Nebula
Loading...
Searching...
No Matches
IO::URI Class Reference

#include <uri.h>

Detailed Description

An URI object can split a Uniform Resource Identifier string into its components or build a string from URI components.

Please note that the memory footprint of an URI object is always bigger then a pure String object, so if memory usage is of concern, it is advised to keep paths as String objects around, and only use URI objects to encode and decode them.

An URI is made of the following components, where most of them are optional:

Scheme://UserInfo@Host:Port/LocalPathFragment?Query

Example URIs:

http://user:password@www.myserver.com:8080/index.html#main http://www.myserver.com/query?user=bla ftp://ftp.myserver.com/pub/bla.zip file:///c:/temp/bla.txt file://SambaServer/temp/blub.txt

Note that assigns will be resolved before splitting a URI into its components, for instance the assign "textures" could be defined as:

Assign("textures", "http://www.dataserv.com/myapp/textures/");

So a path to a texture URI could be defined as:

URI("textures:mytex.dds")

Which would actually resolve into:

http://www.dataserv.com/myapp/textures/mytex.dds

Decoding into components happens in the init constructor or the Set() method in the following steps:

  • resolve any assigns in the original string
  • split into Scheme, Host and Path blocks
  • resolve Host and Path blocks further

Enconding from components into string happens in the AsString() method in the following steps:

  • concatenate URI string from components
  • convert part of the string back into an existing assign

Public Member Functions

 URI ()
 default constructor
 
 URI (const Util::String &s)
 init constructor
 
 URI (const char *s)
 init constructor
 
 URI (const URI &rhs)
 copy constructor
 
void operator= (const URI &rhs)
 assignmnent operator
 
bool operator== (const URI &rhs) const
 equality operator
 
bool operator!= (const URI &rhs) const
 inequality operator
 
void Set (const Util::String &s)
 set complete URI string
 
Util::String AsString () const
 return as concatenated string
 
bool IsEmpty () const
 return true if the URI is empty
 
bool IsValid () const
 return true if the URI is not empty
 
void Clear ()
 clear the URI
 
void SetScheme (const Util::String &s)
 set Scheme component (ftp, http, etc...)
 
const Util::StringScheme () const
 get Scheme component (default is file)
 
void SetUserInfo (const Util::String &s)
 set UserInfo component
 
const Util::StringUserInfo () const
 get UserInfo component (can be empty)
 
void SetHost (const Util::String &s)
 set Host component
 
const Util::StringHost () const
 get Host component (can be empty)
 
void SetPort (const Util::String &s)
 set Port component
 
const Util::StringPort () const
 get Port component (can be empty)
 
void SetLocalPath (const Util::String &s)
 set LocalPath component
 
const Util::StringLocalPath () const
 get LocalPath component (can be empty)
 
void AppendLocalPath (const Util::String &pathComponent)
 append an element to the local path component
 
void SetFragment (const Util::String &s)
 set Fragment component
 
const Util::StringFragment () const
 get Fragment component (can be empty)
 
void SetQuery (const Util::String &s)
 set Query component
 
const Util::StringQuery () const
 get Query component (can be empty)
 
Util::Dictionary< Util::String, Util::StringParseQuery () const
 parse query parameters into a dictionary
 
Util::String GetTail () const
 get the "tail" (path, query and fragment)
 
Util::String GetHostAndLocalPath () const
 get the host and path without scheme
 

Private Member Functions

bool Split (const Util::String &s)
 split string into components
 
Util::String Build () const
 build string from components
 

Private Attributes

bool isEmpty
 
Util::String scheme
 
Util::String userInfo
 
Util::String host
 
Util::String port
 
Util::String localPath
 
Util::String fragment
 
Util::String query
 

Constructor & Destructor Documentation

◆ URI() [1/4]

IO::URI::URI ( )
inline

default constructor

◆ URI() [2/4]

IO::URI::URI ( const Util::String & s)
inline

init constructor

◆ URI() [3/4]

IO::URI::URI ( const char * s)
inline

init constructor

◆ URI() [4/4]

IO::URI::URI ( const URI & rhs)
inline

copy constructor

Member Function Documentation

◆ AppendLocalPath()

void IO::URI::AppendLocalPath ( const Util::String & pathComponent)

append an element to the local path component

Appends an element to the local path.

Automatically inserts a path delimiter "/".

◆ AsString()

Util::String IO::URI::AsString ( ) const
inline

return as concatenated string

◆ Build()

String IO::URI::Build ( ) const
private

build string from components

This builds an URI string from its components.

◆ Clear()

void IO::URI::Clear ( )
inline

clear the URI

◆ Fragment()

const Util::String & IO::URI::Fragment ( ) const
inline

get Fragment component (can be empty)

◆ GetHostAndLocalPath()

String IO::URI::GetHostAndLocalPath ( ) const

get the host and path without scheme

Returns the host and local path in the form "//host/localpath".

If no host has been set, only "/localpath" will be returned.

◆ GetTail()

String IO::URI::GetTail ( ) const

get the "tail" (path, query and fragment)

This returns the "tail", which is the local path, the fragment and the query concatenated into one string.

◆ Host()

const Util::String & IO::URI::Host ( ) const
inline

get Host component (can be empty)

◆ IsEmpty()

bool IO::URI::IsEmpty ( ) const
inline

return true if the URI is empty

◆ IsValid()

bool IO::URI::IsValid ( ) const
inline

return true if the URI is not empty

◆ LocalPath()

const Util::String & IO::URI::LocalPath ( ) const
inline

get LocalPath component (can be empty)

◆ operator!=()

bool IO::URI::operator!= ( const URI & rhs) const
inline

inequality operator

◆ operator=()

void IO::URI::operator= ( const URI & rhs)
inline

assignmnent operator

◆ operator==()

bool IO::URI::operator== ( const URI & rhs) const
inline

equality operator

◆ ParseQuery()

Dictionary< String, String > IO::URI::ParseQuery ( ) const

parse query parameters into a dictionary

This parses the query part of the URI (in the form param1=value&param2=value&param3=value ...) into a dictionary.

Ill-formatted query fragments will be ignored.

◆ Port()

const Util::String & IO::URI::Port ( ) const
inline

get Port component (can be empty)

◆ Query()

const Util::String & IO::URI::Query ( ) const
inline

get Query component (can be empty)

◆ Scheme()

const Util::String & IO::URI::Scheme ( ) const
inline

get Scheme component (default is file)

◆ Set()

void IO::URI::Set ( const Util::String & s)
inline

set complete URI string

◆ SetFragment()

void IO::URI::SetFragment ( const Util::String & s)
inline

set Fragment component

◆ SetHost()

void IO::URI::SetHost ( const Util::String & s)
inline

set Host component

◆ SetLocalPath()

void IO::URI::SetLocalPath ( const Util::String & s)
inline

set LocalPath component

◆ SetPort()

void IO::URI::SetPort ( const Util::String & s)
inline

set Port component

◆ SetQuery()

void IO::URI::SetQuery ( const Util::String & s)
inline

set Query component

◆ SetScheme()

void IO::URI::SetScheme ( const Util::String & s)
inline

set Scheme component (ftp, http, etc...)

◆ SetUserInfo()

void IO::URI::SetUserInfo ( const Util::String & s)
inline

set UserInfo component

◆ Split()

bool IO::URI::Split ( const Util::String & s)
private

split string into components

Resolve assigns and split URI string into its components.

Todo
: this is too complicated...

◆ UserInfo()

const Util::String & IO::URI::UserInfo ( ) const
inline

get UserInfo component (can be empty)

Member Data Documentation

◆ fragment

Util::String IO::URI::fragment
private

◆ host

Util::String IO::URI::host
private

◆ isEmpty

bool IO::URI::isEmpty
private

◆ localPath

Util::String IO::URI::localPath
private

◆ port

Util::String IO::URI::port
private

◆ query

Util::String IO::URI::query
private

◆ scheme

Util::String IO::URI::scheme
private

◆ userInfo

Util::String IO::URI::userInfo
private

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