:relfileprefix: ../../
[#C21DD46D44E85FD6039919A7A5CA0CF44504668F]

= Class url_view

pass:v,q[A non-owning reference to a valid URL]


== Synopsis

Declared in header `</boost/url/url_view.hpp#L74[boost/url/url_view.hpp,window=blank_]>`

[source,cpp,subs="verbatim,macros,-callouts"]
----
class url_view
    : public xref:boost/urls/url_view_base.adoc[url_view_base];
----

==  Member Functions
[,cols=2]
|===
|Name |Description
|xref:boost/urls/url_view_base/authority.adoc[`pass:v[authority]`] |
pass:v,q[Return the authority]

|xref:boost/urls/url_view_base/buffer.adoc[`pass:v[buffer]`] |
pass:v,q[Return the url string]

|xref:boost/urls/url_view_base/compare.adoc[`pass:v[compare]`] |
pass:v,q[Return the result of comparing this with another url]

|xref:boost/urls/url_view_base/data.adoc[`pass:v[data]`] |
pass:v,q[Return a pointer to the url's character buffer]

|xref:boost/urls/url_view_base/digest.adoc[`pass:v[digest]`] |

|xref:boost/urls/url_view_base/empty.adoc[`pass:v[empty]`] |
pass:v,q[Return true if the url is empty]

|xref:boost/urls/url_view_base/encoded_authority.adoc[`pass:v[encoded_authority]`] |
pass:v,q[Return the authority.]

|xref:boost/urls/url_view_base/encoded_fragment.adoc[`pass:v[encoded_fragment]`] |
pass:v,q[Return the fragment]

|xref:boost/urls/url_view_base/encoded_host.adoc[`pass:v[encoded_host]`] |
pass:v,q[Return the host]

|xref:boost/urls/url_view_base/encoded_host_address.adoc[`pass:v[encoded_host_address]`] |
pass:v,q[Return the host]

|xref:boost/urls/url_view_base/encoded_host_and_port.adoc[`pass:v[encoded_host_and_port]`] |
pass:v,q[Return the host and port]

|xref:boost/urls/url_view_base/encoded_host_name.adoc[`pass:v[encoded_host_name]`] |
pass:v,q[Return the host name]

|xref:boost/urls/url_view_base/encoded_origin.adoc[`pass:v[encoded_origin]`] |
pass:v,q[Return the origin]

|xref:boost/urls/url_view_base/encoded_params.adoc[`pass:v[encoded_params]`] |
pass:v,q[Return the query as a container of parameters]

|xref:boost/urls/url_view_base/encoded_password.adoc[`pass:v[encoded_password]`] |
pass:v,q[Return the password]

|xref:boost/urls/url_view_base/encoded_path.adoc[`pass:v[encoded_path]`] |
pass:v,q[Return the path]

|xref:boost/urls/url_view_base/encoded_query.adoc[`pass:v[encoded_query]`] |
pass:v,q[Return the query]

|xref:boost/urls/url_view_base/encoded_resource.adoc[`pass:v[encoded_resource]`] |
pass:v,q[Return the resource]

|xref:boost/urls/url_view_base/encoded_segments.adoc[`pass:v[encoded_segments]`] |
pass:v,q[Return the path as a container of segments]

|xref:boost/urls/url_view_base/encoded_target.adoc[`pass:v[encoded_target]`] |
pass:v,q[Return the target]

|xref:boost/urls/url_view_base/encoded_user.adoc[`pass:v[encoded_user]`] |
pass:v,q[Return the user]

|xref:boost/urls/url_view_base/encoded_userinfo.adoc[`pass:v[encoded_userinfo]`] |
pass:v,q[Return the userinfo]

|xref:boost/urls/url_view_base/encoded_zone_id.adoc[`pass:v[encoded_zone_id]`] |
pass:v,q[Return the IPv6 Zone ID]

|xref:boost/urls/url_view_base/fragment.adoc[`pass:v[fragment]`] |
pass:v,q[Return the fragment]

|xref:boost/urls/url_view_base/has_authority.adoc[`pass:v[has_authority]`] |
pass:v,q[Return true if an authority is present]

|xref:boost/urls/url_view_base/has_fragment.adoc[`pass:v[has_fragment]`] |
pass:v,q[Return true if a fragment is present]

|xref:boost/urls/url_view_base/has_password.adoc[`pass:v[has_password]`] |
pass:v,q[Return true if a password is present]

|xref:boost/urls/url_view_base/has_port.adoc[`pass:v[has_port]`] |
pass:v,q[Return true if a port is present]

|xref:boost/urls/url_view_base/has_query.adoc[`pass:v[has_query]`] |
pass:v,q[Return true if a query is present]

|xref:boost/urls/url_view_base/has_scheme.adoc[`pass:v[has_scheme]`] |
pass:v,q[Return true a scheme is present]

|xref:boost/urls/url_view_base/has_userinfo.adoc[`pass:v[has_userinfo]`] |
pass:v,q[Return true if a userinfo is present]

|xref:boost/urls/url_view_base/host.adoc[`pass:v[host]`] |
pass:v,q[Return the host]

|xref:boost/urls/url_view_base/host_address.adoc[`pass:v[host_address]`] |
pass:v,q[Return the host]

|xref:boost/urls/url_view_base/host_ipv4_address.adoc[`pass:v[host_ipv4_address]`] |
pass:v,q[Return the host IPv4 address]

|xref:boost/urls/url_view_base/host_ipv6_address.adoc[`pass:v[host_ipv6_address]`] |
pass:v,q[Return the host IPv6 address]

|xref:boost/urls/url_view_base/host_ipvfuture.adoc[`pass:v[host_ipvfuture]`] |
pass:v,q[Return the host IPvFuture address]

|xref:boost/urls/url_view_base/host_name.adoc[`pass:v[host_name]`] |
pass:v,q[Return the host name]

|xref:boost/urls/url_view_base/host_type.adoc[`pass:v[host_type]`] |
pass:v,q[Return the host type]

|xref:boost/urls/url_view_base/is_path_absolute.adoc[`pass:v[is_path_absolute]`] |
pass:v,q[Return true if the path is absolute]

|xref:boost/urls/url_view_base/2conversion.adoc[`pass:v[operator string_view]`] |
pass:v,q[Return the URL as a core::string_view]

|xref:boost/urls/url_view/operator_assign.adoc[`pass:v[operator=]`] |
pass:v,q[Assignment]

|xref:boost/urls/url_view_base/params.adoc[`pass:v[params]`] |
pass:v,q[Return the query as a container of parameters]

|xref:boost/urls/url_view_base/password.adoc[`pass:v[password]`] |
pass:v,q[Return the password]

|xref:boost/urls/url_view_base/path.adoc[`pass:v[path]`] |
pass:v,q[Return the path]

|xref:boost/urls/url_view_base/persist.adoc[`pass:v[persist]`] |
pass:v,q[Return a shared, persistent copy of the url]

|xref:boost/urls/url_view_base/port.adoc[`pass:v[port]`] |
pass:v,q[Return the port]

|xref:boost/urls/url_view_base/port_number.adoc[`pass:v[port_number]`] |
pass:v,q[Return the port]

|xref:boost/urls/url_view_base/query.adoc[`pass:v[query]`] |
pass:v,q[Return the query]

|xref:boost/urls/url_view_base/scheme.adoc[`pass:v[scheme]`] |
pass:v,q[Return the scheme]

|xref:boost/urls/url_view_base/scheme_id.adoc[`pass:v[scheme_id]`] |
pass:v,q[Return the scheme]

|xref:boost/urls/url_view_base/segments.adoc[`pass:v[segments]`] |
pass:v,q[Return the path as a container of segments]

|xref:boost/urls/url_view_base/size.adoc[`pass:v[size]`] |
pass:v,q[Return the number of characters in the url]

|xref:boost/urls/url_view/2constructor.adoc[`pass:v[url_view]`] |
pass:v,q[Constructor]

|xref:boost/urls/url_view_base/user.adoc[`pass:v[user]`] |
pass:v,q[Return the user]

|xref:boost/urls/url_view_base/userinfo.adoc[`pass:v[userinfo]`] |
pass:v,q[Return the userinfo]

|xref:boost/urls/url_view_base/zone_id.adoc[`pass:v[zone_id]`] |
pass:v,q[Return the IPv6 Zone ID]

|xref:boost/urls/url_view/2destructor.adoc[`pass:v[~url_view]`] |
pass:v,q[Destructor]

|===
==  Static Member Functions
[,cols=2]
|===
|Name |Description
|xref:boost/urls/url_view_base/max_size.adoc[`pass:v[max_size]`] |
pass:v,q[Return the maximum number of characters possible]

|===
==  Friends
[,cols=2]
|===
|Name |Description
|xref:boost/urls/url_view_base/8friend-02.adoc[`pass:v[operator!=]`] |
pass:v,q[Return the result of comparing two URLs]

|xref:boost/urls/url_view_base/8friend-05.adoc[`pass:v[operator<]`] |
pass:v,q[Return the result of comparing two URLs]

|xref:boost/urls/url_view_base/8friend-03.adoc[`pass:v[operator<<]`] |

|xref:boost/urls/url_view_base/8friend-04.adoc[`pass:v[operator<=]`] |
pass:v,q[Return the result of comparing two URLs]

|xref:boost/urls/url_view_base/8friend-07c.adoc[`pass:v[operator==]`] |
pass:v,q[Return the result of comparing two URLs]

|xref:boost/urls/url_view_base/8friend-073.adoc[`pass:v[operator>]`] |
pass:v,q[Return the result of comparing two URLs]

|xref:boost/urls/url_view_base/8friend-06.adoc[`pass:v[operator>=]`] |
pass:v,q[Return the result of comparing two URLs]

|===

== Description

pass:v,q[Objects of this type represent valid URL] pass:v,q[strings constructed from a parsed, external]
pass:v,q[character buffer whose storage is managed]
pass:v,q[by the caller. That is, it acts like a]
pass:v,q[`core::string_view` in terms of ownership.]
pass:v,q[The caller is responsible for ensuring]
pass:v,q[that the lifetime of the underlying]
pass:v,q[character buffer extends until it is no]
pass:v,q[longer referenced.]

=== Example 1
pass:v,q[Construction from a string parses the input]
pass:v,q[as a]
pass:v,q[URI-reference]
pass:v,q[and throws an]
pass:v,q[exception on error. Upon success, the]
pass:v,q[constructed object points to the passed]
pass:v,q[character buffer; ownership is not]
pass:v,q[transferred.]
[,cpp]
----
url_view u( "https://www.example.com/index.htm?text=none#a1" );
----

=== Example 2
pass:v,q[Parsing functions like]
xref:boost/urls/parse_uri_reference.adoc[parse_uri_reference]
pass:v,q[return a]
pass:v,q[result]
pass:v,q[containing either a valid]
xref:boost/urls/url_view/2constructor-0c.adoc[url_view]
pass:v,q[upon succcess, otherwise they]
pass:v,q[contain an error. The error can be converted to]
pass:v,q[an exception by the caller if desired:]
[,cpp]
----
system::result< url_view > rv = parse_uri_reference( "https://www.example.com/index.htm?text=none#a1" );
----

=== BNF
[,cpp]
----
URI-reference = URI / relative-ref

URI           = scheme ":" hier-part [ "?" query ] [ "#" fragment ]

relative-ref  = relative-part [ "?" query ] [ "#" fragment ]
----

=== Specification

* link:https://tools.ietf.org/html/rfc3986[Uniform Resource Identifier (URI): Generic Syntax (rfc3986)]



