1212namespace network {
1313uri_builder::uri_builder (const network::uri &base_uri) {
1414 if (base_uri.has_scheme ()) {
15- set_scheme ( base_uri.scheme ().to_string () );
15+ scheme_ = base_uri.scheme ().to_string ();
1616 }
1717
1818 if (base_uri.has_user_info ()) {
19- set_user_info ( base_uri.user_info ().to_string () );
19+ user_info_ = base_uri.user_info ().to_string ();
2020 }
2121
2222 if (base_uri.has_host ()) {
23- set_host ( base_uri.host ().to_string () );
23+ host_ = base_uri.host ().to_string ();
2424 }
2525
2626 if (base_uri.has_port ()) {
27- set_port ( base_uri.port ().to_string () );
27+ port_ = base_uri.port ().to_string ();
2828 }
2929
3030 if (base_uri.has_path ()) {
31- set_path ( base_uri.path ().to_string () );
31+ path_ = base_uri.path ().to_string ();
3232 }
3333
3434 if (base_uri.has_query ()) {
35- append_query ( base_uri.query ().to_string () );
35+ query_ = base_uri.query ().to_string ();
3636 }
3737
3838 if (base_uri.has_fragment ()) {
39- set_fragment ( base_uri.fragment ().to_string () );
39+ fragment_ = base_uri.fragment ().to_string ();
4040 }
4141}
4242
4343uri_builder::~uri_builder () noexcept {}
4444
4545network::uri uri_builder::uri () const { return network::uri (*this ); }
4646
47- void uri_builder::set_scheme (string_type scheme) {
47+ void uri_builder::set_scheme (string_type && scheme) {
4848 // validate scheme is valid and normalize
4949 scheme_ = scheme;
5050 detail::transform (*scheme_, std::begin (*scheme_),
5151 [] (char ch) { return std::tolower (ch, std::locale ()); });
5252}
5353
54- void uri_builder::set_user_info (string_type user_info) {
54+ void uri_builder::set_user_info (string_type && user_info) {
5555 user_info_ = string_type ();
5656 network::uri::encode_user_info (std::begin (user_info), std::end (user_info),
5757 std::back_inserter (*user_info_));
@@ -62,15 +62,15 @@ uri_builder &uri_builder::clear_user_info() {
6262 return *this ;
6363}
6464
65- void uri_builder::set_host (string_type host) {
65+ void uri_builder::set_host (string_type && host) {
6666 host_ = string_type ();
6767 network::uri::encode_host (std::begin (host), std::end (host),
6868 std::back_inserter (*host_));
6969 detail::transform (*host_, std::begin (*host_),
7070 [](char ch) { return std::tolower (ch, std::locale ()); });
7171}
7272
73- void uri_builder::set_port (string_type port) {
73+ void uri_builder::set_port (string_type && port) {
7474 port_ = string_type ();
7575 network::uri::encode_port (std::begin (port), std::end (port),
7676 std::back_inserter (*port_));
@@ -81,7 +81,7 @@ uri_builder &uri_builder::clear_port() {
8181 return *this ;
8282}
8383
84- void uri_builder::set_authority (string_type authority) {
84+ void uri_builder::set_authority (string_type && authority) {
8585 optional<detail::uri_part> user_info, host, port;
8686 uri::string_view view (authority);
8787 uri::const_iterator it = std::begin (view), last = std::end (view);
@@ -100,7 +100,7 @@ void uri_builder::set_authority(string_type authority) {
100100 }
101101}
102102
103- void uri_builder::set_path (string_type path) {
103+ void uri_builder::set_path (string_type && path) {
104104 path_ = string_type ();
105105 network::uri::encode_path (std::begin (path), std::end (path),
106106 std::back_inserter (*path_));
@@ -111,36 +111,35 @@ uri_builder &uri_builder::clear_path() {
111111 return *this ;
112112}
113113
114- void uri_builder::append_query (string_type query ) {
114+ void uri_builder::append_query_component (string_type &&name ) {
115115 if (!query_) {
116116 query_ = string_type ();
117117 }
118118 else {
119119 query_->append (" &" );
120120 }
121- network::uri::encode_query ( std::begin (query), std::end (query),
122- std::back_inserter (*query_));
121+ network::uri::encode_query_component (
122+ std::begin (name), std::end (name), std::back_inserter (*query_));
123123}
124124
125- void uri_builder::append_query_key_value_pair (string_type key, string_type value) {
125+ void uri_builder::append_query_key_value_pair (string_type && key, string_type && value) {
126126 if (!query_) {
127127 query_ = string_type ();
128128 } else {
129129 query_->push_back (' &' );
130130 }
131- detail::encode_query_component (std::begin (key), std::end (key),
132- std::back_inserter (*query_));
133- query_->push_back (' =' );
134- detail::encode_query_component (std::begin (value), std::end (value),
135- std::back_inserter (*query_));
131+ network::uri::encode_query_key_value_pair (
132+ std::begin (key), std::end (key),
133+ std::begin (value), std::end (value),
134+ std::back_inserter (*query_));
136135}
137136
138137uri_builder &uri_builder::clear_query () {
139138 query_ = network::nullopt ;
140139 return *this ;
141140}
142141
143- void uri_builder::set_fragment (string_type fragment) {
142+ void uri_builder::set_fragment (string_type && fragment) {
144143 fragment_ = string_type ();
145144 network::uri::encode_fragment (std::begin (fragment), std::end (fragment),
146145 std::back_inserter (*fragment_));
0 commit comments