Transfer Ease
Loading...
Searching...
No Matches
tease::Url Class Reference

Use to manage URLs. More...

Public Types

enum  IdScheme {
  SCHEME_UNK = 0 , SCHEME_FTP , SCHEME_FTPS , SCHEME_HTTP ,
  SCHEME_HTTPS , SCHEME_NB_SUPPORTED
}
 List of supported schemes. More...
 

Public Member Functions

 Url ()
 Build a empty URL which will be invalid.
 
 Url (const std::string &url)
 Create an URL from a string which will be parsed.
 
 Url (const Url &other)
 
 Url (Url &&other) noexcept
 
void clear ()
 Use to reset an URL.
 
void setUrl (const std::string &url)
 Use to set URL from a string.
 
void setIdScheme (IdScheme idScheme)
 
void setHost (const std::string &host)
 
void setPort (uint16_t port)
 
void setPath (const std::string &path)
 
bool isValid () const
 Use to know if URL is valid.
 
std::string toString () const
 Use to generate properly formatted URL.
 
IdScheme getIdScheme () const
 
const std::string & getHost () const
 
uint16_t getPort () const
 
const std::string & getPath () const
 
Urloperator= (const Url &other)
 
Urloperator= (Url &&other) noexcept
 

Static Public Member Functions

static std::string idSchemeToString (IdScheme idScheme)
 
static IdScheme idSchemeFromString (const std::string &idScheme)
 

Friends

TEASE_EXPORT friend bool operator== (const Url &left, const Url &right)
 
TEASE_EXPORT friend bool operator!= (const Url &left, const Url &right)
 

Detailed Description

Use to manage URLs.

Member Enumeration Documentation

◆ IdScheme

List of supported schemes.

See also
idSchemeToString(), idSchemeFromString()
Enumerator
SCHEME_UNK 

Unknown/unsupported protocol

SCHEME_FTP  

Plain, unencrypted FTP that defaults over port 21

SCHEME_FTPS  

Implicit SSL/TLS encrypted FTP that works just like HTTPS.
Security is enabled with SSL as soon as the connection starts.
The default FTPS port is 990. This protocol was the first version of encrypted FTP available, and while considered deprecated, is still widely used

SCHEME_HTTP  

Plain, unencrypted HTTP

SCHEME_HTTPS  

HTTPS protocol which use SSL/TLS layer

SCHEME_NB_SUPPORTED  

Number of protocol supported

Constructor & Destructor Documentation

◆ Url() [1/2]

tease::Url::Url ( )

Build a empty URL which will be invalid.

See also
isValid()

◆ Url() [2/2]

tease::Url::Url ( const std::string & url)
explicit

Create an URL from a string which will be parsed.

See setUrl() for more details.

Parameters
[in]urlURL to parse.
If invalid or protocol unsupported, URL will be cleared.
See also
isValid(), setUrl()
clear()

Member Function Documentation

◆ clear()

void tease::Url::clear ( )

Use to reset an URL.

See also
isValid()

◆ isValid()

bool tease::Url::isValid ( ) const

Use to know if URL is valid.

URL is considered valid if scheme is supported and associated fields are set.

Returns
Returns true if URL is valid

◆ setUrl()

void tease::Url::setUrl ( const std::string & url)

Use to set URL from a string.

This method will parse the provided string to URL format. Examples:

url1.setUrl("https://example.com:8080/path/to/resource.zip");
url2.setUrl("https://example.com/path/to/resource.zip");

Properties of those URLs will be:

  • IdScheme: Url::SCHEME_HTTPS
  • Host: example.com
  • Port: 8080 for url1 and 0 for url2 (0 simply means that we don't provide port info)
  • Path: path/to/resource.zip
Parameters
[in]urlURL to parse.
If invalid or protocol unsupported, URL will be cleared.

◆ toString()

std::string tease::Url::toString ( ) const

Use to generate properly formatted URL.

Returns
Returns formatted URL.
Returned value can be empty if URL is invalid.
See also
isValid()

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