Base Framework
Classes | Public Member Functions | Static Public Member Functions | Protected Member Functions | Static Protected Member Functions | List of all members
Url Class Reference

Uniform Resource Locator (URL) More...

#include <base/net/Url.h>

Inherits Object.

Classes

class  UrlException
 URL exception. More...
 

Public Member Functions

 Url ()
 
 Url (const String &url, bool strict=true)
 
 Url (const String &relative, const String &base, bool strict=true)
 
 Url (const Url &copy) noexcept
 
Urloperator= (const Url &assign) noexcept
 
bool isRelative () const noexcept
 
String getScheme () const noexcept
 
String getUser () const noexcept
 
String getPassword () const noexcept
 
String getHost () const noexcept
 
String getPort () const noexcept
 
virtual String getPath () const
 
String getUrl () const
 
virtual void setScheme (const String &value)
 
void setUser (const String &value)
 
void setPassword (const String &value)
 
void setHost (const String &value)
 
void setPort (const String &value)
 
virtual void setPath (const String &value)
 
virtual ~Url () noexcept
 

Static Public Member Functions

static bool isReserved (ucs4 ch)
 
static bool isUnreserved (ucs4 ch)
 
static String encodeURIComponent (const String &component)
 
static String decodeURIComponent (const String &component)
 

Protected Member Functions

void parse (const String &url, bool strict)
 

Static Protected Member Functions

static String validateScheme (const String &value)
 
static String validateUser (const String &str)
 
static String validatePassword (const String &str)
 
static bool isHost (String::ReadIterator i, const String::ReadIterator &end) noexcept
 
static bool isPort (String::ReadIterator i, const String::ReadIterator &end) noexcept
 

Detailed Description

Uniform Resource Locator (URL)

Implementation of Uniform Resource Locator (URL) as specified by RFC 1738 and

  1. A compact string representation for a resource available via the Internet. This class is used to break down a url into its components. The components of the url are stored internally in decoded format.
Url url("http://www.google.com")
Url url("ftp://ftp.gnu.org")
Version
1.0
Examples
testsuite/ftp.cpp, and testsuite/http.cpp.

Constructor & Destructor Documentation

◆ Url() [1/4]

Url::Url ( )

Initializes an empty url.

◆ Url() [2/4]

Url::Url ( const String url,
bool  strict = true 
)

Initializes url from a string representation.

Parameters
urlThe string representation of the url.
strictSpecifies that unsafe characters are required to be encoded. Default is true.

◆ Url() [3/4]

Url::Url ( const String relative,
const String base,
bool  strict = true 
)

Initializes url from separate string representations of relative and base url.

Parameters
relativeThe relative url.
baseThe base url.
strictSpecifies that unsafe characters are required to be encoded. Default is true.

◆ Url() [4/4]

Url::Url ( const Url copy)
noexcept

Initializes url from other url.

◆ ~Url()

virtual Url::~Url ( )
inlinevirtualnoexcept

Destroys the url.

Member Function Documentation

◆ decodeURIComponent()

static String Url::decodeURIComponent ( const String component)
static

Returns the decoded URI component.

◆ encodeURIComponent()

static String Url::encodeURIComponent ( const String component)
static

Returns the encoded URI component.

◆ getHost()

String Url::getHost ( ) const
noexcept

Returns the host.

◆ getPassword()

String Url::getPassword ( ) const
noexcept

Returns the password.

◆ getPath()

virtual String Url::getPath ( ) const
virtual

Returns the path.

◆ getPort()

String Url::getPort ( ) const
noexcept

Returns the port.

◆ getScheme()

String Url::getScheme ( ) const
noexcept

Returns the scheme (a.k.a. protocol).

◆ getUrl()

String Url::getUrl ( ) const

Returns the url.

◆ getUser()

String Url::getUser ( ) const
noexcept

Returns the user.

◆ isHost()

static bool Url::isHost ( String::ReadIterator  i,
const String::ReadIterator &  end 
)
staticprotectednoexcept

Returns true if the string is a valid host specification.

◆ isPort()

static bool Url::isPort ( String::ReadIterator  i,
const String::ReadIterator &  end 
)
staticprotectednoexcept

Returns true if the string is a valid port.

◆ isRelative()

bool Url::isRelative ( ) const
noexcept

Returns true if the url is relative.

◆ isReserved()

static bool Url::isReserved ( ucs4  ch)
static

Returns true if character is reserved per RFC3986.

◆ isUnreserved()

static bool Url::isUnreserved ( ucs4  ch)
static

Returns true if character is unreserved per RFC3986.

◆ operator=()

Url& Url::operator= ( const Url assign)
noexcept

Assignment of url by url.

◆ parse()

void Url::parse ( const String url,
bool  strict 
)
protected

Parses the string as a url.

◆ setHost()

void Url::setHost ( const String value)

Sets the host.

◆ setPassword()

void Url::setPassword ( const String value)

Sets the password.

◆ setPath()

virtual void Url::setPath ( const String value)
virtual

Sets the path.

◆ setPort()

void Url::setPort ( const String value)

Sets the port.

◆ setScheme()

virtual void Url::setScheme ( const String value)
virtual

Sets the scheme (a.k.a. protocol). The scheme is composed of letters ('a'-'z'), digits ('0'-'9'), and the characters plus ('+'), period ('.'), and hyphen ('-'). Upper case letters are also allowed but are converted into lower case. The exception URLException is raised if the set of allowed characters is violated.

◆ setUser()

void Url::setUser ( const String value)

Sets the user.

◆ validatePassword()

static String Url::validatePassword ( const String str)
staticprotected

Validates the specified password and returns it.

◆ validateScheme()

static String Url::validateScheme ( const String value)
staticprotected

Validates the specified scheme and returns a slightly converted scheme to be used.

◆ validateUser()

static String Url::validateUser ( const String str)
staticprotected

Validates the specified user and returns it.

Url
Uniform Resource Locator (URL)
Definition: Url.h:38