[#C21DD46D44E85FD6039919A7A5CA0CF44504668F]

Class url_view

A non-owning reference to a valid URL

Synopsis

            class url_view
    : public url_view_base;
        

Member Functions

Friends

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

  • Uniform Resource Identifier (URI): Generic Syntax (rfc3986)