CoreComponents 3.0.0
A Modern C++ Toolkit
Loading...
Searching...
No Matches
Uri Class Reference

Uniform Resource Indentifier (URI) More...

#include <cc/Uri>

Public Member Functions

 Uri ()=default
 Create an invalid URI.
 
 Uri (const String &text)
 Create a new URI from text.
 
 Uri (const char *text)
 Create a new URI from text.
 
 Uri (const String &text, const Token &token)
 Create a new URI from text using the UriSyntax production token.
 
bool isValid () const
 Tell if this URI is valid.
 
 operator bool () const
 Tell if this URI is valid.
 
String scheme () const
 URI scheme (e.g.
 
void setScheme (const String &newValue)
 Set the URI scheme to newValue
 
String userInfo () const
 User and password information (e.g.
 
void setUserInfo (const String &newValue)
 Set the user information to newValue
 
String host () const
 Registered host name or numeric address (IPv4 or IPv6)
 
void setHost (const String &newValue)
 Set the host name to newValue
 
bool hostIsNumeric () const
 Tell if the host part is a numeric address.
 
bool isHostNumeric () const
 Tell if the host part is a numeric address.
 
int port () const
 Service port.
 
void setPort (int newValue)
 Set the service port to newValue
 
String path () const
 Path component of the URI.
 
void setPath (const String &newValue)
 Set the path component of the URI to newValue
 
String query () const
 Get tje query component of the URI.
 
void setQuery (const String &newValue)
 Set the query component of the URI to newValue
 
String fragment () const
 Get the fragment component of the URI.
 
void setFragment (const String &newValue)
 Set the fragment component of the URI to newValue
 
String requestHost () const
 Get the host name including the port number.
 
String requestPath () const
 Get the full request path (path, query and fragment component)
 
String toString () const
 Return the human readable textual representation of this URI
 
String encoded () const
 Return an percent encoded textual representation of this URI
 
SocketAddress resolve (int port=0) const
 Resolve internet address of this URI.
 
ProtocolFamily family () const
 Protocol family of uri (if uri contains a numeric host part)
 

Static Public Member Functions

static String encode (const String &text)
 Encode text using percent encoding.
 
static String decode (const String &text)
 Decode text from percent encoding.
 
static void decode (InOut< String > text)
 Decode text from percent encoding.
 
static String encodeForm (const Map< String > &form)
 Encode a percent encoded web input form.
 
static Map< StringdecodeForm (const String &payload)
 Decode a percent encoded web input form.
 

Detailed Description

Uniform Resource Indentifier (URI)

Constructor & Destructor Documentation

◆ Uri() [1/4]

Uri ( )
default

Create an invalid URI.

◆ Uri() [2/4]

Uri ( const String & text)

Create a new URI from text.

Exceptions
TextErrorInvalid URI syntax

◆ Uri() [3/4]

Uri ( const char * text)

Create a new URI from text.

Exceptions
TextErrorInvalid URI syntax

◆ Uri() [4/4]

Uri ( const String & text,
const Token & token )

Create a new URI from text using the UriSyntax production token.

Member Function Documentation

◆ isValid()

bool isValid ( ) const

Tell if this URI is valid.

◆ operator bool()

operator bool ( ) const
explicit

Tell if this URI is valid.

◆ scheme()

String scheme ( ) const

URI scheme (e.g.

http, file)

◆ setScheme()

void setScheme ( const String & newValue)

Set the URI scheme to newValue

◆ userInfo()

String userInfo ( ) const

User and password information (e.g.

"oscar:123456")

◆ setUserInfo()

void setUserInfo ( const String & newValue)

Set the user information to newValue

◆ host()

String host ( ) const

Registered host name or numeric address (IPv4 or IPv6)

◆ setHost()

void setHost ( const String & newValue)

Set the host name to newValue

◆ hostIsNumeric()

bool hostIsNumeric ( ) const

Tell if the host part is a numeric address.

Todo
obsolete

◆ isHostNumeric()

bool isHostNumeric ( ) const

Tell if the host part is a numeric address.

◆ port()

int port ( ) const

Service port.

◆ setPort()

void setPort ( int newValue)

Set the service port to newValue

◆ path()

String path ( ) const

Path component of the URI.

◆ setPath()

void setPath ( const String & newValue)

Set the path component of the URI to newValue

◆ query()

String query ( ) const

Get tje query component of the URI.

◆ setQuery()

void setQuery ( const String & newValue)

Set the query component of the URI to newValue

◆ fragment()

String fragment ( ) const

Get the fragment component of the URI.

◆ setFragment()

void setFragment ( const String & newValue)

Set the fragment component of the URI to newValue

◆ requestHost()

String requestHost ( ) const

Get the host name including the port number.

◆ requestPath()

String requestPath ( ) const

Get the full request path (path, query and fragment component)

◆ toString()

String toString ( ) const

Return the human readable textual representation of this URI

◆ encoded()

String encoded ( ) const

Return an percent encoded textual representation of this URI

◆ encode()

static String encode ( const String & text)
static

Encode text using percent encoding.

◆ decode() [1/2]

String decode ( const String & text)
static

Decode text from percent encoding.

◆ decode() [2/2]

void decode ( InOut< String > text)
static

Decode text from percent encoding.

◆ encodeForm()

String encodeForm ( const Map< String > & form)
static

Encode a percent encoded web input form.

◆ decodeForm()

Map< String > decodeForm ( const String & payload)
static

Decode a percent encoded web input form.

◆ resolve()

SocketAddress resolve ( int port = 0) const

Resolve internet address of this URI.

Parameters
portPort number to set (if this URI does not provide a port number)
Exceptions
HostNameResolutionError

◆ family()

ProtocolFamily family ( ) const

Protocol family of uri (if uri contains a numeric host part)