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:Port/LocalPathFragment?Query
Example URIs:
http://user:[email protected]: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
(C) 2006 Radon Labs GmbH
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 |
Member Function Documentation
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 "/".
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.
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.
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.