2 // Copyright (c) 2016-2017 Vinnie Falco (vinnie dot falco at gmail dot com)
4 // Distributed under the Boost Software License, Version 1.0. (See accompanying
5 // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
7 // Official repository: https://github.com/boostorg/beast
10 #ifndef BOOST_BEAST_STRING_HPP
11 #define BOOST_BEAST_STRING_HPP
13 #include <boost/beast/core/detail/config.hpp>
14 #include <boost/version.hpp>
15 #ifndef BOOST_BEAST_NO_BOOST_STRING_VIEW
16 # if BOOST_VERSION >= 106400
17 # define BOOST_BEAST_NO_BOOST_STRING_VIEW 0
19 # define BOOST_BEAST_NO_BOOST_STRING_VIEW 1
23 #if BOOST_BEAST_NO_BOOST_STRING_VIEW
24 #include <boost/utility/string_ref.hpp>
26 #include <boost/utility/string_view.hpp>
34 #if BOOST_BEAST_NO_BOOST_STRING_VIEW
35 /// The type of string view used by the library
36 using string_view = boost::string_ref;
38 /// The type of basic string view used by the library
39 template<class CharT, class Traits>
40 using basic_string_view =
41 boost::basic_string_ref<CharT, Traits>;
43 /// The type of string view used by the library
44 using string_view = boost::string_view;
46 /// The type of basic string view used by the library
47 template<class CharT, class Traits>
48 using basic_string_view =
49 boost::basic_string_view<CharT, Traits>;
58 if(c >= 'A' && c <= 'Z')
63 template<class = void>
66 beast::string_view lhs,
67 beast::string_view rhs)
87 if(ascii_tolower(a) != ascii_tolower(b))
97 /** Returns `true` if two strings are equal, using a case-insensitive comparison.
99 The case-comparison operation is defined only for low-ASCII characters.
101 @param lhs The string on the left side of the equality
103 @param rhs The string on the right side of the equality
108 beast::string_view lhs,
109 beast::string_view rhs)
111 return detail::iequals(lhs, rhs);
114 /** A case-insensitive less predicate for strings.
116 The case-comparison operation is defined only for low-ASCII characters.
123 string_view rhs) const
127 return std::lexicographical_compare(
128 begin(lhs), end(lhs), begin(rhs), end(rhs),
131 return detail::ascii_tolower(c1) < detail::ascii_tolower(c2);
137 /** A case-insensitive equality predicate for strings.
139 The case-comparison operation is defined only for low-ASCII characters.
146 string_view rhs) const
148 return iequals(lhs, rhs);