:relfileprefix: ../../
[#boost-urls-authority_view]

= xref:boost.adoc[pass:[boost]]::xref:boost/urls.adoc[pass:[urls]]::authority_view


A non-owning reference to a valid authority


== Synopsis

Declared in header `<https://www.github.com/boostorg/url/blob/develop/include/boost/url/authority_view.hpp#L82[boost/url/authority_view.hpp,window=blank_]>`

[source,cpp,subs="verbatim,macros,-callouts"]
----
class authority_view;
----

==  Member Functions
[cols=2,separator=¦]
|===
¦Name ¦Description
¦xref:boost/urls/authority_view/2constructor.adoc[`authority_view`] [.small]#[constructor]# ¦

Construct from a string.


Constructor

¦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_host`]  ¦

Return the host

¦xref:boost/urls/authority_view/encoded_host_address.adoc[`encoded_host_address`]  ¦

Return the host

¦xref:boost/urls/authority_view/encoded_host_and_port.adoc[`encoded_host_and_port`]  ¦

Return the host and port

¦xref:boost/urls/authority_view/encoded_host_name.adoc[`encoded_host_name`]  ¦

Return the host name

¦xref:boost/urls/authority_view/encoded_password.adoc[`encoded_password`]  ¦

Return the password

¦xref:boost/urls/authority_view/encoded_user.adoc[`encoded_user`]  ¦

Return the user

¦xref:boost/urls/authority_view/encoded_userinfo.adoc[`encoded_userinfo`]  ¦

Return the userinfo

¦xref:boost/urls/authority_view/has_password.adoc[`has_password`]  ¦

Return true if a password is present

¦xref:boost/urls/authority_view/has_port.adoc[`has_port`]  ¦

Return true if a port is present

¦xref:boost/urls/authority_view/has_userinfo.adoc[`has_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_address`]  ¦

Return the host

¦xref:boost/urls/authority_view/host_ipv4_address.adoc[`host_ipv4_address`]  ¦

Return the host IPv4 address

¦xref:boost/urls/authority_view/host_ipv6_address.adoc[`host_ipv6_address`]  ¦

Return the host IPv6 address

¦xref:boost/urls/authority_view/host_ipvfuture.adoc[`host_ipvfuture`]  ¦

Return the host IPvFuture address

¦xref:boost/urls/authority_view/host_name.adoc[`host_name`]  ¦

Return the host name

¦xref:boost/urls/authority_view/host_type.adoc[`host_type`]  ¦

Return the host type

¦xref:boost/urls/authority_view/operator_assign.adoc[`operator=`]  ¦

Assignment

¦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_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

¦xref:boost/urls/authority_view/2destructor.adoc[`~authority_view`] [.small]#[destructor]# ¦

Destructor

|===
==  Friends
[cols=2,separator=¦]
|===
¦Name ¦Description
¦xref:boost/urls/authority_view/08friend-0c.adoc[`operator!=`]  ¦

Return the result of comparing two authorities
The authorities are compared component
by component as if they were first
normalized.

¦xref:boost/urls/authority_view/08friend-076.adoc[`operator<`]  ¦

Return the result of comparing two authorities
The authorities are compared component
by component as if they were first
normalized.

¦xref:boost/urls/authority_view/08friend-0a.adoc[`operator<<`]  ¦

¦xref:boost/urls/authority_view/08friend-007.adoc[`operator<=`]  ¦

Return the result of comparing two authorities
The authorities are compared component
by component as if they were first
normalized.

¦xref:boost/urls/authority_view/08friend-00c.adoc[`operator==`]  ¦

Return the result of comparing two authorities
The authorities are compared component
by component as if they were first
normalized.

¦xref:boost/urls/authority_view/08friend-0d.adoc[`operator>`]  ¦

Return the result of comparing two authorities
The authorities are compared component
by component as if they were first
normalized.

¦xref:boost/urls/authority_view/08friend-072.adoc[`operator>=`]  ¦

Return the result of comparing two authorities
The authorities are compared component
by component as if they were first
normalized.

|===

== Description


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

=== Example 1

Construction from a string parses the input
as an
_authority_
and throws an
exception on error. Upon success, the
constructed object points to the passed
character buffer; ownership is not
transferred.
[,cpp]
----
authority_view a( "user:pass@www.example.com:8080" );
----

=== Example 2

The parsing function
xref:boost/urls/parse_authority.adoc[parse_authority]
returns
a
result
containing either a valid
xref:boost/urls/authority_view/2constructor-0e.adoc[authority_view]
upon succcess, otherwise it
contain an error. The error can be converted to
an exception by the caller if desired:
[,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

* link:https://datatracker.ietf.org/doc/html/rfc3986#section-3.2[3.2. Authority (rfc3986)]



== See Also


xref:boost/urls/parse_authority.adoc[parse_authority]
.



