Nebula
|
#include <uri.h>
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:
Enconding from components into string happens in the AsString() method in the following steps:
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::String & | Scheme () const |
get Scheme component (default is file) | |
void | SetUserInfo (const Util::String &s) |
set UserInfo component | |
const Util::String & | UserInfo () const |
get UserInfo component (can be empty) | |
void | SetHost (const Util::String &s) |
set Host component | |
const Util::String & | Host () const |
get Host component (can be empty) | |
void | SetPort (const Util::String &s) |
set Port component | |
const Util::String & | Port () const |
get Port component (can be empty) | |
void | SetLocalPath (const Util::String &s) |
set LocalPath component | |
const Util::String & | LocalPath () 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::String & | Fragment () const |
get Fragment component (can be empty) | |
void | SetQuery (const Util::String &s) |
set Query component | |
const Util::String & | Query () const |
get Query component (can be empty) | |
Util::Dictionary< Util::String, Util::String > | ParseQuery () 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 |
|
inline |
default constructor
|
inline |
init constructor
|
inline |
init constructor
|
inline |
copy constructor
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 "/".
|
inline |
return as concatenated string
|
private |
build string from components
This builds an URI string from its components.
|
inline |
clear the URI
|
inline |
get Fragment component (can be empty)
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.
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.
|
inline |
get Host component (can be empty)
|
inline |
return true if the URI is empty
|
inline |
return true if the URI is not empty
|
inline |
get LocalPath component (can be empty)
|
inline |
inequality operator
|
inline |
assignmnent operator
|
inline |
equality operator
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¶m2=value¶m3=value ...) into a dictionary.
Ill-formatted query fragments will be ignored.
|
inline |
get Port component (can be empty)
|
inline |
get Query component (can be empty)
|
inline |
get Scheme component (default is file)
|
inline |
set complete URI string
|
inline |
set Fragment component
|
inline |
set Host component
|
inline |
set LocalPath component
|
inline |
set Port component
|
inline |
set Query component
|
inline |
set Scheme component (ftp, http, etc...)
|
inline |
set UserInfo component
|
private |
|
inline |
get UserInfo component (can be empty)
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |