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

#include <hikogui/URL.hpp>

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

Public Member Functions

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
 
constexpr URL (URI &&other) noexcept
 
 URL (std::filesystem::path const &path)
 
std::string generic_path () const
 Return a generic path.
 
std::filesystem::path filesystem_path () const
 Create a filesystem path from a file URL.
 
 operator std::filesystem::path () const
 
std::unique_ptr< resource_view > loadView () const
 Load a resource.
 
- 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 URL from a string.
 
constexpr URI (std::string const &str)
 
constexpr URI (const char *str)
 
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 std::string make_file_url_string (std::filesystem::path const &path)
 
constexpr static void validate_file_segment (std::string_view segment)
 
constexpr static void validate_file_server (std::string_view server)
 
static URL url_from_current_working_directory () noexcept
 
static URL url_from_resource_directory () noexcept
 
static URL url_from_executable_directory () noexcept
 
static URL url_from_executable_file () noexcept
 
static URL url_from_application_data_directory () noexcept
 
static URL url_from_application_log_directory () noexcept
 
static URL url_from_system_font_directory () noexcept
 
static URL url_from_application_preferences_file () noexcept
 
- Static Public Member Functions inherited from hi::v1::URI
static constexpr std::string decode (auto first, auto last)
 URI percent-encoding decode function.
 
static constexpr std::string decode (auto &&range)
 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

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

Detailed Description

Universal Resource Locator.

An instance internally holds a string to an url. This will have the following effects:

Constructors and path manipulations will cause the url to be normalized:

'file:' scheme urls can handle the following:

The url instance may be relative itself; meaning it does not hold a scheme. This is important, because it means that any string passed to the constructor is a valid url. This also means that non of the constructors and non of the methods will ever cause an error.

meaningless-urls could still cause meaningless results when converted to a path. But this is no different from having a meaningless path in the first place.

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.

◆ generic_path()

std::string hi::v1::URL::generic_path ( ) const
inline

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.

◆ loadView()

std::unique_ptr< resource_view > hi::v1::URL::loadView ( ) const

Load a resource.

Returns
A pointer to a resource view.

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