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

Uniform Resource Identifier (URI) More...

#include <base/net/Uri.h>

Inherits Object.

Public Member Functions

 Uri ()
 
 Uri (const String &uri, bool strict=true)
 
 Uri (const String &relative, const String &base, bool strict=true)
 
 Uri (const Uri &copy) noexcept
 
Urioperator= (const Uri &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 getSearch () const noexcept
 
String getUri () 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)
 

Protected Member Functions

void parse (const String &uri, 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 Identifier (URI)

Implementation of Uniform Resource Identifier (URI) as specified by RFC 2396. A Uniform Resource Identifier (URI) is a compact string for identifying an abstract or physical resource.

Uri uri("http://www.google.com")
Uri uri("ftp://ftp.gnu.org")
Version
1.0

Constructor & Destructor Documentation

◆ Uri() [1/4]

Uri::Uri ( )

Initializes an empty uri.

◆ Uri() [2/4]

Uri::Uri ( const String uri,
bool  strict = true 
)

Initializes uri from a string representation.

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

◆ Uri() [3/4]

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

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

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

◆ Uri() [4/4]

Uri::Uri ( const Uri copy)
noexcept

Initializes uri from other uri.

Member Function Documentation

◆ getHost()

String Uri::getHost ( ) const
noexcept

Returns the host.

◆ getPassword()

String Uri::getPassword ( ) const
noexcept

Returns the password.

◆ getPath()

virtual String Uri::getPath ( ) const
virtual

Returns the path.

◆ getPort()

String Uri::getPort ( ) const
noexcept

Returns the port.

◆ getScheme()

String Uri::getScheme ( ) const
noexcept

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

◆ getSearch()

String Uri::getSearch ( ) const
noexcept

Returns the search part of the identifier.

◆ getUri()

String Uri::getUri ( ) const

Returns the entire identifier.

◆ getUser()

String Uri::getUser ( ) const
noexcept

Returns the user.

◆ isHost()

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

Returns true if the string is a valid host specification.

◆ isPort()

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

Returns true if the string is a valid port.

◆ isRelative()

bool Uri::isRelative ( ) const
noexcept

Returns true if the uri is relative.

◆ operator=()

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

Assignment of uri by uri.

◆ parse()

void Uri::parse ( const String uri,
bool  strict 
)
protected

Parses the string as a uri.

◆ setHost()

void Uri::setHost ( const String value)

Sets the host.

◆ setPassword()

void Uri::setPassword ( const String value)

Sets the password.

◆ setPath()

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

Sets the path.

◆ setPort()

void Uri::setPort ( const String value)

Sets the port.

◆ setScheme()

virtual void Uri::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 thrown if the set of allowed characters is violated.

◆ setUser()

void Uri::setUser ( const String value)

Sets the user.

◆ validatePassword()

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

Validates the specified password and returns it.

◆ validateScheme()

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

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

◆ validateUser()

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

Validates the specified user and returns it.