diff --git a/test/unit/snippets.cpp b/test/unit/snippets.cpp index 3fc42b40..1faf3cae 100644 --- a/test/unit/snippets.cpp +++ b/test/unit/snippets.cpp @@ -22,7 +22,7 @@ //[snippet_headers_3 #include -namespace urls = boost::urls; +using namespace boost::urls; //] #include @@ -31,30 +31,30 @@ void using_url_views() { //[snippet_parsing_1 - urls::string_view s = "https://user:pass@example.com:443/path/to/my%2dfile.txt?id=42&name=John%20Doe+Jingleheimer%2DSchmidt#page%20anchor"; + string_view s = "https://user:pass@example.com:443/path/to/my%2dfile.txt?id=42&name=John%20Doe+Jingleheimer%2DSchmidt#page%20anchor"; //] { //[snippet_parsing_2 - urls::result r = urls::parse_uri( s ); + result r = parse_uri( s ); //] } { - urls::result r = urls::parse_uri( s ); + result r = parse_uri( s ); //[snippet_parsing_3 - urls::url_view u = r.value(); + url_view u = r.value(); //] } { - urls::result r = urls::parse_uri( s ); + result r = parse_uri( s ); //[snippet_parsing_4 - urls::url_view u = *r; + url_view u = *r; //] } - urls::url_view u = urls::parse_uri( s ).value(); + url_view u = parse_uri( s ).value(); //[snippet_accessing_1 std::cout << @@ -81,27 +81,27 @@ using_url_views() { //[snippet_accessing_2a - urls::url_view u1 = urls::parse_uri( "http://www.example.com" ).value(); + url_view u1 = parse_uri( "http://www.example.com" ).value(); std::cout << "fragment 1 : " << u1.fragment() << "\n\n"; //] } { //[snippet_accessing_2b - urls::url_view u2 = urls::parse_uri( "http://www.example.com/#" ).value(); + url_view u2 = parse_uri( "http://www.example.com/#" ).value(); std::cout << "fragment 2 : " << u2.fragment() << "\n\n"; //] } { //[snippet_accessing_3a - urls::url_view u1 = urls::parse_uri( "http://www.example.com" ).value(); + url_view u1 = parse_uri( "http://www.example.com" ).value(); std::cout << "has fragment 1 : " << u1.has_fragment() << "\n"; std::cout << "fragment 1 : " << u1.fragment() << "\n\n"; //] //[snippet_accessing_3b - urls::url_view u2 = urls::parse_uri( "http://www.example.com/#" ).value(); + url_view u2 = parse_uri( "http://www.example.com/#" ).value(); std::cout << "has fragment 2 : " << u2.has_fragment() << "\n"; std::cout << "fragment 2 : " << u2.fragment() << "\n\n"; //] @@ -134,8 +134,8 @@ using_url_views() //] } { - urls::url u1 = u; - urls::url u2 = u; + url u1 = u; + url u2 = u; //[snippet_decoding_2 u1.set_host(u2.host()); //] @@ -154,13 +154,13 @@ using_url_views() { auto handle_route = []( std::vector const&, - urls::url_view) + url_view) {}; //[snippet_decoding_4a auto match = []( std::vector const& route, - urls::url_view u) + url_view u) { auto segs = u.segments(); if (route.size() != segs.size()) @@ -183,7 +183,7 @@ using_url_views() #endif { //[snippet_decoding_5a - auto function = [](urls::string_view str) + auto function = [](string_view str) { std::cout << str << "\n"; }; @@ -195,10 +195,10 @@ using_url_views() { //[snippet_allocators_1 - urls::static_pool< 1024 > sp; + static_pool< 1024 > sp; boost::container::basic_string< char, std::char_traits, - urls::static_pool_allocator> + static_pool_allocator> str(sp.allocator()); u.query().assign_to(str); str += "\n"; @@ -209,7 +209,7 @@ using_url_views() { //[snippet_compound_elements_1 - urls::segments_view segs = u.segments(); + segments_view segs = u.segments(); for( auto v : segs ) { std::cout << v << "\n"; @@ -219,7 +219,7 @@ using_url_views() { //[snippet_encoded_compound_elements_1 - urls::segments_view segs = u.segments(); + segments_view segs = u.segments(); for( auto v : segs ) { @@ -230,7 +230,7 @@ using_url_views() { //[snippet_encoded_compound_elements_2 - urls::params_view params = u.params(); + params_view params = u.params(); for( auto v : params ) { @@ -245,14 +245,14 @@ using_url_views() void using_urls() { - urls::string_view s = "https://user:pass@www.example.com:443/path/to/my%2dfile.txt?id=42&name=John%20Doe#page%20anchor"; + string_view s = "https://user:pass@www.example.com:443/path/to/my%2dfile.txt?id=42&name=John%20Doe#page%20anchor"; //[snippet_quicklook_modifying_1 - urls::url u = urls::parse_uri( s ).value(); + url u = parse_uri( s ).value(); //] //[snippet_quicklook_modifying_1b - urls::static_url<1024> su = urls::parse_uri( s ).value(); + static_url<1024> su = parse_uri( s ).value(); //] //[snippet_quicklook_modifying_2 @@ -260,18 +260,18 @@ using_urls() //] //[snippet_quicklook_modifying_3 - u.set_scheme( urls::scheme::https ); // equivalent to u.set_scheme( "https" ); + u.set_scheme( scheme::https ); // equivalent to u.set_scheme( "https" ); //] //[snippet_quicklook_modifying_4 - u.set_host( urls::parse_ipv4_address( "192.168.0.1" ).value() ) + u.set_host( parse_ipv4_address( "192.168.0.1" ).value() ) .set_port( 8080 ) .remove_userinfo(); std::cout << u << "\n"; //] //[snippet_quicklook_modifying_5 - urls::params p = u.params(); + params p = u.params(); p.emplace_at(p.find("name"), "name", "Vinnie Falco"); std::cout << u << "\n"; //] @@ -281,10 +281,10 @@ void parsing_urls() { //[snippet_parsing_url_1 - urls::result< urls::url_view > r = urls::parse_uri( "https://www.example.com/path/to/file.txt" ); + result< url_view > r = parse_uri( "https://www.example.com/path/to/file.txt" ); if( r.has_value() ) // parsing was successful { - urls::url_view u = r.value(); // extract the urls::url_view + url_view u = r.value(); // extract the url_view std::cout << u << "\n"; // format the URL to cout } else @@ -295,12 +295,12 @@ parsing_urls() //[snippet_parsing_url_2 // This will hold our copy - std::shared_ptr sp; + std::shared_ptr sp; { std::string s = "/path/to/file.txt"; // result::value() will throw an exception if an error occurs - urls::url_view u = urls::parse_relative_ref( s ).value(); + url_view u = parse_relative_ref( s ).value(); // create a copy with ownership and string lifetime extension sp = u.persist(); @@ -315,12 +315,12 @@ parsing_urls() { //[snippet_parsing_url_3 // This will hold our mutable copy - urls::url v; + url v; { std::string s = "/path/to/file.txt"; // result::value() will throw an exception if an error occurs - v = urls::parse_relative_ref(s).value(); + v = parse_relative_ref(s).value(); // At this point the string goes out of scope } @@ -341,15 +341,15 @@ parsing_scheme() { { //[snippet_parsing_scheme_1 - urls::string_view s = "mailto:name@email.com"; - urls::url_view u = urls::parse_uri( s ).value(); + string_view s = "mailto:name@email.com"; + url_view u = parse_uri( s ).value(); std::cout << u.scheme() << "\n"; //] } { - urls::string_view s = "mailto:name@email.com"; + string_view s = "mailto:name@email.com"; //[snippet_parsing_scheme_2 - urls::url_view u = urls::parse_uri( s ).value(); + url_view u = parse_uri( s ).value(); if (u.has_scheme()) { std::cout << u.scheme() << "\n"; @@ -358,9 +358,9 @@ parsing_scheme() } { //[snippet_parsing_scheme_3 - urls::string_view s = "file://host/path/to/file"; - urls::url_view u = urls::parse_uri( s ).value(); - if (u.scheme_id() == urls::scheme::file) + string_view s = "file://host/path/to/file"; + url_view u = parse_uri( s ).value(); + if (u.scheme_id() == scheme::file) { // handle file } @@ -373,8 +373,8 @@ parsing_authority() { { //[snippet_parsing_authority_1 - urls::string_view s = "https:///path/to_resource"; - urls::url_view u = urls::parse_uri( s ).value(); + string_view s = "https:///path/to_resource"; + url_view u = parse_uri( s ).value(); std::cout << u << "\n" "scheme: " << u.scheme() << "\n" "has authority: " << u.has_authority() << "\n" @@ -384,8 +384,8 @@ parsing_authority() } { //[snippet_parsing_authority_2 - urls::string_view s = "https://www.boost.org"; - urls::url_view u = urls::parse_uri( s ).value(); + string_view s = "https://www.boost.org"; + url_view u = parse_uri( s ).value(); std::cout << "scheme: " << u.scheme() << "\n" "has authority: " << u.has_authority() << "\n" "authority: " << u.authority() << "\n" @@ -394,8 +394,8 @@ parsing_authority() } { //[snippet_parsing_authority_3 - urls::string_view s = "https://www.boost.org/users/download/"; - urls::url_view u = urls::parse_uri( s ).value(); + string_view s = "https://www.boost.org/users/download/"; + url_view u = parse_uri( s ).value(); std::cout << u << "\n" "scheme: " << u.scheme() << "\n" "has authority: " << u.has_authority() << "\n" @@ -405,8 +405,8 @@ parsing_authority() } { //[snippet_parsing_authority_4 - urls::string_view s = "https://www.boost.org/"; - urls::url_view u = urls::parse_uri( s ).value(); + string_view s = "https://www.boost.org/"; + url_view u = parse_uri( s ).value(); std::cout << "scheme: " << u.scheme() << "\n" "has authority: " << u.has_authority() << "\n" "authority: " << u.authority() << "\n" @@ -415,8 +415,8 @@ parsing_authority() } { //[snippet_parsing_authority_5 - urls::string_view s = "mailto:John.Doe@example.com"; - urls::url_view u = urls::parse_uri( s ).value(); + string_view s = "mailto:John.Doe@example.com"; + url_view u = parse_uri( s ).value(); std::cout << "scheme: " << u.scheme() << "\n" "has authority: " << u.has_authority() << "\n" "authority: " << u.authority() << "\n" @@ -425,8 +425,8 @@ parsing_authority() } { //[snippet_parsing_authority_6 - urls::string_view s = "mailto://John.Doe@example.com"; - urls::url_view u = urls::parse_uri( s ).value(); + string_view s = "mailto://John.Doe@example.com"; + url_view u = parse_uri( s ).value(); std::cout << u << "\n" "scheme: " << u.scheme() << "\n" "has authority: " << u.has_authority() << "\n" @@ -436,8 +436,8 @@ parsing_authority() } { //[snippet_parsing_authority_7 - urls::string_view s = "https://john.doe@www.example.com:123/forum/questions/"; - urls::url_view u = urls::parse_uri( s ).value(); + string_view s = "https://john.doe@www.example.com:123/forum/questions/"; + url_view u = parse_uri( s ).value(); std::cout << "scheme: " << u.scheme() << "\n" "has authority: " << u.has_authority() << "\n" "authority: " << u.authority() << "\n" @@ -449,8 +449,8 @@ parsing_authority() } { //[snippet_parsing_authority_8 - urls::string_view s = "https://john.doe@www.example.com:123/forum/questions/"; - urls::url_view u = urls::parse_uri( s ).value(); + string_view s = "https://john.doe@www.example.com:123/forum/questions/"; + url_view u = parse_uri( s ).value(); std::cout << u << "\n" "host: " << u.host() << "\n" "host and port: " << u.encoded_host_and_port() << "\n" @@ -460,8 +460,8 @@ parsing_authority() } { //[snippet_parsing_authority_9 - urls::string_view s = "https://john.doe@192.168.2.1:123/forum/questions/"; - urls::url_view u = urls::parse_uri( s ).value(); + string_view s = "https://john.doe@192.168.2.1:123/forum/questions/"; + url_view u = parse_uri( s ).value(); std::cout << u << "\n" "host: " << u.host() << "\n" "host and port: " << u.encoded_host_and_port() << "\n" @@ -471,18 +471,18 @@ parsing_authority() } { //[snippet_parsing_authority_10 - urls::string_view s = "https://www.boost.org/users/download/"; - urls::url_view u = urls::parse_uri( s ).value(); + string_view s = "https://www.boost.org/users/download/"; + url_view u = parse_uri( s ).value(); switch (u.host_type()) { - case urls::host_type::name: + case host_type::name: // resolve name - case urls::host_type::ipv4: - case urls::host_type::ipv6: - case urls::host_type::ipvfuture: + case host_type::ipv4: + case host_type::ipv6: + case host_type::ipvfuture: // connect to ip break; - case urls::host_type::none: + case host_type::none: // handle empty host URL break; } @@ -490,8 +490,8 @@ parsing_authority() } { //[snippet_parsing_authority_11 - urls::string_view s = "https://john.doe:123456@www.somehost.com/forum/questions/"; - urls::url_view u = urls::parse_uri( s ).value(); + string_view s = "https://john.doe:123456@www.somehost.com/forum/questions/"; + url_view u = parse_uri( s ).value(); std::cout << u << "\n\n" "has_userinfo: " << u.has_userinfo() << "\n" "userinfo: " << u.userinfo() << "\n" @@ -503,8 +503,8 @@ parsing_authority() { std::cout << "snippet_parsing_authority_12\n"; //[snippet_parsing_authority_12 - urls::string_view s = "www.example.com:80"; - urls::authority_view a = urls::parse_authority( s ).value(); + string_view s = "www.example.com:80"; + authority_view a = parse_authority( s ).value(); std::cout << a << "\n\n" // host and port "host_and_port: " << a.encoded_host_and_port() << "\n" @@ -523,8 +523,8 @@ parsing_authority() } { //[snippet_parsing_authority_13 - urls::string_view s = "user:pass@www.example.com:443"; - urls::authority_view a = urls::parse_authority( s ).value(); + string_view s = "user:pass@www.example.com:443"; + authority_view a = parse_authority( s ).value(); std::cout << a << "\n\n" // host and port "host_and_port: " << a.encoded_host_and_port() << "\n" @@ -548,8 +548,8 @@ parsing_path() { { //[snippet_parsing_path_1 - urls::string_view s = "https://www.boost.org/doc/libs/"; - urls::url_view u = urls::parse_uri(s).value(); + string_view s = "https://www.boost.org/doc/libs/"; + url_view u = parse_uri(s).value(); std::cout << u << "\n" << "path: " << u.path() << "\n" << "path: " << u.encoded_path() << "\n" @@ -568,8 +568,8 @@ parsing_path() { //[snippet_parsing_path_2 - urls::string_view s = "https://www.boost.org/doc/libs"; - urls::url_view u = urls::parse_uri(s).value(); + string_view s = "https://www.boost.org/doc/libs"; + url_view u = parse_uri(s).value(); std::cout << u.segments().size() << " segments\n"; for (auto seg: u.segments()) { @@ -580,8 +580,8 @@ parsing_path() { //[snippet_parsing_path_3 - urls::string_view s = "https://www.boost.org"; - urls::url_view u = urls::parse_uri(s).value(); + string_view s = "https://www.boost.org"; + url_view u = parse_uri(s).value(); std::cout << u << "\n" << "path: " << u.encoded_path() << "\n"; //] @@ -589,8 +589,8 @@ parsing_path() { //[snippet_parsing_path_4 - urls::string_view s = "https://www.boost.org//doc///libs"; - urls::url_view u = urls::parse_uri(s).value(); + string_view s = "https://www.boost.org//doc///libs"; + url_view u = parse_uri(s).value(); std::cout << u << "\n" "path: " << u.encoded_path() << "\n" "encoded segments: " << u.encoded_segments() << "\n" @@ -606,8 +606,8 @@ parsing_path() { { //[snippet_parsing_path_5_a - urls::string_view s = "https://www.boost.org"; - urls::url_view u = urls::parse_uri(s).value(); + string_view s = "https://www.boost.org"; + url_view u = parse_uri(s).value(); std::cout << u << "\n" << "path: " << u.encoded_host() << "\n" << "path: " << u.encoded_path() << "\n" @@ -616,8 +616,8 @@ parsing_path() } { //[snippet_parsing_path_5_b - urls::string_view s = "https://www.boost.org/"; - urls::url_view u = urls::parse_uri(s).value(); + string_view s = "https://www.boost.org/"; + url_view u = parse_uri(s).value(); std::cout << u << "\n" << "host: " << u.encoded_host() << "\n" << "path: " << u.encoded_path() << "\n" @@ -626,8 +626,8 @@ parsing_path() } { //[snippet_parsing_path_5_c - urls::string_view s = "https://www.boost.org//"; - urls::url_view u = urls::parse_uri(s).value(); + string_view s = "https://www.boost.org//"; + url_view u = parse_uri(s).value(); std::cout << u << "\n" << "host: " << u.encoded_host() << "\n" << "path: " << u.encoded_path() << "\n" @@ -638,8 +638,8 @@ parsing_path() { //[snippet_parsing_path_6 - urls::string_view s = "https://www.boost.org//doc/libs/"; - urls::url_view u = urls::parse_uri(s).value(); + string_view s = "https://www.boost.org//doc/libs/"; + url_view u = parse_uri(s).value(); std::cout << u << "\n" "authority: " << u.encoded_authority() << "\n" "path: " << u.encoded_path() << "\n"; @@ -653,8 +653,8 @@ parsing_path() { //[snippet_parsing_path_7 - urls::string_view s = "https://doc/libs/"; - urls::url_view u = urls::parse_uri(s).value(); + string_view s = "https://doc/libs/"; + url_view u = parse_uri(s).value(); std::cout << u << "\n" "authority: " << u.encoded_authority() << "\n" "path: " << u.encoded_path() << "\n"; @@ -668,8 +668,8 @@ parsing_path() { //[snippet_parsing_path_8 - urls::string_view s = "https://www.boost.org/doc@folder/libs:boost"; - urls::url_view u = urls::parse_uri(s).value(); + string_view s = "https://www.boost.org/doc@folder/libs:boost"; + url_view u = parse_uri(s).value(); std::cout << u << "\n" "authority: " << u.encoded_authority() << "\n" "path: " << u.encoded_path() << "\n"; @@ -683,8 +683,8 @@ parsing_path() { //[snippet_parsing_path_9 - urls::string_view s = "/doc/libs"; - urls::segments_view p = urls::parse_path(s).value(); + string_view s = "/doc/libs"; + segments_view p = parse_path(s).value(); std::cout << "path: " << p << "\n"; std::cout << p.size() << " segments\n"; for (auto seg: p) @@ -700,8 +700,8 @@ parsing_query() { { //[snippet_parsing_query_1 - urls::string_view s = "https://www.example.com/get-customer.php?id=409&name=Joe&individual"; - urls::url_view u = urls::parse_uri(s).value(); + string_view s = "https://www.example.com/get-customer.php?id=409&name=Joe&individual"; + url_view u = parse_uri(s).value(); std::cout << u << "\n" "has query: " << u.has_query() << "\n" "query: " << u.query() << "\n"; @@ -722,8 +722,8 @@ parsing_query() } { //[snippet_parsing_query_2 - urls::string_view s = "https://www.example.com/get-customer.php?key-1=value-1&key-2=&key-3&&=value-2"; - urls::url_view u = urls::parse_uri(s).value(); + string_view s = "https://www.example.com/get-customer.php?key-1=value-1&key-2=&key-3&&=value-2"; + url_view u = parse_uri(s).value(); std::cout << u << "\n" "has query: " << u.has_query() << "\n" "encoded query: " << u.encoded_query() << "\n" @@ -744,8 +744,8 @@ parsing_query() } { //[snippet_parsing_query_3 - urls::string_view s = "https://www.example.com/get-customer.php?email=joe@email.com&code=a:2@/!"; - urls::url_view u = urls::parse_uri(s).value(); + string_view s = "https://www.example.com/get-customer.php?email=joe@email.com&code=a:2@/!"; + url_view u = parse_uri(s).value(); std::cout << u << "\n" "has query: " << u.has_query() << "\n" "encoded query: " << u.encoded_query() << "\n" @@ -766,16 +766,16 @@ parsing_query() } { //[snippet_parsing_query_4 - urls::string_view s = "https://www.example.com/get-customer.php?name=joe"; - urls::url_view u = urls::parse_uri(s).value(); + string_view s = "https://www.example.com/get-customer.php?name=joe"; + url_view u = parse_uri(s).value(); std::cout << u << "\n" "query: " << u.query() << "\n"; //] } { //[snippet_parsing_query_5 - urls::string_view s = "https://www.example.com/get-customer.php"; - urls::url_view u = urls::parse_uri(s).value(); + string_view s = "https://www.example.com/get-customer.php"; + url_view u = parse_uri(s).value(); std::cout << u << "\n" "has query: " << u.has_query() << "\n" "query: " << u.query() << "\n"; @@ -783,8 +783,8 @@ parsing_query() } { //[snippet_parsing_query_6 - urls::string_view s = "https://www.example.com/get-customer.php?name=John%20Doe"; - urls::url_view u = urls::parse_uri(s).value(); + string_view s = "https://www.example.com/get-customer.php?name=John%20Doe"; + url_view u = parse_uri(s).value(); std::cout << u << "\n" "has query: " << u.has_query() << "\n" "encoded query: " << u.encoded_query() << "\n" @@ -793,8 +793,8 @@ parsing_query() } { //[snippet_parsing_query_7 - urls::string_view s = "https://www.example.com/get-customer.php?name=John%26Doe"; - urls::url_view u = urls::parse_uri(s).value(); + string_view s = "https://www.example.com/get-customer.php?name=John%26Doe"; + url_view u = parse_uri(s).value(); std::cout << u << "\n" "has query: " << u.has_query() << "\n" "encoded query: " << u.encoded_query() << "\n" @@ -808,8 +808,8 @@ parsing_fragment() { { //[snippet_parsing_fragment_1 - urls::string_view s = "https://www.example.com/index.html#section%202"; - urls::url_view u = urls::parse_uri(s).value(); + string_view s = "https://www.example.com/index.html#section%202"; + url_view u = parse_uri(s).value(); std::cout << u << "\n" "has fragment: " << u.has_fragment() << "\n" "fragment: " << u.fragment() << "\n" @@ -818,8 +818,8 @@ parsing_fragment() } { //[snippet_parsing_fragment_2_a - urls::string_view s = "https://www.example.com/index.html#"; - urls::url_view u = urls::parse_uri(s).value(); + string_view s = "https://www.example.com/index.html#"; + url_view u = parse_uri(s).value(); std::cout << u << "\n" "has fragment: " << u.has_fragment() << "\n" "fragment: " << u.fragment() << "\n"; @@ -827,8 +827,8 @@ parsing_fragment() } { //[snippet_parsing_fragment_2_b - urls::string_view s = "https://www.example.com/index.html"; - urls::url_view u = urls::parse_uri(s).value(); + string_view s = "https://www.example.com/index.html"; + url_view u = parse_uri(s).value(); std::cout << u << "\n" "has fragment: " << u.has_fragment() << "\n" "fragment: " << u.fragment() << "\n"; @@ -836,8 +836,8 @@ parsing_fragment() } { //[snippet_parsing_fragment_3 - urls::string_view s = "https://www.example.com/index.html#code%20:a@b?c/d"; - urls::url_view u = urls::parse_uri(s).value(); + string_view s = "https://www.example.com/index.html#code%20:a@b?c/d"; + url_view u = parse_uri(s).value(); std::cout << u << "\n" "has fragment: " << u.has_fragment() << "\n" "fragment: " << u.fragment() << "\n"; @@ -850,9 +850,9 @@ using_modifying() { { //[snippet_modifying_1 - urls::string_view s = "https://www.example.com"; - urls::url_view u = urls::parse_uri(s).value(); - urls::url v(u); + string_view s = "https://www.example.com"; + url_view u = parse_uri(s).value(); + url v(u); //] //[snippet_modifying_2 @@ -891,9 +891,9 @@ grammar_parse() //[snippet_parse_1 // VFALCO we should not show this example /* - urls::string_view s = "http:after_scheme"; + string_view s = "http:after_scheme"; const char* it = s.begin(); - auto rv = urls::grammar::parse(it, s.end(), urls::scheme_rule() ); + auto rv = grammar::parse(it, s.end(), scheme_rule() ); if( ! rv ) { std::cout << "scheme: " << rv->scheme << '\n'; @@ -907,12 +907,12 @@ grammar_parse() //[snippet_parse_2 // VFALCO This needs refactoring /* - urls::string_view s = "?key=value#anchor"; + string_view s = "?key=value#anchor"; const char* it = s.begin(); - urls::error_code ec; - if (urls::grammar::parse(it, s.end(), ec, r1)) + error_code ec; + if (grammar::parse(it, s.end(), ec, r1)) { - auto r2 = urls::grammar::parse( it, s.end(), urls::fragment_part_rule ); + auto r2 = grammar::parse( it, s.end(), fragment_part_rule ); if( r2 ) { std::cout << "query: " << r1.query_part << '\n'; @@ -927,11 +927,11 @@ grammar_parse() //[snippet_parse_3 // VFALCO This needs refactoring /* - urls::string_view s = "?key=value#anchor"; - urls::query_part_rule r1; + string_view s = "?key=value#anchor"; + query_part_rule r1; const char* it = s.begin(); - urls::error_code ec; - auto r2 = urls::grammar::parse( it, s.end(), ec, urls::fragment_part_rule ); + error_code ec; + auto r2 = grammar::parse( it, s.end(), ec, fragment_part_rule ); if( ! ec.failed() ) { std::cout << "query: " << r1.query_part << '\n'; @@ -944,10 +944,10 @@ grammar_parse() { //[snippet_parse_4 /* VFALCO This will be removed - urls::string_view s = "http://www.boost.org"; - urls::uri_rule r; - urls::error_code ec; - if (urls::grammar::parse_string(s, ec, r)) + string_view s = "http://www.boost.org"; + uri_rule r; + error_code ec; + if (grammar::parse_string(s, ec, r)) { std::cout << "scheme: " << r.scheme_part.scheme << '\n'; std::cout << "host: " << r.hier_part.authority.host.host_part << '\n'; @@ -961,15 +961,15 @@ grammar_parse() /* VFALCO This needs rewriting struct lowercase_rule { - urls::string_view str; + string_view str; friend void tag_invoke( - urls::grammar::parse_tag const&, + grammar::parse_tag const&, char const*& it, char const* const end, - urls::error_code& ec, + error_code& ec, lowercase_rule& t) noexcept { ec = {}; @@ -978,7 +978,7 @@ struct lowercase_rule { ++it; } - t.str = urls::string_view(begin, it); + t.str = string_view(begin, it); } }; */ @@ -991,11 +991,11 @@ grammar_customization() //[snippet_customization_2 // VFALCO THIS NEEDS TO BE PORTED /* - urls::string_view s = "http:somelowercase"; - urls::scheme_rule r1; + string_view s = "http:somelowercase"; + scheme_rule r1; lowercase_rule r2; - urls::error_code ec; - if (urls::grammar::parse_string(s, ec, r1, ':', r2)) + error_code ec; + if (grammar::parse_string(s, ec, r1, ':', r2)) { std::cout << "scheme: " << r1.scheme << '\n'; std::cout << "lower: " << r2.str << '\n'; @@ -1034,7 +1034,7 @@ modifying_path() { { //[snippet_modifying_path_1 - urls::url_view u = urls::parse_uri("https://www.boost.org").value(); + url_view u = parse_uri("https://www.boost.org").value(); //] BOOST_TEST_NOT(u.is_path_absolute()); BOOST_TEST_EQ(u.encoded_segments().size(), 0u); @@ -1042,7 +1042,7 @@ modifying_path() { //[snippet_modifying_path_2 - urls::url_view u = urls::parse_uri("https://www.boost.org/").value(); + url_view u = parse_uri("https://www.boost.org/").value(); //] BOOST_TEST(u.is_path_absolute()); BOOST_TEST_EQ(u.encoded_segments().size(), 0u); @@ -1050,7 +1050,7 @@ modifying_path() { //[snippet_modifying_path_3 - urls::url u = urls::parse_uri("https://www.boost.org/./a/../b").value(); + url u = parse_uri("https://www.boost.org/./a/../b").value(); u.normalize(); //] BOOST_TEST(u.is_path_absolute()); @@ -1061,7 +1061,7 @@ modifying_path() { //[snippet_modifying_path_4 // scheme and a relative path - urls::url_view u = urls::parse_uri("https:path/to/file.txt").value(); + url_view u = parse_uri("https:path/to/file.txt").value(); //] BOOST_TEST_EQ(u.scheme(), "https"); BOOST_TEST_NOT(u.has_authority()); @@ -1072,7 +1072,7 @@ modifying_path() { //[snippet_modifying_path_5 // scheme and an absolute path - urls::url_view u = urls::parse_uri("https:/path/to/file.txt").value(); + url_view u = parse_uri("https:/path/to/file.txt").value(); //] BOOST_TEST_EQ(u.scheme(), "https"); BOOST_TEST_NOT(u.has_authority()); @@ -1083,7 +1083,7 @@ modifying_path() { //[snippet_modifying_path_6 // "//path" will be considered the authority component - urls::url_view u = urls::parse_uri("https://path/to/file.txt").value(); + url_view u = parse_uri("https://path/to/file.txt").value(); //] BOOST_TEST_EQ(u.scheme(), "https"); BOOST_TEST(u.has_authority()); @@ -1094,7 +1094,7 @@ modifying_path() { //[snippet_modifying_path_7 // only a relative path - urls::url_view u = urls::parse_uri_reference("path-to/file.txt").value(); + url_view u = parse_uri_reference("path-to/file.txt").value(); //] BOOST_TEST_NOT(u.has_scheme()); BOOST_TEST_NOT(u.has_authority()); @@ -1106,7 +1106,7 @@ modifying_path() //[snippet_modifying_path_8 // "path:" will be considered the scheme component // instead of a substring of the first segment - urls::url_view u = urls::parse_uri_reference("path:to/file.txt").value(); + url_view u = parse_uri_reference("path:to/file.txt").value(); //] BOOST_TEST(u.has_scheme()); BOOST_TEST_NOT(u.has_authority()); @@ -1117,7 +1117,7 @@ modifying_path() { //[snippet_modifying_path_9 // "path" should not become the authority component - urls::url u = urls::parse_uri("https:path/to/file.txt").value(); + url u = parse_uri("https:path/to/file.txt").value(); u.set_encoded_path("//path/to/file.txt"); //] BOOST_TEST_EQ(u.scheme(), "https"); @@ -1129,7 +1129,7 @@ modifying_path() { //[snippet_modifying_path_10 // "path:to" should not make the scheme become "path:" - urls::url u = urls::parse_uri_reference("path-to/file.txt").value(); + url u = parse_uri_reference("path-to/file.txt").value(); u.set_encoded_path("path:to/file.txt"); //] BOOST_TEST_NOT(u.has_scheme()); @@ -1141,8 +1141,8 @@ modifying_path() { //[snippet_modifying_path_11 // should not insert as "pathto/file.txt" - urls::url u = urls::parse_uri_reference("to/file.txt").value(); - urls::segments segs = u.segments(); + url u = parse_uri_reference("to/file.txt").value(); + segments segs = u.segments(); segs.insert(segs.begin(), "path"); //] BOOST_TEST_NOT(u.has_scheme()); @@ -1159,13 +1159,13 @@ using_static_pool() //[snippet_using_static_pool_1 using pool_string = boost::container::basic_string< char, std::char_traits, - urls::static_pool_allocator>; - urls::static_pool<4096> pool; + static_pool_allocator>; + static_pool<4096> pool; pool_string k(pool.allocator()); pool_string v(pool.allocator()); - urls::url_view u = urls::parse_uri_reference( + url_view u = parse_uri_reference( "?k0=0&k1=1&k2=&k3&k4=4444#f").value(); - urls::params_view params = u.params(); + params_view params = u.params(); for (auto p: params) { p.key.assign_to(k); p.key.assign_to(v);