Canonicalize string_view parameter types

This commit is contained in:
Vinnie Falco
2017-06-04 10:52:28 -07:00
parent 048ee7523c
commit aa2c915c96
22 changed files with 141 additions and 140 deletions

View File

@@ -3,6 +3,7 @@ Version 49
API Changes:
* Refactor method and verb
* Canonicalize string_view parameter types
--------------------------------------------------------------------------------

View File

@@ -463,8 +463,8 @@ private:
char const* last, error_code& ec);
void
do_field(string_view const& name,
string_view const& value,
do_field(string_view name,
string_view value,
error_code& ec);
};

View File

@@ -128,7 +128,7 @@ public:
/// Construct a list from a string
explicit
basic_parsed_list(string_view const& s)
basic_parsed_list(string_view s)
: s_(s)
{
}

View File

@@ -211,8 +211,8 @@ protected:
template<class = void>
static
bool
strieq(string_view const& s1,
string_view const& s2)
strieq(string_view s1,
string_view s2)
{
if(s1.size() != s2.size())
return false;
@@ -227,7 +227,7 @@ protected:
template<std::size_t N>
bool
strieq(const char (&s1)[N],
string_view const& s2)
string_view s2)
{
return strieq({s1, N-1}, s2);
}

View File

@@ -29,8 +29,8 @@ public:
std::string first;
std::string second;
value_type(string_view const& name_,
string_view const& value_)
value_type(string_view name_,
string_view value_)
: first(name_)
, second(value_)
{
@@ -63,8 +63,8 @@ protected:
{
value_type data;
element(string_view const& name,
string_view const& value)
element(string_view name,
string_view value)
: data(name, value)
{
}

View File

@@ -329,7 +329,7 @@ skip_token(FwdIt& it, FwdIt const& last)
inline
string_view
trim(string_view const& s)
trim(string_view s)
{
auto first = s.begin();
auto last = s.end();
@@ -459,7 +459,7 @@ struct opt_token_list_policy
bool
operator()(value_type& v,
char const*& it, string_view const& s) const
char const*& it, string_view s) const
{
v = {};
auto need_comma = it != s.begin();

View File

@@ -177,14 +177,14 @@ public:
/// Returns `true` if the specified field exists.
bool
exists(string_view const& name) const
exists(string_view name) const
{
return set_.find(name, less{}) != set_.end();
}
/// Returns the number of values for the specified field.
std::size_t
count(string_view const& name) const;
count(string_view name) const;
/** Returns an iterator to the case-insensitive matching field name.
@@ -192,7 +192,7 @@ public:
first field defined by insertion order is returned.
*/
iterator
find(string_view const& name) const;
find(string_view name) const;
/** Returns the value for a case-insensitive matching header, or `""`.
@@ -200,7 +200,7 @@ public:
first field defined by insertion order is returned.
*/
string_view const
operator[](string_view const& name) const;
operator[](string_view name) const;
/// Clear the contents of the basic_fields.
void
@@ -216,7 +216,7 @@ public:
@return The number of fields removed.
*/
std::size_t
erase(string_view const& name);
erase(string_view name);
/** Insert a field value.
@@ -229,7 +229,7 @@ public:
@param value A string holding the value of the field.
*/
void
insert(string_view const& name, string_view value);
insert(string_view name, string_view value);
/** Insert a field value.
@@ -260,7 +260,7 @@ public:
@param value A string holding the value of the field.
*/
void
replace(string_view const& name, string_view value);
replace(string_view name, string_view value);
/** Replace a field value.
@@ -275,7 +275,7 @@ public:
template<class T>
typename std::enable_if<
! std::is_constructible<string_view, T>::value>::type
replace(string_view const& name, T const& value)
replace(string_view name, T const& value)
{
replace(name,
boost::lexical_cast<std::string>(value));

View File

@@ -739,8 +739,8 @@ template<bool isRequest, class Derived>
void
basic_parser<isRequest, Derived>::
do_field(
string_view const& name,
string_view const& value,
string_view name,
string_view value,
error_code& ec)
{
// Connection

View File

@@ -161,7 +161,7 @@ operator=(basic_fields<OtherAlloc> const& other) ->
template<class Allocator>
std::size_t
basic_fields<Allocator>::
count(string_view const& name) const
count(string_view name) const
{
auto const it = set_.find(name, less{});
if(it == set_.end())
@@ -173,7 +173,7 @@ count(string_view const& name) const
template<class Allocator>
auto
basic_fields<Allocator>::
find(string_view const& name) const ->
find(string_view name) const ->
iterator
{
auto const it = set_.find(name, less{});
@@ -185,7 +185,7 @@ find(string_view const& name) const ->
template<class Allocator>
string_view const
basic_fields<Allocator>::
operator[](string_view const& name) const
operator[](string_view name) const
{
auto const it = find(name);
if(it == end())
@@ -206,7 +206,7 @@ clear() noexcept
template<class Allocator>
std::size_t
basic_fields<Allocator>::
erase(string_view const& name)
erase(string_view name)
{
auto it = set_.find(name, less{});
if(it == set_.end())
@@ -230,7 +230,7 @@ erase(string_view const& name)
template<class Allocator>
void
basic_fields<Allocator>::
insert(string_view const& name,
insert(string_view name,
string_view value)
{
value = detail::trim(value);
@@ -243,7 +243,7 @@ insert(string_view const& name,
template<class Allocator>
void
basic_fields<Allocator>::
replace(string_view const& name,
replace(string_view name,
string_view value)
{
value = detail::trim(value);

View File

@@ -87,7 +87,7 @@ private:
template<class = void>
static
std::string
unquote(string_view const& sr);
unquote(string_view sr);
template<class = void>
void
@@ -133,7 +133,7 @@ cend() const ->
template<class>
std::string
param_list::const_iterator::
unquote(string_view const& sr)
unquote(string_view sr)
{
std::string s;
s.reserve(sr.size());

View File

@@ -187,7 +187,7 @@ private:
void
on_chunk(std::uint64_t,
string_view const&, error_code&)
string_view, error_code&)
{
body_ = {};
}
@@ -331,8 +331,8 @@ private:
void
on_request(
string_view const& method,
string_view const& target,
string_view method,
string_view target,
int version, error_code&)
{
m_.target(target);
@@ -342,7 +342,7 @@ private:
void
on_response(int status,
string_view const& reason,
string_view reason,
int version, error_code&)
{
m_.status = status;
@@ -351,8 +351,8 @@ private:
}
void
on_field(string_view const& name,
string_view const& value,
on_field(string_view name,
string_view value,
error_code&)
{
m_.fields.insert(name, value);
@@ -373,7 +373,7 @@ private:
}
void
on_data(string_view const& s,
on_data(string_view s,
error_code& ec)
{
wr_->put(boost::asio::buffer(
@@ -382,7 +382,7 @@ private:
void
on_chunk(
std::uint64_t, string_view const&,
std::uint64_t, string_view,
error_code&)
{
}

View File

@@ -77,7 +77,7 @@ public:
must remain valid for the lifetime of the container.
*/
explicit
param_list(string_view const& s)
param_list(string_view s)
: s_(s)
{
}
@@ -163,7 +163,7 @@ public:
must remain valid for the lifetime of the container.
*/
explicit
ext_list(string_view const& s)
ext_list(string_view s)
: s_(s)
{
}
@@ -251,7 +251,7 @@ public:
must remain valid for the lifetime of the container.
*/
explicit
token_list(string_view const& s)
token_list(string_view s)
: s_(s)
{
}

View File

@@ -47,7 +47,7 @@ struct pmd_offer
template<class = void>
int
parse_bits(string_view const& s)
parse_bits(string_view s)
{
if(s.size() == 0)
return -1;

View File

@@ -47,8 +47,8 @@ class stream<NextLayer>::handshake_op
template<class Decorator>
data(Handler& handler, stream<NextLayer>& ws_,
response_type* res_p_,
string_view const& host,
string_view const& target,
string_view host,
string_view target,
Decorator const& decorator)
: ws(ws_)
, res_p(res_p_)
@@ -171,8 +171,8 @@ template<class HandshakeHandler>
async_return_type<
HandshakeHandler, void(error_code)>
stream<NextLayer>::
async_handshake(string_view const& host,
string_view const& target,
async_handshake(string_view host,
string_view target,
HandshakeHandler&& handler)
{
static_assert(is_async_stream<next_layer_type>::value,
@@ -192,8 +192,8 @@ async_return_type<
HandshakeHandler, void(error_code)>
stream<NextLayer>::
async_handshake(response_type& res,
string_view const& host,
string_view const& target,
string_view host,
string_view target,
HandshakeHandler&& handler)
{
static_assert(is_async_stream<next_layer_type>::value,
@@ -212,8 +212,8 @@ template<class RequestDecorator, class HandshakeHandler>
async_return_type<
HandshakeHandler, void(error_code)>
stream<NextLayer>::
async_handshake_ex(string_view const& host,
string_view const& target,
async_handshake_ex(string_view host,
string_view target,
RequestDecorator const& decorator,
HandshakeHandler&& handler)
{
@@ -237,8 +237,8 @@ async_return_type<
HandshakeHandler, void(error_code)>
stream<NextLayer>::
async_handshake_ex(response_type& res,
string_view const& host,
string_view const& target,
string_view host,
string_view target,
RequestDecorator const& decorator,
HandshakeHandler&& handler)
{
@@ -259,8 +259,8 @@ async_handshake_ex(response_type& res,
template<class NextLayer>
void
stream<NextLayer>::
handshake(string_view const& host,
string_view const& target)
handshake(string_view host,
string_view target)
{
static_assert(is_sync_stream<next_layer_type>::value,
"SyncStream requirements not met");
@@ -275,8 +275,8 @@ template<class NextLayer>
void
stream<NextLayer>::
handshake(response_type& res,
string_view const& host,
string_view const& target)
string_view host,
string_view target)
{
static_assert(is_sync_stream<next_layer_type>::value,
"SyncStream requirements not met");
@@ -290,8 +290,8 @@ template<class NextLayer>
template<class RequestDecorator>
void
stream<NextLayer>::
handshake_ex(string_view const& host,
string_view const& target,
handshake_ex(string_view host,
string_view target,
RequestDecorator const& decorator)
{
static_assert(is_sync_stream<next_layer_type>::value,
@@ -310,8 +310,8 @@ template<class RequestDecorator>
void
stream<NextLayer>::
handshake_ex(response_type& res,
string_view const& host,
string_view const& target,
string_view host,
string_view target,
RequestDecorator const& decorator)
{
static_assert(is_sync_stream<next_layer_type>::value,
@@ -328,8 +328,8 @@ handshake_ex(response_type& res,
template<class NextLayer>
void
stream<NextLayer>::
handshake(string_view const& host,
string_view const& target, error_code& ec)
handshake(string_view host,
string_view target, error_code& ec)
{
static_assert(is_sync_stream<next_layer_type>::value,
"SyncStream requirements not met");
@@ -341,8 +341,8 @@ template<class NextLayer>
void
stream<NextLayer>::
handshake(response_type& res,
string_view const& host,
string_view const& target,
string_view host,
string_view target,
error_code& ec)
{
static_assert(is_sync_stream<next_layer_type>::value,
@@ -355,8 +355,8 @@ template<class NextLayer>
template<class RequestDecorator>
void
stream<NextLayer>::
handshake_ex(string_view const& host,
string_view const& target,
handshake_ex(string_view host,
string_view target,
RequestDecorator const& decorator,
error_code& ec)
{
@@ -374,8 +374,8 @@ template<class RequestDecorator>
void
stream<NextLayer>::
handshake_ex(response_type& res,
string_view const& host,
string_view const& target,
string_view host,
string_view target,
RequestDecorator const& decorator,
error_code& ec)
{

View File

@@ -128,8 +128,8 @@ template<class RequestDecorator>
void
stream<NextLayer>::
do_handshake(response_type* res_p,
string_view const& host,
string_view const& target,
string_view host,
string_view target,
RequestDecorator const& decorator,
error_code& ec)
{
@@ -157,8 +157,8 @@ template<class Decorator>
request_type
stream<NextLayer>::
build_request(detail::sec_ws_key_type& key,
string_view const& host,
string_view const& target,
string_view host,
string_view target,
Decorator const& decorator)
{
request_type req;

View File

@@ -1471,8 +1471,8 @@ public:
@endcode
*/
void
handshake(string_view const& host,
string_view const& target);
handshake(string_view host,
string_view target);
/** Send an HTTP WebSocket Upgrade request and receive the response.
@@ -1519,8 +1519,8 @@ public:
*/
void
handshake(response_type& res,
string_view const& host,
string_view const& target);
string_view host,
string_view target);
/** Send an HTTP WebSocket Upgrade request and receive the response.
@@ -1576,8 +1576,8 @@ public:
*/
template<class RequestDecorator>
void
handshake_ex(string_view const& host,
string_view const& target,
handshake_ex(string_view host,
string_view target,
RequestDecorator const& decorator);
/** Send an HTTP WebSocket Upgrade request and receive the response.
@@ -1639,8 +1639,8 @@ public:
template<class RequestDecorator>
void
handshake_ex(response_type& res,
string_view const& host,
string_view const& target,
string_view host,
string_view target,
RequestDecorator const& decorator);
/** Send an HTTP WebSocket Upgrade request and receive the response.
@@ -1681,8 +1681,8 @@ public:
@endcode
*/
void
handshake(string_view const& host,
string_view const& target, error_code& ec);
handshake(string_view host,
string_view target, error_code& ec);
/** Send an HTTP WebSocket Upgrade request and receive the response.
@@ -1727,8 +1727,8 @@ public:
*/
void
handshake(response_type& res,
string_view const& host,
string_view const& target,
string_view host,
string_view target,
error_code& ec);
/** Send an HTTP WebSocket Upgrade request and receive the response.
@@ -1784,8 +1784,8 @@ public:
*/
template<class RequestDecorator>
void
handshake_ex(string_view const& host,
string_view const& target,
handshake_ex(string_view host,
string_view target,
RequestDecorator const& decorator,
error_code& ec);
@@ -1847,8 +1847,8 @@ public:
template<class RequestDecorator>
void
handshake_ex(response_type& res,
string_view const& host,
string_view const& target,
string_view host,
string_view target,
RequestDecorator const& decorator,
error_code& ec);
@@ -1899,8 +1899,8 @@ public:
async_return_type<
HandshakeHandler, void(error_code)>
#endif
async_handshake(string_view const& host,
string_view const& target,
async_handshake(string_view host,
string_view target,
HandshakeHandler&& handler);
/** Start an asynchronous operation to send an upgrade request and receive the response.
@@ -1955,8 +1955,8 @@ public:
HandshakeHandler, void(error_code)>
#endif
async_handshake(response_type& res,
string_view const& host,
string_view const& target,
string_view host,
string_view target,
HandshakeHandler&& handler);
/** Start an asynchronous operation to send an upgrade request and receive the response.
@@ -2015,8 +2015,8 @@ public:
async_return_type<
HandshakeHandler, void(error_code)>
#endif
async_handshake_ex(string_view const& host,
string_view const& target,
async_handshake_ex(string_view host,
string_view target,
RequestDecorator const& decorator,
HandshakeHandler&& handler);
@@ -2081,8 +2081,8 @@ public:
HandshakeHandler, void(error_code)>
#endif
async_handshake_ex(response_type& res,
string_view const& host,
string_view const& target,
string_view host,
string_view target,
RequestDecorator const& decorator,
HandshakeHandler&& handler);
@@ -2963,16 +2963,16 @@ private:
template<class RequestDecorator>
void
do_handshake(response_type* res_p,
string_view const& host,
string_view const& target,
string_view host,
string_view target,
RequestDecorator const& decorator,
error_code& ec);
template<class Decorator>
request_type
build_request(detail::sec_ws_key_type& key,
string_view const& host,
string_view const& target,
string_view host,
string_view target,
Decorator const& decorator);
template<class Fields, class Decorator>

View File

@@ -217,7 +217,7 @@ public:
template<bool isRequest, class Pred>
void
good(string_view const& s,
good(string_view s,
Pred const& pred, bool skipBody = false)
{
using boost::asio::buffer;
@@ -239,7 +239,7 @@ public:
template<bool isRequest>
void
good(string_view const& s)
good(string_view s)
{
good<isRequest>(s,
[](test_parser<isRequest> const&)
@@ -249,7 +249,7 @@ public:
template<bool isRequest>
void
bad(string_view const& s,
bad(string_view s,
error_code const& ev, bool skipBody = false)
{
using boost::asio::buffer;

View File

@@ -19,7 +19,7 @@ namespace http {
template<class = void>
std::string
escaped_string(string_view const& s)
escaped_string(string_view s)
{
std::string out;
out.reserve(s.size());

View File

@@ -165,22 +165,22 @@ public:
boost::asio::mutable_buffers_1;
void
on_request(string_view const&,
string_view const&,
on_request(string_view,
string_view,
int, error_code&)
{
}
void
on_response(int,
string_view const&,
string_view,
int, error_code&)
{
}
void
on_field(string_view const&,
string_view const&,
on_field(string_view,
string_view,
error_code&)
{
}
@@ -197,14 +197,14 @@ public:
}
void
on_data(string_view const&,
on_data(string_view,
error_code& ec)
{
}
void
on_chunk(std::uint64_t,
string_view const&,
string_view,
error_code&)
{
}

View File

@@ -30,7 +30,7 @@ public:
static
std::string
str(string_view const& s)
str(string_view s)
{
return std::string(s.data(), s.size());
}
@@ -241,7 +241,7 @@ public:
template<class Policy>
static
std::vector<std::string>
to_vector(string_view const& in)
to_vector(string_view in)
{
std::vector<std::string> v;
detail::basic_parsed_list<Policy> list{in};
@@ -253,7 +253,7 @@ public:
template<class Policy>
void
validate(string_view const& in,
validate(string_view in,
std::vector<std::string> const& v)
{
BEAST_EXPECT(to_vector<Policy>(in) == v);
@@ -261,7 +261,7 @@ public:
template<class Policy>
void
good(string_view const& in)
good(string_view in)
{
BEAST_EXPECT(validate_list(
detail::basic_parsed_list<Policy>{in}));
@@ -269,7 +269,7 @@ public:
template<class Policy>
void
good(string_view const& in,
good(string_view in,
std::vector<std::string> const& v)
{
BEAST_EXPECT(validate_list(
@@ -279,7 +279,7 @@ public:
template<class Policy>
void
bad(string_view const& in)
bad(string_view in)
{
BEAST_EXPECT(! validate_list(
detail::basic_parsed_list<Policy>{in}));

View File

@@ -47,8 +47,8 @@ public:
}
void
on_request(string_view const& method_,
string_view const& path_,
on_request(string_view method_,
string_view path_,
int version_, error_code& ec)
{
method = std::string(
@@ -63,7 +63,7 @@ public:
void
on_response(int status_,
string_view const& reason_,
string_view reason_,
int version_, error_code& ec)
{
status = status_;
@@ -76,8 +76,8 @@ public:
}
void
on_field(string_view const&,
string_view const&,
on_field(string_view,
string_view,
error_code& ec)
{
got_on_field = true;
@@ -106,7 +106,7 @@ public:
}
void
on_data(string_view const& s,
on_data(string_view s,
error_code& ec)
{
body.append(s.data(), s.size());
@@ -116,7 +116,7 @@ public:
void
on_chunk(std::uint64_t,
string_view const&, error_code& ec)
string_view, error_code& ec)
{
got_on_chunk = true;
if(fc_)

View File

@@ -200,8 +200,8 @@ public:
template<class NextLayer>
void
handshake(stream<NextLayer>& ws,
string_view const& uri,
string_view const& path) const
string_view uri,
string_view path) const
{
ws.handshake(uri, path);
}
@@ -210,8 +210,8 @@ public:
void
handshake(stream<NextLayer>& ws,
response_type& res,
string_view const& uri,
string_view const& path) const
string_view uri,
string_view path) const
{
ws.handshake(res, uri, path);
}
@@ -219,8 +219,8 @@ public:
template<class NextLayer, class Decorator>
void
handshake_ex(stream<NextLayer>& ws,
string_view const& uri,
string_view const& path,
string_view uri,
string_view path,
Decorator const& d) const
{
ws.handshake_ex(uri, path, d);
@@ -230,8 +230,8 @@ public:
void
handshake_ex(stream<NextLayer>& ws,
response_type& res,
string_view const& uri,
string_view const& path,
string_view uri,
string_view path,
Decorator const& d) const
{
ws.handshake_ex(res, uri, path, d);
@@ -413,8 +413,8 @@ public:
template<class NextLayer>
void
handshake(stream<NextLayer>& ws,
string_view const& uri,
string_view const& path) const
string_view uri,
string_view path) const
{
error_code ec;
ws.async_handshake(
@@ -427,8 +427,8 @@ public:
void
handshake(stream<NextLayer>& ws,
response_type& res,
string_view const& uri,
string_view const& path) const
string_view uri,
string_view path) const
{
error_code ec;
ws.async_handshake(
@@ -440,8 +440,8 @@ public:
template<class NextLayer, class Decorator>
void
handshake_ex(stream<NextLayer>& ws,
string_view const& uri,
string_view const& path,
string_view uri,
string_view path,
Decorator const &d) const
{
error_code ec;
@@ -455,8 +455,8 @@ public:
void
handshake_ex(stream<NextLayer>& ws,
response_type& res,
string_view const& uri,
string_view const& path,
string_view uri,
string_view path,
Decorator const &d) const
{
error_code ec;