Use beast::string_view alias

This commit is contained in:
Vinnie Falco committed 2017-07-20 08:12:16 -07:00
1 parent f50a37b778
commit 84ece031f2
36 files changed
+319 -288

No files matched your search

+1
View File
@@ -37,6 +37,7 @@ unit-test core-tests :
core/static_buffer.cpp
core/static_string.cpp
core/stream_concepts.cpp
core/string_view.cpp
core/base64.cpp
core/empty_base_optimization.cpp
core/get_lowest_layer.cpp
+1
View File
@@ -30,6 +30,7 @@ add_executable (core-tests
static_buffer.cpp
static_string.cpp
stream_concepts.cpp
string_view.cpp
base64.cpp
empty_base_optimization.cpp
get_lowest_layer.cpp
+13 -13
View File
@@ -123,13 +123,13 @@ public:
}
{
static_string<3> s1(
boost::string_ref("123"));
string_view("123"));
BEAST_EXPECT(s1 == "123");
BEAST_EXPECT(*s1.end() == 0);
try
{
static_string<2> s2(
boost::string_ref("123"));
string_view("123"));
fail("", __FILE__, __LINE__);
}
catch(std::length_error const&)
@@ -232,13 +232,13 @@ public:
}
{
static_string<3> s1;
s1 = boost::string_ref("123");
s1 = string_view("123");
BEAST_EXPECT(s1 == "123");
BEAST_EXPECT(*s1.end() == 0);
try
{
static_string<1> s2;
s2 = boost::string_ref("123");
s2 = string_view("123");
fail("", __FILE__, __LINE__);
}
catch(std::length_error const&)
@@ -370,15 +370,15 @@ public:
}
{
static_string<5> s1;
s1.assign(boost::string_ref("123"));
s1.assign(string_view("123"));
BEAST_EXPECT(s1 == "123");
BEAST_EXPECT(*s1.end() == 0);
s1.assign(boost::string_ref("12345"));
s1.assign(string_view("12345"));
BEAST_EXPECT(s1 == "12345");
BEAST_EXPECT(*s1.end() == 0);
try
{
s1.assign(boost::string_ref("1234567"));
s1.assign(string_view("1234567"));
fail("", __FILE__, __LINE__);
}
catch(std::length_error const&)
@@ -483,7 +483,7 @@ public:
}
{
static_string<3> s("123");
boost::string_ref sv = s;
string_view sv = s;
BEAST_EXPECT(static_string<5>(sv) == "123");
}
}
@@ -750,13 +750,13 @@ public:
}
{
static_string<5> s1("123");
s1.insert(1, boost::string_ref("UV"));
s1.insert(1, string_view("UV"));
BEAST_EXPECT(s1 == "1UV23");
BEAST_EXPECT(*s1.end() == 0);
try
{
static_string<4> s2("123");
s2.insert(1, boost::string_ref("UV"));
s2.insert(1, string_view("UV"));
fail("", __FILE__, __LINE__);
}
catch(std::length_error const&)
@@ -766,7 +766,7 @@ public:
try
{
static_string<5> s2("123");
s2.insert(5, boost::string_ref("UV"));
s2.insert(5, string_view("UV"));
fail("", __FILE__, __LINE__);
}
catch(std::out_of_range const&)
@@ -1024,7 +1024,7 @@ public:
}
}
{
boost::string_ref s1("XYZ");
string_view s1("XYZ");
static_string<5> s2("12");
s2.append(s1);
BEAST_EXPECT(s2 == "12XYZ");
@@ -1124,7 +1124,7 @@ public:
}
}
{
boost::string_ref s1("34");
string_view s1("34");
static_string<4> s2("12");
s2 += s1;
BEAST_EXPECT(s2 == "1234");
+9
View File
@@ -0,0 +1,9 @@
//
// Copyright (c) 2013-2017 Vinnie Falco (vinnie dot falco at gmail dot com)
//
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
//
// Test that header file is self-contained.
#include <beast/core/string_view.hpp>
+3 -3
View File
@@ -218,7 +218,7 @@ public:
template<bool isRequest, class Pred>
void
good(boost::string_ref const& s,
good(string_view const& s,
Pred const& pred, bool skipBody = false)
{
using boost::asio::buffer;
@@ -240,7 +240,7 @@ public:
template<bool isRequest>
void
good(boost::string_ref const& s)
good(string_view const& s)
{
good<isRequest>(s,
[](test_parser<isRequest> const&)
@@ -250,7 +250,7 @@ public:
template<bool isRequest>
void
bad(boost::string_ref const& s,
bad(string_view const& s,
error_code const& ev, bool skipBody = false)
{
using boost::asio::buffer;
+2 -2
View File
@@ -176,7 +176,7 @@ public:
}
void
write(boost::string_ref const& s,
write(string_view const& s,
error_code& ec)
{
body_.append(s.data(), s.size());
@@ -464,7 +464,7 @@ public:
struct bodyHandler
{
void
operator()(boost::string_ref const& body) const
operator()(string_view const& body) const
{
// called for each piece of the body,
}
+1 -1
View File
@@ -19,7 +19,7 @@ namespace http {
template<class = void>
std::string
escaped_string(boost::string_ref const& s)
escaped_string(string_view const& s)
{
std::string out;
out.reserve(s.size());
+8 -8
View File
@@ -168,22 +168,22 @@ public:
boost::asio::mutable_buffers_1;
void
on_request(boost::string_ref const&,
boost::string_ref const&,
on_request(string_view const&,
string_view const&,
int, error_code&)
{
}
void
on_response(int,
boost::string_ref const&,
string_view const&,
int, error_code&)
{
}
void
on_field(boost::string_ref const&,
boost::string_ref const&,
on_field(string_view const&,
string_view const&,
error_code&)
{
}
@@ -205,20 +205,20 @@ public:
}
void
on_data(boost::string_ref const&,
on_data(string_view const&,
error_code& ec)
{
}
void
on_chunk(std::uint64_t,
boost::string_ref const&,
string_view const&,
error_code&)
{
}
void
on_body(boost::string_ref const&,
on_body(string_view const&,
error_code&)
{
}
+6 -6
View File
@@ -30,7 +30,7 @@ public:
static
std::string
str(boost::string_ref const& s)
str(string_view const& s)
{
return std::string(s.data(), s.size());
}
@@ -241,7 +241,7 @@ public:
template<class Policy>
static
std::vector<std::string>
to_vector(boost::string_ref const& in)
to_vector(string_view const& in)
{
std::vector<std::string> v;
detail::basic_parsed_list<Policy> list{in};
@@ -253,7 +253,7 @@ public:
template<class Policy>
void
validate(boost::string_ref const& in,
validate(string_view const& in,
std::vector<std::string> const& v)
{
BEAST_EXPECT(to_vector<Policy>(in) == v);
@@ -261,7 +261,7 @@ public:
template<class Policy>
void
good(boost::string_ref const& in)
good(string_view const& in)
{
BEAST_EXPECT(validate_list(
detail::basic_parsed_list<Policy>{in}));
@@ -269,7 +269,7 @@ public:
template<class Policy>
void
good(boost::string_ref const& in,
good(string_view const& in,
std::vector<std::string> const& v)
{
BEAST_EXPECT(validate_list(
@@ -279,7 +279,7 @@ public:
template<class Policy>
void
bad(boost::string_ref const& in)
bad(string_view const& in)
{
BEAST_EXPECT(! validate_list(
detail::basic_parsed_list<Policy>{in}));
+7 -7
View File
@@ -51,8 +51,8 @@ public:
void
on_request(
boost::string_ref const& method_,
boost::string_ref const& path_,
string_view const& method_,
string_view const& path_,
int version_, error_code& ec)
{
method = std::string(
@@ -67,7 +67,7 @@ public:
void
on_response(int status_,
boost::string_ref const& reason_,
string_view const& reason_,
int version_, error_code& ec)
{
status = status_;
@@ -80,8 +80,8 @@ public:
}
void
on_field(boost::string_ref const&,
boost::string_ref const&,
on_field(string_view const&,
string_view const&,
error_code& ec)
{
got_on_field = true;
@@ -116,7 +116,7 @@ public:
}
void
on_data(boost::string_ref const& s,
on_data(string_view const& s,
error_code& ec)
{
body.append(s.data(), s.size());
@@ -124,7 +124,7 @@ public:
void
on_chunk(std::uint64_t,
boost::string_ref const&,
string_view const&,
error_code& ec)
{
got_on_chunk = true;
+16 -16
View File
@@ -198,8 +198,8 @@ public:
template<class NextLayer>
void
handshake(stream<NextLayer>& ws,
boost::string_ref const& uri,
boost::string_ref const& path) const
string_view const& uri,
string_view const& path) const
{
ws.handshake(uri, path);
}
@@ -208,8 +208,8 @@ public:
void
handshake(stream<NextLayer>& ws,
response_type& res,
boost::string_ref const& uri,
boost::string_ref const& path) const
string_view const& uri,
string_view const& path) const
{
ws.handshake(res, uri, path);
}
@@ -217,8 +217,8 @@ public:
template<class NextLayer, class Decorator>
void
handshake_ex(stream<NextLayer>& ws,
boost::string_ref const& uri,
boost::string_ref const& path,
string_view const& uri,
string_view const& path,
Decorator const& d) const
{
ws.handshake_ex(uri, path, d);
@@ -228,8 +228,8 @@ public:
void
handshake_ex(stream<NextLayer>& ws,
response_type& res,
boost::string_ref const& uri,
boost::string_ref const& path,
string_view const& uri,
string_view const& path,
Decorator const& d) const
{
ws.handshake_ex(res, uri, path, d);
@@ -409,8 +409,8 @@ public:
template<class NextLayer>
void
handshake(stream<NextLayer>& ws,
boost::string_ref const& uri,
boost::string_ref const& path) const
string_view const& uri,
string_view const& path) const
{
error_code ec;
ws.async_handshake(
@@ -423,8 +423,8 @@ public:
void
handshake(stream<NextLayer>& ws,
response_type& res,
boost::string_ref const& uri,
boost::string_ref const& path) const
string_view const& uri,
string_view const& path) const
{
error_code ec;
ws.async_handshake(
@@ -436,8 +436,8 @@ public:
template<class NextLayer, class Decorator>
void
handshake_ex(stream<NextLayer>& ws,
boost::string_ref const& uri,
boost::string_ref const& path,
string_view const& uri,
string_view const& path,
Decorator const &d) const
{
error_code ec;
@@ -451,8 +451,8 @@ public:
void
handshake_ex(stream<NextLayer>& ws,
response_type& res,
boost::string_ref const& uri,
boost::string_ref const& path,
string_view const& uri,
string_view const& path,
Decorator const &d) const
{
error_code ec;