Sirikata
|
Contains the current directory, hostname, protocol and user. More...
#include <URL.hpp>
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 |
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¶m2...) or anchors (#someanchor) although, those would also be forms of relative URLs.
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] |
Sirikata::Transfer::URLContext::URLContext | ( | const URLContext & | parent, |
const std::string * | newProto, | ||
const std::string * | newHost, | ||
const std::string * | newUser, | ||
const std::string * | newDirectory | ||
) | [inline] |
Sirikata::Transfer::URLContext::URLContext | ( | const URLContext & | parent, |
const std::string & | identifier | ||
) | [inline] |
Sirikata::Transfer::URLContext::URLContext | ( | const std::string & | identifier | ) | [inline] |
const std::string& Sirikata::Transfer::URLContext::basepath | ( | ) | const [inline] |
References mDirectory.
Referenced by Sirikata::Transfer::URL::basepath(), Sirikata::Transfer::URL::fullpath(), and setBasepath().
void Sirikata::Transfer::URLContext::cleanup | ( | std::string & | s | ) | [inline, private] |
Referenced by parse(), and URLContext().
bool Sirikata::Transfer::URLContext::empty | ( | ) | const [inline] |
References mDirectory, mHost, mProto, and mUser.
Referenced by Sirikata::Transfer::URL::empty(), and operator bool().
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] |
References mHost.
Referenced by Sirikata::Transfer::MeerkatChunkHandler::cache_check_callback(), and Sirikata::Transfer::URL::hostname().
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] |
References cleanup(), mDirectory, mHost, mProto, mUser, and resolveParentDirectories().
Referenced by Sirikata::Transfer::URL::findSlash(), and URLContext().
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] |
References mHost.
Referenced by Sirikata::Transfer::MeerkatChunkHandler::cache_check_callback().
void Sirikata::Transfer::URLContext::setBasepath | ( | const std::string & | basepath | ) | [inline] |
References basepath(), and mDirectory.
void Sirikata::Transfer::URLContext::setHost | ( | const std::string & | host | ) | [inline] |
void Sirikata::Transfer::URLContext::setProto | ( | const std::string & | proto | ) | [inline] |
void Sirikata::Transfer::URLContext::setUsername | ( | const std::string & | user | ) | [inline] |
References mUser.
void Sirikata::Transfer::URLContext::toParentContext | ( | std::string * | pathString | ) | [inline] |
References mDirectory, mHost, mProto, mUser, and toParentPath().
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().
friend class URL [friend] |
std::string Sirikata::Transfer::URLContext::mDirectory [private] |
DOES NOT include initial or ending slash.
Referenced by basepath(), empty(), operator<(), operator==(), parse(), setBasepath(), toParentContext(), toParentPath(), and toString().
std::string Sirikata::Transfer::URLContext::mHost [private] |
Referenced by empty(), host(), hostname(), operator<(), operator==(), parse(), service(), setHost(), toParentContext(), toString(), and URLContext().
std::string Sirikata::Transfer::URLContext::mProto [private] |
Referenced by empty(), operator<(), operator==(), parse(), proto(), setProto(), toParentContext(), toString(), and URLContext().
std::string Sirikata::Transfer::URLContext::mUser [private] |
Referenced by empty(), operator<(), operator==(), parse(), setUsername(), toParentContext(), toString(), and username().