[#boost-urls-authority_view]
= xref:boost.adoc[boost]::xref:boost/urls.adoc[urls]::authority&lowbar;view
:relfileprefix: ../../
:mrdocs:

A non&hyphen;owning reference to a valid authority

== Synopsis

Declared in `&lt;https://www.github.com/boostorg/url/blob/develop/include/boost/url/authority_view.hpp#L82[boost&sol;url&sol;authority&lowbar;view&period;hpp]&gt;`

[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
class authority&lowbar;view;
----

== Member Functions

[cols="1,4"]
|===
| Name| Description
| xref:boost/urls/authority_view/2constructor-05.adoc[`authority&lowbar;view`]         [.small]#[constructor]#
| Constructors
| xref:boost/urls/authority_view/2destructor.adoc[`&#126;authority&lowbar;view`] [.small]#[destructor]# [.small]#[virtual]#
| Destructor
| xref:boost/urls/authority_view/operator_assign.adoc[`operator&equals;`] 
| Assignment
| xref:boost/urls/authority_view/buffer.adoc[`buffer`] 
| Return the complete authority
| xref:boost/urls/authority_view/compare.adoc[`compare`] 
| Return the result of comparing this with another authority
| xref:boost/urls/authority_view/data.adoc[`data`] 
| Return a pointer to the first character
| xref:boost/urls/authority_view/empty.adoc[`empty`] 
| Return true if the authority is empty
| xref:boost/urls/authority_view/encoded_host.adoc[`encoded&lowbar;host`] 
| Return the host
| xref:boost/urls/authority_view/encoded_host_address.adoc[`encoded&lowbar;host&lowbar;address`] 
| Return the host
| xref:boost/urls/authority_view/encoded_host_and_port.adoc[`encoded&lowbar;host&lowbar;and&lowbar;port`] 
| Return the host and port
| xref:boost/urls/authority_view/encoded_host_name.adoc[`encoded&lowbar;host&lowbar;name`] 
| Return the host name
| xref:boost/urls/authority_view/encoded_password.adoc[`encoded&lowbar;password`] 
| Return the password
| xref:boost/urls/authority_view/encoded_user.adoc[`encoded&lowbar;user`] 
| Return the user
| xref:boost/urls/authority_view/encoded_userinfo.adoc[`encoded&lowbar;userinfo`] 
| Return the userinfo
| xref:boost/urls/authority_view/has_password.adoc[`has&lowbar;password`] 
| Return true if a password is present
| xref:boost/urls/authority_view/has_port.adoc[`has&lowbar;port`] 
| Return true if a port is present
| xref:boost/urls/authority_view/has_userinfo.adoc[`has&lowbar;userinfo`] 
| Return true if a userinfo is present
| xref:boost/urls/authority_view/host.adoc[`host`] 
| Return the host
| xref:boost/urls/authority_view/host_address.adoc[`host&lowbar;address`] 
| Return the host
| xref:boost/urls/authority_view/host_ipv4_address.adoc[`host&lowbar;ipv4&lowbar;address`] 
| Return the host IPv4 address
| xref:boost/urls/authority_view/host_ipv6_address.adoc[`host&lowbar;ipv6&lowbar;address`] 
| Return the host IPv6 address
| xref:boost/urls/authority_view/host_ipvfuture.adoc[`host&lowbar;ipvfuture`] 
| Return the host IPvFuture address
| xref:boost/urls/authority_view/host_name.adoc[`host&lowbar;name`] 
| Return the host name
| xref:boost/urls/authority_view/host_type.adoc[`host&lowbar;type`] 
| Return the host type
| xref:boost/urls/authority_view/password.adoc[`password`] 
| Return the password
| xref:boost/urls/authority_view/port.adoc[`port`] 
| Return the port
| xref:boost/urls/authority_view/port_number.adoc[`port&lowbar;number`] 
| Return the port
| xref:boost/urls/authority_view/size.adoc[`size`] 
| Return the number of characters in the authority
| xref:boost/urls/authority_view/user.adoc[`user`] 
| Return the user
| xref:boost/urls/authority_view/userinfo.adoc[`userinfo`] 
| Return the userinfo
|===

== Friends

[cols="1,4"]
|===
|Name|Description

| `xref:boost/urls/operator_lshift-0d.adoc[boost::urls::operator&lt;&lt;]`
| Format the encoded authority to the output stream
| `xref:boost/urls/operator_ge-08.adoc[boost::urls::operator&gt;&equals;]`
| Return the result of comparing two authorities&period; The authorities are compared component by component as if they were first normalized&period;
| `xref:boost/urls/operator_gt-08.adoc[boost::urls::operator&gt;]`
| Return the result of comparing two authorities&period; The authorities are compared component by component as if they were first normalized&period;
| `xref:boost/urls/operator_le-01.adoc[boost::urls::operator&lt;&equals;]`
| Return the result of comparing two authorities&period; The authorities are compared component by component as if they were first normalized&period;
| `xref:boost/urls/operator_lt-0a.adoc[boost::urls::operator&lt;]`
| Return the result of comparing two authorities&period; The authorities are compared component by component as if they were first normalized&period;
| `xref:boost/urls/operator_not_eq-03.adoc[boost::urls::operator!&equals;]`
| Return the result of comparing two authorities&period; The authorities are compared component by component as if they were first normalized&period;
| `xref:boost/urls/operator_eq-092.adoc[boost::urls::operator&equals;&equals;]`
| Return the result of comparing two authorities&period; The authorities are compared component by component as if they were first normalized&period;
|===

== Non-Member Functions

[cols="1,4"]
|===
| Name
| Description
| xref:boost/urls/parse_authority.adoc[`parse&lowbar;authority`]
| Parse an authority
|===

== Description

Objects of this type represent valid authority strings constructed from a parsed, external character buffer whose storage is managed by the caller&period; That is, it acts like a `core&colon;&colon;string&lowbar;view` in terms of ownership&period; The caller is responsible for ensuring that the lifetime of the underlying character buffer extends until it is no longer referenced&period;

== Example 1

Construction from a string parses the input as an _authority_ and throws an exception on error&period; Upon success, the constructed object points to the passed character buffer&semi; ownership is not transferred&period;

[,cpp]
----
authority_view a( "user:pass@www.example.com:8080" );
----
== Example 2

The parsing function xref:boost/urls/parse_authority.adoc[`parse&lowbar;authority`] returns a `boost&colon;&colon;system&colon;&colon;result` containing either a valid xref:boost/urls/authority_view/2constructor-05.adoc[`authority&lowbar;view`] upon success, otherwise it contains an error&period; The error can be converted to an exception by the caller if desired&colon;

[,cpp]
----
system::result< authority_view > rv = parse_authority( "user:pass@www.example.com:8080" );
----
== BNF

[,cpp]
----
authority     = [ userinfo "@" ] host [ ":" port ]

userinfo      = user [ ":" [ password ] ]

user          = *( unreserved / pct-encoded / sub-delims )
password      = *( unreserved / pct-encoded / sub-delims / ":" )

host          = IP-literal / IPv4address / reg-name

port          = *DIGIT
----
== Specification

* https://datatracker.ietf.org/doc/html/rfc3986#section-3.2[3&period;2&period; Authority (rfc3986)]

== See Also

xref:boost/urls/parse_authority.adoc[`parse&lowbar;authority`]&period;


[.small]#Created with https://www.mrdocs.com[MrDocs]#
