TSDuck v3.46-4964
MPEG Transport Stream Toolkit
Loading...
Searching...
No Matches

#include <tsURL.h>

Public Member Functions

 URL ()=default
 URL (const UString &path)
 URL (const UString &path, const URL &base)
 URL (const UString &path, const UString &base)
void clear ()
UString getFragment () const
 Get the optional fragment after '#'.
UString getHost () const
 Get the host name.
UString getPassword () const
 Get the optional password.
UString getPath () const
 Get the local path.
uint16_t getPort () const
 Get the optional port number.
UString getQuery () const
const UStringToUStringMultiMap & getQueryParameters () const
UString getScheme () const
 Get the scheme name without trailing colon.
UString getUserName () const
 Get the optional user name part.
bool isValid () const
bool sameServer (const URL &other) const
void setFragment (const UString &value)
 Set the optional fragment after '#'.
void setHost (const UString &value)
 Set the host name.
void setPassword (const UString &value)
 Set the optional password.
void setPath (const UString &value)
 Set the local path.
void setPort (const uint16_t &value)
 Set the optional port number.
void setQuery (const UString &value)
void setScheme (const UString &value)
 Set the scheme name without trailing colon.
void setURL (const UString &path)
void setURL (const UString &path, const URL &base)
void setURL (const UString &path, const UString &base)
void setUserName (const UString &value)
 Set the optional user name part.
UString toRelative (const URL &base, bool use_win_inet=true) const
UString toRelative (const UString &base, bool use_win_inet=true) const
UString toString (bool use_win_inet=true) const

Static Public Member Functions

static bool IsURL (const UString &path)

Detailed Description

Representation of a Uniform Resource Locator (URL).

Constructor & Destructor Documentation

◆ URL() [1/4]

ts::URL::URL ( )
default

Default constructor.

◆ URL() [2/4]

ts::URL::URL ( const UString & path)
inline

Constructor from a string.

Parameters
[in]pathA file path or URL as a string. If this is a file specification, build a "file:" URL with the absolute path.

◆ URL() [3/4]

ts::URL::URL ( const UString & path,
const UString & base )
inline

Constructor from a string and a base string.

Parameters
[in]pathA file path or URL as a string.
[in]baseThe base URL or directory to use if path is a relative file path. By default, when base is empty, the current working directory is used and a "file:" URL is built.

◆ URL() [4/4]

ts::URL::URL ( const UString & path,
const URL & base )
inline

Constructor from a string and a base URL.

Parameters
[in]pathA file path or URL as a string.
[in]baseThe base URL to use if path is a relative path.

Member Function Documentation

◆ setURL() [1/3]

void ts::URL::setURL ( const UString & path)

Set URL from a string.

Parameters
[in]pathA file path or URL as a string. If this is a file specification, build a "file:" URL with the absolute path.

◆ setURL() [2/3]

void ts::URL::setURL ( const UString & path,
const UString & base )

Set URL from a string and a base string.

Parameters
[in]pathA file path or URL as a string.
[in]baseThe base URL or directory to use if path is a relative file path. By default, when base is empty, the current working directory is used and a "file:" URL is built.

◆ setURL() [3/3]

void ts::URL::setURL ( const UString & path,
const URL & base )

Set URL from a string and a base URL.

Parameters
[in]pathA file path or URL as a string.
[in]baseThe base URL to use if path is a relative path.

◆ toString()

UString ts::URL::toString ( bool use_win_inet = true) const

Convert to a string object.

Parameters
[in]use_win_inetThis boolean is used on Windows only. When true, a file URL is built as 'file://C:/dir/file' (with 2 slashes). When false, the URL is 'file:///C:/dir/file' (with 3 slashes). The latter form is the documented one from Microsoft and should be considered as the "correct" one. However, the Microsoft WinInet library (which is used by the WebRequest class) requires the incorrect form with 2 slashes. So, if the resulting URL is to be used by WebRequest, set use_win_inet to true (the default) but if the URL needs to be published somewhere, use false.
Returns
The URL as a string.

◆ toRelative() [1/2]

UString ts::URL::toRelative ( const URL & base,
bool use_win_inet = true ) const

Extract a relative URL of this object, from a base URL.

Parameters
[in]baseThe base URL to use. If this object and base share the same scheme and host specification.
[in]use_win_inetThis boolean is used on Windows only. See toString() for details.
Returns
The relative URL as a string.

◆ toRelative() [2/2]

UString ts::URL::toRelative ( const UString & base,
bool use_win_inet = true ) const

Extract a relative URL of this object, from a base URL.

Parameters
[in]baseThe base URL to use. If this object and base share the same scheme and host specification.
[in]use_win_inetThis boolean is used on Windows only. See toString() for details.
Returns
The relative URL as a string.

◆ sameServer()

bool ts::URL::sameServer ( const URL & other) const

Check if two URL's use the same server (scheme, host, user, etc.)

Parameters
[in]otherAnother URL to compare.
Returns
True if the two URL' as a string's use the same server.

◆ isValid()

bool ts::URL::isValid ( ) const
inline

Check if the URL is valid (was built from a valid URL string).

Returns
True if the URL is valid.

◆ clear()

void ts::URL::clear ( )

Clear the content of the URL (becomes invalid).

◆ setScheme()

void ts::URL::setScheme ( const UString & value)
inline

Set the scheme name without trailing colon.

Parameters
[in]valueThe scheme name without trailing colon.

◆ getScheme()

UString ts::URL::getScheme ( ) const
inline

Get the scheme name without trailing colon.

Returns
The scheme name without trailing colon.

◆ setUserName()

void ts::URL::setUserName ( const UString & value)
inline

Set the optional user name part.

Parameters
[in]valueThe optional user name part.

◆ getUserName()

UString ts::URL::getUserName ( ) const
inline

Get the optional user name part.

Returns
The optional user name part.

◆ setPassword()

void ts::URL::setPassword ( const UString & value)
inline

Set the optional password.

Parameters
[in]valueThe optional password.

◆ getPassword()

UString ts::URL::getPassword ( ) const
inline

Get the optional password.

Returns
The optional password.

◆ setHost()

void ts::URL::setHost ( const UString & value)
inline

Set the host name.

Parameters
[in]valueThe host name.

◆ getHost()

UString ts::URL::getHost ( ) const
inline

Get the host name.

Returns
The host name.

◆ setPort()

void ts::URL::setPort ( const uint16_t & value)
inline

Set the optional port number.

Parameters
[in]valueThe optional port number.

◆ getPort()

uint16_t ts::URL::getPort ( ) const
inline

Get the optional port number.

Returns
The optional port number.

◆ setPath()

void ts::URL::setPath ( const UString & value)
inline

Set the local path.

Parameters
[in]valueThe local path.

◆ getPath()

UString ts::URL::getPath ( ) const
inline

Get the local path.

Returns
The local path.

◆ setFragment()

void ts::URL::setFragment ( const UString & value)
inline

Set the optional fragment after '#'.

Parameters
[in]valueThe optional fragment after '#'.

◆ getFragment()

UString ts::URL::getFragment ( ) const
inline

Get the optional fragment after '#'.

Returns
The optional fragment after '#'.

◆ setQuery()

void ts::URL::setQuery ( const UString & value)

Set the optional query after '?'.

Parameters
[in]valueThe optional query after '?'.

◆ getQuery()

UString ts::URL::getQuery ( ) const
inline

Get the optional query after '?'.

Returns
The optional query after '?'.

◆ getQueryParameters()

const UStringToUStringMultiMap & ts::URL::getQueryParameters ( ) const
inline

Set the parameters in the optional query after '?'.

Returns
A constant reference to a string-to-string multimap. The keys are the parameter names in the query, with their associated value.

◆ IsURL()

bool ts::URL::IsURL ( const UString & path)
inlinestatic

This static method checks if a string contains a URL. It does not check the full validity of the URL, only if it starts with scheme://.

Parameters
[in]pathA file path.
Returns
True if path is a URL.

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