mirror of
https://github.com/boostorg/beast.git
synced 2025-07-31 13:27:33 +02:00
Add BOOST_BEAST_USE_STD_STRING_VIEW:
fix #1133, fix #1241 When the macro BOOST_BEAST_USE_STD_STRING_VIEW is defined, Beast will use std::string_view instead of boost::string_view. The name boost::beast::string_view is a type alias for the chosen view type.
This commit is contained in:
committed by
Vinnie Falco
parent
f3212eba48
commit
806979e37b
@@ -2,6 +2,7 @@ Version 184:
|
|||||||
|
|
||||||
* Remove extraneous function
|
* Remove extraneous function
|
||||||
* Fix some typos
|
* Fix some typos
|
||||||
|
* Add BOOST_BEAST_USE_STD_STRING_VIEW
|
||||||
|
|
||||||
--------------------------------------------------------------------------------
|
--------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
@@ -13,6 +13,10 @@
|
|||||||
|
|
||||||
[heading Boost 1.69]
|
[heading Boost 1.69]
|
||||||
|
|
||||||
|
[* New Features]
|
||||||
|
|
||||||
|
* ([issue 1133]) Add `BOOST_BEAST_USE_STD_STRING_VIEW`
|
||||||
|
|
||||||
[*Fixes]
|
[*Fixes]
|
||||||
|
|
||||||
* ([issue 1245]) Fix a rare case of incorrect UTF8 validation
|
* ([issue 1245]) Fix a rare case of incorrect UTF8 validation
|
||||||
@@ -25,6 +29,7 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
[heading Boost 1.68]
|
[heading Boost 1.68]
|
||||||
|
|
||||||
This version fixes a missing executor work guard in all composed operations
|
This version fixes a missing executor work guard in all composed operations
|
||||||
|
@@ -12,19 +12,35 @@
|
|||||||
|
|
||||||
#include <boost/beast/core/detail/config.hpp>
|
#include <boost/beast/core/detail/config.hpp>
|
||||||
#include <boost/version.hpp>
|
#include <boost/version.hpp>
|
||||||
|
|
||||||
|
#if defined(BOOST_BEAST_USE_STD_STRING_VIEW)
|
||||||
|
#include <string_view>
|
||||||
|
#else
|
||||||
#include <boost/utility/string_view.hpp>
|
#include <boost/utility/string_view.hpp>
|
||||||
|
#endif
|
||||||
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
|
||||||
namespace boost {
|
namespace boost {
|
||||||
namespace beast {
|
namespace beast {
|
||||||
|
|
||||||
/// The type of string view used by the library
|
#if defined(BOOST_BEAST_USE_STD_STRING_VIEW)
|
||||||
using string_view = boost::string_view;
|
/// The type of string view used by the library
|
||||||
|
using string_view = std::string_view;
|
||||||
|
|
||||||
/// The type of basic string view used by the library
|
/// The type of basic string view used by the library
|
||||||
template<class CharT, class Traits>
|
template<class CharT, class Traits>
|
||||||
using basic_string_view =
|
using basic_string_view =
|
||||||
boost::basic_string_view<CharT, Traits>;
|
std::basic_string_view<CharT, Traits>;
|
||||||
|
#else
|
||||||
|
/// The type of string view used by the library
|
||||||
|
using string_view = boost::string_view;
|
||||||
|
|
||||||
|
/// The type of basic string view used by the library
|
||||||
|
template<class CharT, class Traits>
|
||||||
|
using basic_string_view =
|
||||||
|
boost::basic_string_view<CharT, Traits>;
|
||||||
|
#endif
|
||||||
|
|
||||||
namespace detail {
|
namespace detail {
|
||||||
|
|
||||||
|
@@ -110,7 +110,7 @@ public:
|
|||||||
basic_parsed_list const& list, bool at_end)
|
basic_parsed_list const& list, bool at_end)
|
||||||
: list_(&list)
|
: list_(&list)
|
||||||
, it_(at_end ? nullptr :
|
, it_(at_end ? nullptr :
|
||||||
list.s_.begin())
|
list.s_.data())
|
||||||
{
|
{
|
||||||
if(! at_end)
|
if(! at_end)
|
||||||
increment();
|
increment();
|
||||||
|
@@ -429,11 +429,11 @@ struct opt_token_list_policy
|
|||||||
char const*& it, string_view s) const
|
char const*& it, string_view s) const
|
||||||
{
|
{
|
||||||
v = {};
|
v = {};
|
||||||
auto need_comma = it != s.begin();
|
auto need_comma = it != s.data();
|
||||||
for(;;)
|
for(;;)
|
||||||
{
|
{
|
||||||
detail::skip_ows(it, s.end());
|
detail::skip_ows(it, (s.data() + s.size()));
|
||||||
if(it == s.end())
|
if(it == (s.data() + s.size()))
|
||||||
{
|
{
|
||||||
it = nullptr;
|
it = nullptr;
|
||||||
return true;
|
return true;
|
||||||
@@ -447,12 +447,12 @@ struct opt_token_list_policy
|
|||||||
for(;;)
|
for(;;)
|
||||||
{
|
{
|
||||||
++it;
|
++it;
|
||||||
if(it == s.end())
|
if(it == (s.data() + s.size()))
|
||||||
break;
|
break;
|
||||||
if(! detail::is_token_char(*it))
|
if(! detail::is_token_char(*it))
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
v = string_view{&*p0,
|
v = string_view{p0,
|
||||||
static_cast<std::size_t>(it - p0)};
|
static_cast<std::size_t>(it - p0)};
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@@ -51,7 +51,7 @@ struct field_table
|
|||||||
{
|
{
|
||||||
auto p1 = lhs.data();
|
auto p1 = lhs.data();
|
||||||
auto p2 = rhs.data();
|
auto p2 = rhs.data();
|
||||||
auto pend = lhs.end();
|
auto pend = p1 + lhs.size();
|
||||||
char a, b;
|
char a, b;
|
||||||
while(p1 < pend)
|
while(p1 < pend)
|
||||||
{
|
{
|
||||||
|
@@ -127,7 +127,7 @@ string_to_verb(string_view v)
|
|||||||
++s;
|
++s;
|
||||||
++p;
|
++p;
|
||||||
if(! *s)
|
if(! *s)
|
||||||
return p == sv.end();
|
return p == (sv.data() + sv.size());
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
auto c = v[0];
|
auto c = v[0];
|
||||||
|
Reference in New Issue
Block a user