boost::urls::url_view :: Boost Libraries Documentation

# boost::urls::url_view

A non‐owning reference to a valid URL

## Synopsis

Declared in `<boost/url/url_view.hpp>`

    class url_view
        : public url_view_base;

## Base Classes

Name | Description
`url_view_base` | Common functionality for containers

## Member Functions

Name | Description
`url_view` [constructor] | Constructor
`~url_view` [destructor] | Destructor
`operator=` | Assignment
`authority` | Return the authority
`buffer` | Return the url string
`compare` | Return the result of comparing this with another url
`data` | Return a pointer to the url's character buffer
`empty` | Return true if the url is empty
`encoded_authority` | Return the authority.
`encoded_fragment` | Return the fragment
`encoded_host` | Return the host
`encoded_host_address` | Return the host
`encoded_host_and_port` | Return the host and port
`encoded_host_name` | Return the host name
`encoded_origin` | Return the origin
`encoded_params` | Return the query as a container of parameters
`encoded_password` | Return the password
`encoded_path` | Return the path
`encoded_query` | Return the query
`encoded_resource` | Return the resource
`encoded_segments` | Return the path as a container of segments
`encoded_target` | Return the target
`encoded_user` | Return the user
`encoded_userinfo` | Return the userinfo
`encoded_zone_id` | Return the IPv6 Zone ID
`fragment` | Return the fragment
`has_authority` | Return true if an authority is present
`has_fragment` | Return true if a fragment is present
`has_password` | Return true if a password is present
`has_port` | Return true if a port is present
`has_query` | Return true if a query is present
`has_scheme` | Return true a scheme is present
`has_userinfo` | Return true if a userinfo is present
`host` | Return the host
`host_address` | Return the host
`host_ipv4_address` | Return the host IPv4 address
`host_ipv6_address` | Return the host IPv6 address
`host_ipvfuture` | Return the host IPvFuture address
`host_name` | Return the host name
`host_type` | Return the host type
`is_path_absolute` | Return true if the path is absolute
`params` | Return the query as a container of parameters
`password` | Return the password
`path` | Return the path
`persist` | Return a shared, persistent copy of the url
`port` | Return the port
`port_number` | Return the port
`query` | Return the query
`scheme` | Return the scheme
`scheme_id` | Return the scheme
`segments` | Return the path as a container of segments
`size` | Return the number of characters in the url
`user` | Return the user
`userinfo` | Return the userinfo
`zone_id` | Return the IPv6 Zone ID
`operator core::string_view` | Return the URL as a core::string_view

## Static Member Functions

Name | Description
`max_size` | Return the maximum number of characters possible

## Protected Member Functions

Name | Description
`digest` | Calculate a hash of the url

## Friends

Name | Description
`boost::urls::params_encoded_base` | Common functionality for containers
`boost::urls::params_base` | Common functionality for query parameter containers
`boost::urls::url_view_base` | Common functionality for containers
`std::hash<url_view>` |

## Non-Member Functions

Name | Description
`operator!=` | Return the result of comparing two URLs
`operator<` | Return the result of comparing two URLs
`operator<=` | Return the result of comparing two URLs
`operator==` | Return the result of comparing two URLs
`operator>` | Return the result of comparing two URLs
`operator>=` | Return the result of comparing two URLs
`parse_absolute_uri` | Return a reference to a parsed URL string
`parse_origin_form` | Return a reference to a parsed URL string
`parse_relative_ref` | Return a reference to a parsed URL string
`parse_uri` | Return a reference to a parsed URL string
`parse_uri_reference` | Return a reference to a parsed URL string
`resolve` | Resolve a URL reference against a base URL

## Description

Objects of this type represent valid URL 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 a URI‐reference and throws an exception on error. Upon success, the constructed object points to the passed character buffer; ownership is not transferred.

    url_view u( "https://www.example.com/index.htm?text=none#a1" );

## Example 2

Parsing functions like `parse_uri_reference` return a `boost::system::result` containing either a valid `url_view` upon succcess, otherwise they contain an error. The error can be converted to an exception by the caller if desired:

    system::result< url_view > rv = parse_uri_reference( "https://www.example.com/index.htm?text=none#a1" );

## BNF

    URI-reference = URI / relative-ref

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

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

## Specification

- https://tools.ietf.org/html/rfc3986

## See Also

`parse_absolute_uri`, `parse_origin_form`, `parse_relative_ref`, `parse_uri`, `parse_uri_reference`.

Created with MrDocs