diff --git a/doc/modules/ROOT/pages/quicklook.adoc b/doc/modules/ROOT/pages/quicklook.adoc index f26cfdb0d..b6f9ab9f8 100644 --- a/doc/modules/ROOT/pages/quicklook.adoc +++ b/doc/modules/ROOT/pages/quicklook.adoc @@ -242,6 +242,8 @@ This is also useful when manipulating URLs: [source,cpp] ---- +url u1 = parse_uri( "http://www.example.com" ).value(); +url_view u2 = parse_uri( "http://other.example.com" ).value(); u1.set_host(u2.host()); ---- @@ -313,7 +315,7 @@ Output:: ---- path to -my-file.txt +my%2dfile.txt ---- -- ==== diff --git a/doc/modules/ROOT/pages/urls/parsing.adoc b/doc/modules/ROOT/pages/urls/parsing.adoc index 9156db874..3c790d3f9 100644 --- a/doc/modules/ROOT/pages/urls/parsing.adoc +++ b/doc/modules/ROOT/pages/urls/parsing.adoc @@ -104,6 +104,8 @@ https://datatracker.ietf.org/doc/html/rfc3986#section-3[__URI__,window=blank_]: [source,cpp] ---- include::example$unit/snippets.cpp[tag=code_urls_parsing_1,indent=0] + +include::example$unit/snippets.cpp[tag=code_urls_parsing_2,indent=0] ---- The function returns a cpp:result[] which holds a cpp:url_view[] @@ -117,15 +119,19 @@ The caller is responsible for ensuring that the lifetime of the character buffer These are the same semantics as that of cpp:std::string_view[]. ==== -For convenience, a URL view can be constructed directly from the character buffer in a cpp:string_view[]. -In this case, it parses the string according to the -https://datatracker.ietf.org/doc/html/rfc3986#section-4.1[__URI-reference__,window=blank_] -grammar, throwing an exception upon failure. -The following two statements are equivalent: +We can immediately call cpp:result::value[] to obtain a cpp:url_view[]: [source,cpp] ---- -include::example$unit/snippets.cpp[tag=code_urls_parsing_2,indent=0] +include::example$unit/snippets.cpp[tag=snippet_parsing_3,indent=0] +---- + +Or, on a result that is known to hold a value, the shorter +cpp:result::operator*[]: + +[source,cpp] +---- +include::example$unit/snippets.cpp[tag=snippet_parsing_4,indent=0] ---- In this library, free functions which parse things are named with the word "parse" followed by the name of the grammar used to match the string.