Url Class Reference

#include <Url.h>

List of all members.

Public Types

enum  Protocol {
  unknown, file, ftp, http,
  https, cd, dvd, nfs,
  dir, hd, smb, cifs
}
typedef std::map
< std::string,
std::string > 
OptionMapType

Public Member Functions

 Url ()
 Url (const std::string &url)
 ~Url ()
bool operator== (const Url &) const
void setProtocol (Protocol)
void setProtocolString (const std::string &str)
void setUsername (const std::string &str)
void setPassword (const std::string &str)
void setHost (const std::string &str)
void setPort (int)
void setPath (const std::string &path)
Protocol protocol () const
const std::string & protocolString () const
const std::string & username () const
const std::string & password () const
const std::string & host () const
int port () const
const std::string & path () const
const OptionMapTypeoptions () const
std::string option (const std::string &key) const
bool isLocal () const
bool isValid () const
bool set (const std::string url)
std::string asString (bool path=true, bool options=true, bool plainpassword=false) const
std::string saveAsString () const

Static Public Member Functions

static Protocol stringToProtocol (const std::string &protocolString)
static std::string protocolToString (Protocol)

Private Member Functions

void clearifinvalid (bool valid)

Static Private Member Functions

static bool split (const std::string &url, Protocol &protocol, std::string &protocolString, std::string &username, std::string &password, std::string &hostname, int &port, std::string &path, OptionMapType &options)

Private Attributes

Protocol _protocol
std::string _protocolString
std::string _username
std::string _password
std::string _host
int _port
std::string _path
OptionMapType _options
bool _valid

Static Private Attributes

static ProtocolStrings _protocolStrings

Friends

std::ostream & operator<< (std::ostream &str, const Url &obj)

Classes

class  ProtocolStrings


Detailed Description

URL class that handles URLs of the form protocol://[[username[:password]][:port]]/path[;options]

TODO: (un)escaping special characters like space -> 20 TODO: check if url is still valid when using set* functions


Member Typedef Documentation

typedef std::map<std::string,std::string> Url::OptionMapType


Member Enumeration Documentation

enum Url::Protocol

Enumerator:
unknown 
file 
ftp 
http 
https 
cd 
dvd 
nfs 
dir 
hd 
smb 
cifs 


Constructor & Destructor Documentation

Url::Url (  ) 

default constructor creating an (invalid) empty Url

Url::Url ( const std::string &  url  ) 

construct new url

Parameters:
url string of the form protocol://[[username[:password]][:port]]/path[;options]

Url::~Url (  )  [inline]


Member Function Documentation

void Url::clearifinvalid ( bool  valid  )  [private]

clear all variables

Parameters:
valid clear if this parameter is false, do nothing if true

bool Url::operator== ( const Url  )  const

void Url::setProtocol ( Protocol   ) 

void Url::setProtocolString ( const std::string &  str  ) 

void Url::setUsername ( const std::string &  str  ) 

void Url::setPassword ( const std::string &  str  ) 

void Url::setHost ( const std::string &  str  ) 

void Url::setPort ( int   ) 

void Url::setPath ( const std::string &  path  ) 

Protocol Url::protocol (  )  const [inline]

const std::string& Url::protocolString (  )  const [inline]

const std::string& Url::username (  )  const [inline]

const std::string& Url::password (  )  const [inline]

const std::string& Url::host (  )  const [inline]

int Url::port (  )  const [inline]

const std::string& Url::path (  )  const [inline]

const OptionMapType& Url::options (  )  const [inline]

std::string Url::option ( const std::string &  key  )  const

return Option

Parameters:
key name of option
Returns:
option value, emtpy string if not found

bool Url::isLocal (  )  const

bool Url::isValid (  )  const

bool Url::set ( const std::string  url  ) 

set url

Parameters:
url string of the form protocol://[[username[:password]][:port]]/path[;options]
Returns:
true if url is valid, false otherwise

std::string Url::asString ( bool  path = true,
bool  options = true,
bool  plainpassword = false 
) const

join tokens to a valid url

Parameters:
path whether to append the path
options whether to append options
plainpassword whether to include the password in plaintext (otherwise PASSWORD is printed)
See also:
saveAsString
Returns:
the url

std::string Url::saveAsString (  )  const [inline]

use this function to get full Url for storing it in a file

static Protocol Url::stringToProtocol ( const std::string &  protocolString  )  [static]

static std::string Url::protocolToString ( Protocol   )  [static]

static bool Url::split ( const std::string &  url,
Protocol protocol,
std::string &  protocolString,
std::string &  username,
std::string &  password,
std::string &  hostname,
int &  port,
std::string &  path,
OptionMapType options 
) [static, private]

split url into tokens

Parameters:
url string of the form protocol://[[username[:password]][:port]]/path[;options]
Returns:
true if valid url, false otherwise


Friends And Related Function Documentation

std::ostream& operator<< ( std::ostream &  str,
const Url obj 
) [friend]


Member Data Documentation

ProtocolStrings Url::_protocolStrings [static, private]

Protocol Url::_protocol [private]

std::string Url::_protocolString [private]

std::string Url::_username [private]

std::string Url::_password [private]

std::string Url::_host [private]

int Url::_port [private]

std::string Url::_path [private]

OptionMapType Url::_options [private]

bool Url::_valid [private]


The documentation for this class was generated from the following file:
Generated on Fri Sep 21 22:35:03 2007 for liby2util by  doxygen 1.5.3