Main Page | Namespace List | Class Hierarchy | Class List | File List | Namespace Members | Class Members | File Members

Url Class Reference

#include <Url.h>

List of all members.

Public Types

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

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

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

Private Member Functions

void clearifinvalid (bool valid)

Static Private Member Functions

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

ProtocolStrings _protocolStrings

Friends

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


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
 

Enumeration values:
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

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

void Url::clearifinvalid bool  valid  )  [private]
 

clear all variables

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

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

bool Url::isLocal  )  const
 

bool Url::isValid  )  const
 

bool Url::operator== const Url  )  const
 

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

return Option

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

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

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

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

int Url::port  )  const [inline]
 

Protocol Url::protocol  )  const [inline]
 

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

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

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

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

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

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

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

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

void Url::setPort int   ) 
 

void Url::setProtocol Protocol   ) 
 

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

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

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

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

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


Friends And Related Function Documentation

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


Member Data Documentation

std::string Url::_host [private]
 

OptionMapType Url::_options [private]
 

std::string Url::_password [private]
 

std::string Url::_path [private]
 

int Url::_port [private]
 

Protocol Url::_protocol [private]
 

std::string Url::_protocolString [private]
 

Url::ProtocolStrings Url::_protocolStrings [static, private]
 

std::string Url::_username [private]
 

bool Url::_valid [private]
 


The documentation for this class was generated from the following files:
Generated on Thu Feb 23 23:56:11 2006 for liby2util by doxygen 1.3.6