Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:29:27

0001 //
0002 // Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com)
0003 //
0004 // Distributed under the Boost Software License, Version 1.0. (See accompanying
0005 // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
0006 //
0007 // Official repository: https://github.com/boostorg/beast
0008 //
0009 
0010 #ifndef BOOST_BEAST_IMPL_STRING_IPP
0011 #define BOOST_BEAST_IMPL_STRING_IPP
0012 
0013 #include <boost/beast/core/string.hpp>
0014 #include <boost/beast/core/detail/string.hpp>
0015 
0016 #include <algorithm>
0017 
0018 namespace boost {
0019 namespace beast {
0020 
0021 bool
0022 iequals(
0023     beast::string_view lhs,
0024     beast::string_view rhs)
0025 {
0026     auto n = lhs.size();
0027     if(rhs.size() != n)
0028         return false;
0029     auto p1 = lhs.data();
0030     auto p2 = rhs.data();
0031     char a, b;
0032     // fast loop
0033     while(n--)
0034     {
0035         a = *p1++;
0036         b = *p2++;
0037         if(a != b)
0038             goto slow;
0039     }
0040     return true;
0041 slow:
0042     do
0043     {
0044         if( detail::ascii_tolower(a) !=
0045             detail::ascii_tolower(b))
0046             return false;
0047         a = *p1++;
0048         b = *p2++;
0049     }
0050     while(n--);
0051     return true;
0052 }
0053 
0054 bool
0055 iless::operator()(
0056     string_view lhs,
0057     string_view rhs) const
0058 {
0059     using std::begin;
0060     using std::end;
0061     return std::lexicographical_compare(
0062         begin(lhs), end(lhs), begin(rhs), end(rhs),
0063         [](char c1, char c2)
0064         {
0065             return detail::ascii_tolower(c1) < detail::ascii_tolower(c2);
0066         }
0067     );
0068 }
0069 
0070 } // beast
0071 } // boost
0072 
0073 #endif