Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion doc/modules/ROOT/pages/quicklook.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -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());
----

Expand Down Expand Up @@ -313,7 +315,7 @@ Output::
----
path
to
my-file.txt
my%2dfile.txt
----
--
====
Expand Down
18 changes: 12 additions & 6 deletions doc/modules/ROOT/pages/urls/parsing.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -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[]
Expand All @@ -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.
Expand Down
Loading