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

#include <hikogui/path/URL.hpp>

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

Public Member Functions

constexpr URL () noexcept=default
 Create an empty URL.
 
constexpr URL (URL const &) noexcept=default
 
constexpr URL (URL &&) noexcept=default
 
constexpr URLoperator= (URL const &) noexcept=default
 
constexpr URLoperator= (URL &&) noexcept=default
 
constexpr URL (URI const &other) noexcept
 Convert a URI to an URL.
 
constexpr URL (URI &&other) noexcept
 Convert a URI to an URL.
 
constexpr URL (std::string_view str)
 Construct a URI from a string.
 
constexpr URL (std::string const &str)
 Construct a URI from a string.
 
constexpr URL (const char *str)
 Construct a URI from a string.
 
 URL (std::filesystem::path const &path)
 Convert a filesystem-path to a file-scheme URL.
 
constexpr std::u8string filesystem_path_generic_u8string (bool validate_scheme=true) const
 Return a generic path.
 
std::filesystem::path filesystem_path () const
 Create a filesystem path from a file URL.
 
 operator std::filesystem::path () const
 
- Public Member Functions inherited from hi::v1::URI
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
 

Friends

constexpr friend URL operator/ (URL const &base, URI const &ref) noexcept
 
constexpr friend URL operator/ (URL const &base, std::string_view ref) noexcept
 

Additional Inherited Members

- Static Public Member Functions inherited from hi::v1::URI
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.
 

Detailed Description

Universal Resource Locator.

An instance internally holds the URI split into its non-encoded components.

syd::filesystem::path constructors will do context aware normalizations.

'file:' scheme urls can handle the following:

The URL instance may be relative itself; meaning it does not hold a scheme.

URLs can be implicitly converted to std::filesystem::path.

Constructor & Destructor Documentation

◆ URL() [1/7]

constexpr hi::v1::URL::URL ( )
constexprdefaultnoexcept

Create an empty URL.

◆ URL() [2/7]

constexpr hi::v1::URL::URL ( URI const & other)
inlineexplicitconstexprnoexcept

Convert a URI to an URL.

◆ URL() [3/7]

constexpr hi::v1::URL::URL ( URI && other)
inlineexplicitconstexprnoexcept

Convert a URI to an URL.

◆ URL() [4/7]

constexpr hi::v1::URL::URL ( 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.

◆ URL() [5/7]

constexpr hi::v1::URL::URL ( 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.

◆ URL() [6/7]

constexpr hi::v1::URL::URL ( 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.

◆ URL() [7/7]

hi::v1::URL::URL ( std::filesystem::path const & path)
inlineexplicit

Convert a filesystem-path to a file-scheme URL.

A relative path is converted to a relative URL. An absolute path is converted to an absolute file-scheme URL.

Parameters
pathThe path to convert to an URL.

Member Function Documentation

◆ filesystem_path()

std::filesystem::path hi::v1::URL::filesystem_path ( ) const
inline

Create a filesystem path from a file URL.

Returns
The filesystem path of a file URL.
Exceptions
url_errorWhen a valid file path can not be constructed from the URL.

◆ filesystem_path_generic_u8string()

constexpr std::u8string hi::v1::URL::filesystem_path_generic_u8string ( bool validate_scheme = true) const
inlineconstexpr

Return a generic path.

Returns
The generic path of a file URL.
Exceptions
url_errorWhen a valid file path can not be constructed from the URL.

◆ operator std::filesystem::path()

hi::v1::URL::operator std::filesystem::path ( ) const
inline

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