Sirikata
Classes | Public Member Functions | Private Member Functions | Static Private Member Functions | Private Attributes | Friends
Sirikata::Transfer::URLContext Class Reference

Contains the current directory, hostname, protocol and user. More...

#include <URL.hpp>

Collaboration diagram for Sirikata::Transfer::URLContext:

List of all members.

Classes

struct  IsSpace

Public Member Functions

 URLContext ()
 Default constructor (://@/) -- use this along with an absolute URL.
 URLContext (const std::string &newProto, const std::string &newHost, const std::string &newUser, const std::string &newDirectory)
 Absolute URL constructor.
 URLContext (const URLContext &parent, const std::string *newProto, const std::string *newHost, const std::string *newUser, const std::string *newDirectory)
 Acts like the string-parsing constructor, NULL strings mean inherit from the old context, however it's tricky to pass in string pointers if you constructed them on the fly.
 URLContext (const URLContext &parent, const std::string &identifier)
 The most useful constructor -- parses a URL string, and tries to follow rules regarding relative paths and hostnames.
 URLContext (const std::string &identifier)
 The most useful constructor -- parses a URL string, and tries to follow rules regarding relative paths and hostnames.
const std::string & proto () const
 protocol getter (without a ':'), like "http".
void setProto (const std::string &proto)
const std::string & username () const
 username getter--may be empty for no username.
void setUsername (const std::string &user)
const std::string & host () const
 hostname getter--includes port, if any, as well as has brackets around IPv6 addresses.
const std::string hostname () const
const std::string service () const
void setHost (const std::string &host)
const std::string & basepath () const
void setBasepath (const std::string &basepath)
void toParentPath (std::string *pathString)
void toParentContext (std::string *pathString)
std::string toString (bool trailingSlash=true) const
 Constructs a URL... will exclude an empty username.
bool operator< (const URLContext &other) const
 ordering comparison -- more accurate than ordering based on toString().
bool operator== (const URLContext &other) const
 equality comparison
bool operator!= (const URLContext &other) const
bool empty () const
 operator bool () const

Private Member Functions

void cleanup (std::string &s)
void parse (std::string identifier)

Static Private Member Functions

static void resolveParentDirectories (std::string &str)
 Should handle resolving ".." and "." inside of a path.

Private Attributes

std::string mProto
std::string mHost
std::string mUser
std::string mDirectory
 DOES NOT include initial or ending slash.

Friends

class URL

Detailed Description

Contains the current directory, hostname, protocol and user.

The idea is that you can pass this along with a string into the URL constructor, and it will compute a new URL based on relative or absolute paths.

Does not handle query strings (?param1&param2...) or anchors (#someanchor) although, those would also be forms of relative URLs.


Constructor & Destructor Documentation

Sirikata::Transfer::URLContext::URLContext ( ) [inline]

Default constructor (://@/) -- use this along with an absolute URL.

Sirikata::Transfer::URLContext::URLContext ( const std::string &  newProto,
const std::string &  newHost,
const std::string &  newUser,
const std::string &  newDirectory 
) [inline]

Absolute URL constructor.

References cleanup(), mHost, and mProto.

Sirikata::Transfer::URLContext::URLContext ( const URLContext parent,
const std::string *  newProto,
const std::string *  newHost,
const std::string *  newUser,
const std::string *  newDirectory 
) [inline]

Acts like the string-parsing constructor, NULL strings mean inherit from the old context, however it's tricky to pass in string pointers if you constructed them on the fly.

References cleanup(), mHost, and mProto.

Sirikata::Transfer::URLContext::URLContext ( const URLContext parent,
const std::string &  identifier 
) [inline]

The most useful constructor -- parses a URL string, and tries to follow rules regarding relative paths and hostnames.

References parse().

Sirikata::Transfer::URLContext::URLContext ( const std::string &  identifier) [inline]

The most useful constructor -- parses a URL string, and tries to follow rules regarding relative paths and hostnames.

This constructor is provided for convenience, and in many cases, URLs are only allowed to be absolute.

References parse().


Member Function Documentation

const std::string& Sirikata::Transfer::URLContext::basepath ( ) const [inline]
void Sirikata::Transfer::URLContext::cleanup ( std::string &  s) [inline, private]

Referenced by parse(), and URLContext().

bool Sirikata::Transfer::URLContext::empty ( ) const [inline]
const std::string& Sirikata::Transfer::URLContext::host ( ) const [inline]

hostname getter--includes port, if any, as well as has brackets around IPv6 addresses.

Examples: www.example.com www.example.com:80 [fe80::202:b3ff:fe00:0102]:8080

References mHost.

Referenced by Sirikata::Transfer::URL::host(), and setHost().

const std::string Sirikata::Transfer::URLContext::hostname ( ) const [inline]
Sirikata::Transfer::URLContext::operator bool ( ) const [inline]

References empty().

bool Sirikata::Transfer::URLContext::operator!= ( const URLContext other) const [inline]
bool Sirikata::Transfer::URLContext::operator< ( const URLContext other) const [inline]

ordering comparison -- more accurate than ordering based on toString().

References mDirectory, mHost, mProto, and mUser.

bool Sirikata::Transfer::URLContext::operator== ( const URLContext other) const [inline]

equality comparison

References mDirectory, mHost, mProto, and mUser.

void Sirikata::Transfer::URLContext::parse ( std::string  identifier) [inline, private]
const std::string& Sirikata::Transfer::URLContext::proto ( ) const [inline]

protocol getter (without a ':'), like "http".

References mProto.

Referenced by Sirikata::Transfer::URL::proto(), and setProto().

static void Sirikata::Transfer::URLContext::resolveParentDirectories ( std::string &  str) [inline, static, private]

Should handle resolving ".." and "." inside of a path.

Referenced by parse().

const std::string Sirikata::Transfer::URLContext::service ( ) const [inline]
void Sirikata::Transfer::URLContext::setBasepath ( const std::string &  basepath) [inline]

References basepath(), and mDirectory.

void Sirikata::Transfer::URLContext::setHost ( const std::string &  host) [inline]

References host(), and mHost.

void Sirikata::Transfer::URLContext::setProto ( const std::string &  proto) [inline]

References mProto, and proto().

void Sirikata::Transfer::URLContext::setUsername ( const std::string &  user) [inline]

References mUser.

void Sirikata::Transfer::URLContext::toParentContext ( std::string *  pathString) [inline]
void Sirikata::Transfer::URLContext::toParentPath ( std::string *  pathString) [inline]

References mDirectory.

Referenced by toParentContext().

std::string Sirikata::Transfer::URLContext::toString ( bool  trailingSlash = true) const [inline]

Constructs a URL... will exclude an empty username.

References mDirectory, mHost, mProto, and mUser.

Referenced by Sirikata::Transfer::operator<<(), and Sirikata::Transfer::URL::toString().

const std::string& Sirikata::Transfer::URLContext::username ( ) const [inline]

username getter--may be empty for no username.

Try not to store passwords in here, but if there is a password, it will be of the form "username:password".

References mUser.

Referenced by Sirikata::Transfer::URL::username().


Friends And Related Function Documentation

friend class URL [friend]

Member Data Documentation

DOES NOT include initial or ending slash.

Referenced by basepath(), empty(), operator<(), operator==(), parse(), setBasepath(), toParentContext(), toParentPath(), and toString().


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