Remove Spirit dependency

This commit is contained in:
Vinnie Falco
2017-06-16 21:38:17 -07:00
parent a83b1a0108
commit cdff15e021
2 changed files with 18 additions and 5 deletions

View File

@ -1,3 +1,9 @@
Version 61:
* Remove Spirit dependency
--------------------------------------------------------------------------------
Version 60:
* String comparisons are public interfaces

View File

@ -8,8 +8,8 @@
#ifndef BEAST_STRING_HPP
#define BEAST_STRING_HPP
#include <boost/spirit/home/support/char_encoding/ascii.hpp>
#include <boost/utility/string_ref.hpp>
#include <algorithm>
namespace beast {
@ -23,6 +23,15 @@ using basic_string_view =
namespace detail {
inline
char
ascii_tolower(char c)
{
if(c >= 'A' && c <= 'Z')
c += 'a' - 'A';
return c;
}
template<class = void>
bool
iequals(
@ -34,9 +43,8 @@ iequals(
return false;
auto p1 = lhs.data();
auto p2 = rhs.data();
using namespace boost::spirit::char_encoding;
while(n--)
if(ascii::tolower(*p1) != ascii::tolower(*p2))
if(ascii_tolower(*p1) != ascii_tolower(*p2))
return false;
return true;
}
@ -73,12 +81,11 @@ struct iless
{
using std::begin;
using std::end;
using namespace boost::spirit::char_encoding;
return std::lexicographical_compare(
begin(lhs), end(lhs), begin(rhs), end(rhs),
[](char lhs, char rhs)
{
return ascii::tolower(lhs) < ascii::tolower(rhs);
return detail::ascii_tolower(lhs) < detail::ascii_tolower(rhs);
}
);
}