HikoGUI
A low latency retained GUI
Loading...
Searching...
No Matches
Data Structures | Public Member Functions | Static Public Member Functions | Friends
hi::v1::URI Class Reference

#include <hikogui/path/URI.hpp>

Inheritance diagram for hi::v1::URI:
hi::v1::URL

Data Structures

class  authority_type
 
class  path_type
 A path type. More...
 

Public Member Functions

constexpr URI (URI const &) noexcept=default
 
constexpr URI (URI &&) noexcept=default
 
constexpr URIoperator= (URI const &) noexcept=default
 
constexpr URIoperator= (URI &&) noexcept=default
 
constexpr URI (std::string_view str)
 Construct a URI from a string.
 
constexpr URI (std::string const &str)
 Construct a URI from a string.
 
constexpr URI (const char *str)
 Construct a URI from a string.
 
constexpr bool empty () const noexcept
 
constexpr operator bool () const noexcept
 
constexpr std::optional< std::string > const & scheme () const noexcept
 Get the scheme-component of the URI.
 
constexpr URIset_scheme (std::optional< std::string > const &rhs)
 Get the scheme-component of the URI.
 
constexpr std::optional< authority_type > const & authority () const noexcept
 Get the authority-component of the URI.
 
constexpr URIset_authority (std::optional< authority_type > const &rhs) noexcept
 
constexpr path_type const & path () const noexcept
 
constexpr URIset_path (path_type const &rhs)
 
constexpr std::optional< std::stringfilename () const noexcept
 
constexpr URIremove_filename () noexcept
 Remove the filename part of the path.
 
constexpr std::optional< std::string > const & query () const noexcept
 Get the query-component of the URI.
 
constexpr URIset_query (std::optional< std::string > const &rhs) noexcept
 
constexpr std::optional< std::string > const & fragment () const noexcept
 Get the fragment-component of the URI.
 
constexpr URIset_fragment (std::optional< std::string > const &rhs) noexcept
 

Static Public Member Functions

static constexpr std::string decode (std::string_view rhs)
 URI percent-encoding decode function.
 
static constexpr std::string decode (const_iterator first, const_iterator last)
 URI percent-encoding decode function.
 
template<char... Extras, typename It , typename ItEnd >
static constexpr std::string encode (It first, ItEnd last) noexcept
 URI encode a component.
 
template<char... Extras, typename Range >
static constexpr std::string encode (Range &&range) noexcept
 URI encode a component.
 

Friends

struct std::hash< URI >
 
constexpr friend std::string to_string (URI const &rhs) noexcept
 
std::ostreamoperator<< (std::ostream &lhs, URI const &rhs) noexcept
 
constexpr friend bool operator== (URI const &lhs, URI const &rhs) noexcept=default
 
constexpr friend auto operator<=> (URI const &lhs, URI const &rhs) noexcept=default
 
constexpr friend URI operator/ (URI const &base, URI const &ref) noexcept
 
constexpr friend bool operator== (URI const &lhs, std::string_view rhs) noexcept
 
constexpr friend auto operator<=> (URI const &lhs, std::string_view rhs) noexcept
 
constexpr friend URI operator/ (URI const &base, std::string_view ref) noexcept
 
constexpr friend size_t to_string_size (URI const &rhs) noexcept
 

Detailed Description

A Uniform Resource Identifier.

This class holds the URI separated and unencoded into it components:

Constructor & Destructor Documentation

◆ URI() [1/3]

constexpr hi::v1::URI::URI ( std::string_view str)
inlineexplicitconstexpr

Construct a URI from a string.

Note
This constructor will normalize the URI
Parameters
strA URI encoded as a string.
Exceptions
uri_errorWhen the URI can not be normalized due to a parse error.

◆ URI() [2/3]

constexpr hi::v1::URI::URI ( std::string const & str)
inlineexplicitconstexpr

Construct a URI from a string.

Note
This constructor will normalize the URI
Parameters
strA URI encoded as a string.
Exceptions
uri_errorWhen the URI can not be normalized due to a parse error.

◆ URI() [3/3]

constexpr hi::v1::URI::URI ( const char * str)
inlineexplicitconstexpr

Construct a URI from a string.

Note
This constructor will normalize the URI
Parameters
strA URI encoded as a string.
Exceptions
uri_errorWhen the URI can not be normalized due to a parse error.

Member Function Documentation

◆ authority()

constexpr std::optional< authority_type > const & hi::v1::URI::authority ( ) const
inlineconstexprnoexcept

Get the authority-component of the URI.

Returns
The optional and decoded userinfo, host and port..

◆ decode() [1/2]

static constexpr std::string hi::v1::URI::decode ( const_iterator first,
const_iterator last )
inlinestaticconstexpr

URI percent-encoding decode function.

Parameters
firstAn iterator to the first character of a percent encoded string.
lastAn iterator to one beyond the last character of a percent encoded string.
Returns
A UTF-8 encoded string.

◆ decode() [2/2]

static constexpr std::string hi::v1::URI::decode ( std::string_view rhs)
inlinestaticconstexpr

URI percent-encoding decode function.

Parameters
rhsA percent-encoded string.
Returns
A UTF-8 encoded string.

◆ encode() [1/2]

template<char... Extras, typename It , typename ItEnd >
static constexpr std::string hi::v1::URI::encode ( It first,
ItEnd last )
inlinestaticconstexprnoexcept

URI encode a component.

Template Parameters
ExtrasThe extra characters beyond the unreserved characters to pct-encode.
Parameters
firstIterator to a UTF-8 encoded string; a component or sub-component of a URI.
lastIterator pointing one beyond the UTF-8 encoded string.
Returns
A percent-encoded string.

◆ encode() [2/2]

template<char... Extras, typename Range >
static constexpr std::string hi::v1::URI::encode ( Range && range)
inlinestaticconstexprnoexcept

URI encode a component.

Template Parameters
ExtrasThe extra characters beyond the unreserved characters to pct-encode.
Parameters
rangeA range representing UTF-8 encoded string; a component or sub-component of a URI.
Returns
A percent-encoded string.

◆ fragment()

constexpr std::optional< std::string > const & hi::v1::URI::fragment ( ) const
inlineconstexprnoexcept

Get the fragment-component of the URI.

Returns
The optional and decoded fragment-component.

◆ query()

constexpr std::optional< std::string > const & hi::v1::URI::query ( ) const
inlineconstexprnoexcept

Get the query-component of the URI.

Returns
The optional and decoded query-component.

◆ remove_filename()

constexpr URI & hi::v1::URI::remove_filename ( )
inlineconstexprnoexcept

Remove the filename part of the path.

Note
No change when the path does not contain a filename.
Returns
A reference to this.

◆ scheme()

constexpr std::optional< std::string > const & hi::v1::URI::scheme ( ) const
inlineconstexprnoexcept

Get the scheme-component of the URI.

Returns
The optional and lower-cased scheme-component.

◆ set_scheme()

constexpr URI & hi::v1::URI::set_scheme ( std::optional< std::string > const & rhs)
inlineconstexpr

Get the scheme-component of the URI.


The documentation for this class was generated from the following file: