TSDuck v3.38-3696
MPEG Transport Stream Toolkit
Loading...
Searching...
No Matches
ts::URL Class Reference

Representation of a Uniform Resource Locator (URL). More...

#include <tsURL.h>

Public Member Functions

 URL ()=default
 Default constructor.
 
 URL (const UString &path)
 Constructor from a string.
 
 URL (const UString &path, const URL &base)
 Constructor from a string and a base URL.
 
 URL (const UString &path, const UString &base)
 Constructor from a string and a base string.
 
void clear ()
 Clear the content of the URL (becomes invalid).
 
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
 Get the optional query after '?' .
 
UString getScheme () const
 Get the scheme name without trailing colon .
 
UString getUserName () const
 Get the optiona user name part .
 
bool isValid () const
 Check if the URL is valid (was built from a valid URL string).
 
bool sameServer (const URL &other) const
 Check if two URL's use the same server (scheme, host, user, etc.)
 
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)
 Set the optional query after '?' .
 
void setScheme (const UString &value)
 Set the scheme name without trailing colon .
 
void setURL (const UString &path)
 Set URL from a string.
 
void setURL (const UString &path, const URL &base)
 Set URL from a string and a base URL.
 
void setURL (const UString &path, const UString &base)
 Set URL from a string and a base string.
 
void setUserName (const UString &value)
 Set the optiona user name part .
 
UString toRelative (const URL &base, bool useWinInet=true) const
 Extract a relative URL of this object, from a base URL.
 
UString toRelative (const UString &base, bool useWinInet=true) const
 Extract a relative URL of this object, from a base URL.
 
UString toString (bool useWinInet=true) const
 Convert to a string object.
 

Static Public Member Functions

static bool IsURL (const UString &path)
 This static method checks if a string contains a URL.
 

Detailed Description

Representation of a Uniform Resource Locator (URL).

Constructor & Destructor Documentation

◆ URL() [1/3]

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() [2/3]

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() [3/3]

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  useWinInet = true) const

Convert to a string object.

Parameters
[in]useWinInetThis 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 useWinInet 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  useWinInet = 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]useWinInetThis 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  useWinInet = 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]useWinInetThis 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.

◆ 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 optiona user name part .


Parameters
[in]valueThe optiona user name part .

◆ getUserName()

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

Get the optiona user name part .


Returns
The optiona 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 .

◆ setQuery()

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

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 '?' .

◆ 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 '#' .

◆ IsURL()

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