te::common::uri Namespace Reference

Namespaces

 urisyn
 URI syntax declarations.
 

Classes

class  authority
 URI authority component (without userinfo). More...
 
class  domain_name
 Domain name. More...
 
class  fragment
 URI fragment component. More...
 
class  ip_address
 IP address. More...
 
class  ipv6_address
 
class  path
 URI path component. More...
 
class  query
 URI query component. More...
 
class  scheme
 URI scheme component. More...
 
class  uri
 Uniform Resource Identifier (URI) reference. More...
 

Functions

void append_hex (char v, std::string &s)
 Convert the char v to hex and add the 2 chars to the end of s. More...
 
std::string convert (const char *v)
 cstring to string More...
 
std::string convert (bool v)
 bool to string, true="1", false="0" More...
 
std::string convert (int v)
 int to string More...
 
std::string convert (unsigned int v)
 uint to string More...
 
std::string convert (long int v)
 long int to string More...
 
std::string convert (unsigned long int v)
 unsigned long int to string More...
 
std::string convert (long long int v)
 long long int to string More...
 
std::string convert (unsigned long long int v)
 unsigned long long int to string More...
 
std::string convert (double v)
 double to string More...
 
std::string convert (const std::string &v)
 string to trimmed string More...
 
bool convert (const std::string &s, bool &v)
 String to bool, returning true if set, which is when the string is not empty or all isspace. More...
 
bool convert (const std::string &s, int &v)
 String to int, returning true if set, which is when the string is not empty or all isspace. More...
 
bool convert (const std::string &s, unsigned int &v)
 String to unsigned int, returning true if set, which is when the string is not empty or all isspace. More...
 
bool convert (const std::string &s, unsigned long int &v)
 String to size_t, returning true if set, which is when the string is not empty or all isspace. More...
 
bool convert (const std::string &s, long long int &v)
 String to long long int, returning true if set, which is when the string is not empty or all isspace. More...
 
bool convert (const std::string &s, unsigned long long int &v)
 String to unsigned long long int, returning true if set, which is when the string is not empty or all isspace. More...
 
bool convert (const std::string &s, double &v)
 String to double, returning true if set, which is when the string is not empty or all isspace. More...
 
bool convert (const std::string &s, std::string &v)
 String to trimmed string, returning true if set, which is when the string is not empty or all isspace. More...
 
std::string convert (const path &v)
 URI path to string. More...
 
bool convert (const std::string &s, path &v)
 String to URI path, returning true if set, which is when the string is not empty or all isspace. More...
 
bool decodeAndConcate (std::string::const_iterator &f, std::string &s)
 
bool encodeAndConcate (std::string::const_iterator &f, std::string &s)
 
bool isspaces (const char *s)
 Test if string is empty or all isspace. More...
 
std::ostream & operator<< (std::ostream &os, const scheme &v)
 Stream out URI scheme. More...
 
std::ostream & operator<< (std::ostream &os, const ip_address &v)
 Stream out IP address. More...
 
std::ostream & operator<< (std::ostream &os, const domain_name &v)
 Stream out domain name. More...
 
std::ostream & operator<< (std::ostream &os, const fragment &v)
 Stream out fragment encoding. More...
 
std::ostream & operator<< (std::ostream &os, const ipv6_address &v)
 Stream out IP v6 address. More...
 
std::ostream & operator<< (std::ostream &os, const authority &v)
 Stream out URI authority. More...
 
std::ostream & operator<< (std::ostream &os, const query &v)
 Stream out query encoding. More...
 
std::ostream & operator<< (std::ostream &os, const path &v)
 Stream out path encoding. More...
 
std::ostream & operator<< (std::ostream &os, const uri &v)
 Stream out URI encoding. More...
 
bool parse (std::string::const_iterator &first, std::string::const_iterator last, scheme &v, char *endc=0)
 Parse URI scheme, returning whether found or not and advancing first and setting scheme and end char if found. More...
 
bool parse (std::string::const_iterator &first, std::string::const_iterator last, fragment &v, std::string *errs=0)
 Parse URI fragment, returning whether found or not and advancing first and setting fragment if found. More...
 
bool parse (std::string::const_iterator &first, std::string::const_iterator last, ip_address &v)
 Parse IP address, returning whether found or not and advancing first and setting address if found. More...
 
bool parse (std::string::const_iterator &first, std::string::const_iterator last, domain_name &v)
 Parse domain name, returning whether found or not and advancing first and setting name if found. More...
 
bool parse (std::string::const_iterator &first, std::string::const_iterator last, uri &v, std::string *errs=0)
 Parse URI, returning whether found or not and advancing first and setting URI if found. More...
 
bool parse (std::string::const_iterator &first, std::string::const_iterator last, query &v, std::string *errs=0)
 Parse URI query, returning whether found or not and advancing first and setting query if found. More...
 
bool parse (std::string::const_iterator &first, std::string::const_iterator last, unsigned short &v)
 
bool parse (std::string::const_iterator &first, std::string::const_iterator last, ipv6_address &v)
 Parse IP v6 address, returning whether found or not and advancing first and setting address if found. More...
 
bool parse (std::string::const_iterator &first, std::string::const_iterator last, authority &v)
 Parse URI authority, returning whether found or not and advancing first and setting authority if found. More...
 
bool parse (std::string::const_iterator &first, std::string::const_iterator last, path &v, std::string *errs=0)
 Parse URI path, returning whether found or not and advancing first and setting path if found. More...
 
bool parse_hex (const std::string &s, size_t pos, char &chr)
 Parse hex chars at pos, returning success, and set the char and advance first on success. More...
 
bool parseLoginPassword (std::string::const_iterator &first, std::string::const_iterator last, authority &v)
 

Function Documentation

void TECOMMONEXPORT te::common::uri::append_hex ( char  v,
std::string &  s 
)

Convert the char v to hex and add the 2 chars to the end of s.

Definition at line 206 of file utils.cpp.

Referenced by te::common::uri::urisyn::encode().

std::string te::common::uri::convert ( const char *  v)
inline

cstring to string

Definition at line 26 of file utils.h.

std::string TECOMMONEXPORT te::common::uri::convert ( bool  v)

bool to string, true="1", false="0"

Definition at line 42 of file utils.cpp.

std::string TECOMMONEXPORT te::common::uri::convert ( int  v)

int to string

Definition at line 43 of file utils.cpp.

References stringstream_convert().

std::string TECOMMONEXPORT te::common::uri::convert ( unsigned int  v)

uint to string

Definition at line 44 of file utils.cpp.

References stringstream_convert().

std::string TECOMMONEXPORT te::common::uri::convert ( long int  v)

long int to string

Definition at line 45 of file utils.cpp.

References stringstream_convert().

std::string TECOMMONEXPORT te::common::uri::convert ( unsigned long int  v)

unsigned long int to string

Definition at line 46 of file utils.cpp.

References stringstream_convert().

std::string TECOMMONEXPORT te::common::uri::convert ( long long int  v)

long long int to string

Definition at line 47 of file utils.cpp.

References stringstream_convert().

std::string TECOMMONEXPORT te::common::uri::convert ( unsigned long long int  v)

unsigned long long int to string

Definition at line 48 of file utils.cpp.

References stringstream_convert().

std::string TECOMMONEXPORT te::common::uri::convert ( double  v)

double to string

Definition at line 49 of file utils.cpp.

References stringstream_convert().

std::string TECOMMONEXPORT te::common::uri::convert ( const std::string &  v)

string to trimmed string

Definition at line 50 of file utils.cpp.

bool TECOMMONEXPORT te::common::uri::convert ( const std::string &  s,
bool &  v 
)

String to bool, returning true if set, which is when the string is not empty or all isspace.

isspace before and/or after value OK. The following, and their uppercase, qualify as true: 1, 't', "true", 'y', "yes", "on". Their complements are considered false, and all else error.

Exceptions
std::invalid_argumenton conversion error

Definition at line 51 of file utils.cpp.

bool TECOMMONEXPORT te::common::uri::convert ( const std::string &  s,
int &  v 
)

String to int, returning true if set, which is when the string is not empty or all isspace.

isspace before and/or after value OK.

Exceptions
std::invalid_argumenton conversion error

Definition at line 69 of file utils.cpp.

References isspaces().

bool TECOMMONEXPORT te::common::uri::convert ( const std::string &  s,
unsigned int &  v 
)

String to unsigned int, returning true if set, which is when the string is not empty or all isspace.

isspace before and/or after value OK.

Exceptions
std::invalid_argumenton conversion error

Definition at line 86 of file utils.cpp.

References isspaces().

bool TECOMMONEXPORT te::common::uri::convert ( const std::string &  s,
unsigned long int &  v 
)

String to size_t, returning true if set, which is when the string is not empty or all isspace.

isspace before and/or after value OK.

Exceptions
std::invalid_argumenton conversion error

Definition at line 103 of file utils.cpp.

References convert().

bool TECOMMONEXPORT te::common::uri::convert ( const std::string &  s,
long long int &  v 
)

String to long long int, returning true if set, which is when the string is not empty or all isspace.

isspace before and/or after value OK.

Exceptions
std::invalid_argumenton conversion error

Definition at line 112 of file utils.cpp.

References isspaces().

bool TECOMMONEXPORT te::common::uri::convert ( const std::string &  s,
unsigned long long int &  v 
)

String to unsigned long long int, returning true if set, which is when the string is not empty or all isspace.

isspace before and/or after value OK.

Exceptions
std::invalid_argumenton conversion error

Definition at line 129 of file utils.cpp.

References isspaces().

bool TECOMMONEXPORT te::common::uri::convert ( const std::string &  s,
double &  v 
)

String to double, returning true if set, which is when the string is not empty or all isspace.

isspace before and/or after value OK.

Exceptions
std::invalid_argumenton conversion error

Definition at line 152 of file utils.cpp.

References isspaces().

bool TECOMMONEXPORT te::common::uri::convert ( const std::string &  s,
std::string &  v 
)

String to trimmed string, returning true if set, which is when the string is not empty or all isspace.

Definition at line 169 of file utils.cpp.

References isspaces().

bool TECOMMONEXPORT te::common::uri::convert ( const std::string &  s,
path v 
)

String to URI path, returning true if set, which is when the string is not empty or all isspace.

isspace before and/or after value OK.

Exceptions
std::invalid_argumenton conversion error

Definition at line 220 of file path.cpp.

References isspaces().

bool te::common::uri::decodeAndConcate ( std::string::const_iterator &  f,
std::string &  s 
)

Definition at line 261 of file authority.cpp.

Referenced by parseLoginPassword().

bool te::common::uri::encodeAndConcate ( std::string::const_iterator &  f,
std::string &  s 
)
bool TECOMMONEXPORT te::common::uri::isspaces ( const char *  s)

Test if string is empty or all isspace.

Definition at line 175 of file utils.cpp.

Referenced by convert().

std::ostream& te::common::uri::operator<< ( std::ostream &  os,
const scheme v 
)
inline

Stream out URI scheme.

Definition at line 57 of file scheme.h.

References te::common::uri::scheme::string().

std::ostream& te::common::uri::operator<< ( std::ostream &  os,
const ip_address v 
)
inline

Stream out IP address.

Definition at line 64 of file ip_address.h.

std::ostream& te::common::uri::operator<< ( std::ostream &  os,
const domain_name v 
)
inline

Stream out domain name.

Definition at line 64 of file domain_name.h.

References te::common::uri::domain_name::string().

std::ostream& te::common::uri::operator<< ( std::ostream &  os,
const fragment v 
)
inline

Stream out fragment encoding.

Definition at line 69 of file fragment.h.

References te::common::uri::fragment::encoding().

std::ostream& te::common::uri::operator<< ( std::ostream &  os,
const ipv6_address v 
)
inline

Stream out IP v6 address.

Definition at line 76 of file ipv6_address.h.

References te::common::uri::ipv6_address::write().

std::ostream& te::common::uri::operator<< ( std::ostream &  os,
const authority v 
)
inline

Stream out URI authority.

Definition at line 95 of file authority.h.

std::ostream& te::common::uri::operator<< ( std::ostream &  os,
const query v 
)
inline

Stream out query encoding.

Definition at line 110 of file query.h.

References te::common::uri::query::encoding().

std::ostream& te::common::uri::operator<< ( std::ostream &  os,
const path v 
)
inline

Stream out path encoding.

Definition at line 138 of file path.h.

References te::common::uri::path::encoding().

std::ostream& te::common::uri::operator<< ( std::ostream &  os,
const uri v 
)
inline

Stream out URI encoding.

Definition at line 153 of file uri.h.

bool TECOMMONEXPORT te::common::uri::parse ( std::string::const_iterator &  first,
std::string::const_iterator  last,
scheme v,
char *  endc = 0 
)

Parse URI scheme, returning whether found or not and advancing first and setting scheme and end char if found.

Does not skip leading space.

Definition at line 39 of file scheme.cpp.

References te::common::uri::urisyn::parse(), te::common::uri::urisyn::SCHEME_TRAITS, and te::common::uri::scheme::string_.

bool TECOMMONEXPORT te::common::uri::parse ( std::string::const_iterator &  first,
std::string::const_iterator  last,
fragment v,
std::string *  errs = 0 
)

Parse URI fragment, returning whether found or not and advancing first and setting fragment if found.

Does not skip leading space.

If errs is specified the following take place:

  • Errors in decoding the string do not cause an immediate false return and and error message is reported in the error string errs. The string is used without decoding (i.e. assumes an unencoded '').

Definition at line 42 of file fragment.cpp.

References te::common::uri::urisyn::decode(), te::common::uri::fragment::empty(), te::common::uri::urisyn::FRAGMENT_TRAITS, te::common::uri::urisyn::parse(), and te::common::uri::fragment::string_.

bool TECOMMONEXPORT te::common::uri::parse ( std::string::const_iterator &  first,
std::string::const_iterator  last,
ip_address v 
)

Parse IP address, returning whether found or not and advancing first and setting address if found.

Does not skip leading space.

Definition at line 51 of file ip_address.cpp.

References te::common::uri::ip_address::octets_.

bool TECOMMONEXPORT te::common::uri::parse ( std::string::const_iterator &  first,
std::string::const_iterator  last,
domain_name v 
)

Parse domain name, returning whether found or not and advancing first and setting name if found.

Does not skip leading space.

Definition at line 64 of file domain_name.cpp.

References te::common::uri::domain_name::string_.

bool TECOMMONEXPORT te::common::uri::parse ( std::string::const_iterator &  first,
std::string::const_iterator  last,
uri v,
std::string *  errs = 0 
)

Parse URI, returning whether found or not and advancing first and setting URI if found.

Does not skip leading space.

If errs is specified parsing is more lax allowing decoding and other errors and setting errs with the error messages. See the individual component parse functions for details.

Definition at line 73 of file uri.cpp.

References te::common::uri::urisyn::AUTHORITY_TRAITS, te::common::uri::urisyn::FRAGMENT_TRAITS, parse(), and te::common::uri::urisyn::QUERY_TRAITS.

bool TECOMMONEXPORT te::common::uri::parse ( std::string::const_iterator &  first,
std::string::const_iterator  last,
query v,
std::string *  errs = 0 
)

Parse URI query, returning whether found or not and advancing first and setting query if found.

Does not skip leading space.

If errs is specified the following take place:

  • Errors in parsing subcomponents, after the first, do not cause an immediate false return and errors messages are reported in the error string errs.
  • Errors are handled as follows:
    • Key-value pairs with an empty key are ignored.
    • Keys with missing '=' are ignored.
    • Errors decoding a key or value result in no decoding at all (i.e. assumes an unencoded '').

Definition at line 87 of file query.cpp.

References convert(), te::common::uri::urisyn::CVAL, te::common::uri::urisyn::decode(), and te::common::uri::urisyn::QUERY_TRAITS.

bool te::common::uri::parse ( std::string::const_iterator &  first,
std::string::const_iterator  last,
unsigned short &  v 
)

Definition at line 103 of file ipv6_address.cpp.

bool TECOMMONEXPORT te::common::uri::parse ( std::string::const_iterator &  first,
std::string::const_iterator  last,
ipv6_address v 
)

Parse IP v6 address, returning whether found or not and advancing first and setting address if found.

Does not skip leading space.

Definition at line 126 of file ipv6_address.cpp.

References te::common::uri::ipv6_address::hextets_, te::common::uri::ip_address::octets_, parse(), and te::common::uri::ip_address::SEPARATOR_CHAR.

bool TECOMMONEXPORT te::common::uri::parse ( std::string::const_iterator &  first,
std::string::const_iterator  last,
authority v 
)

Parse URI authority, returning whether found or not and advancing first and setting authority if found.

Does not skip leading space.

Definition at line 156 of file authority.cpp.

References te::common::uri::authority::DOMAIN_NAME, te::common::uri::authority::host_, te::common::uri::authority::host_type_, te::common::uri::authority::IP_ADDRESS, te::common::uri::authority::IPV6_ADDRESS, parseLoginPassword(), and te::common::uri::authority::port_.

Referenced by parse().

bool TECOMMONEXPORT te::common::uri::parse ( std::string::const_iterator &  first,
std::string::const_iterator  last,
path v,
std::string *  errs = 0 
)

Parse URI path, returning whether found or not and advancing first and setting path if found.

Does not skip leading space.

If errs is specified the following take place:

  • Errors in decoding segments do not cause an immediate false return and and error message is reported in the error string errs. The segment is used without decoding (i.e. assumes an unencoded '').

Definition at line 169 of file path.cpp.

References te::common::uri::path::absolute_, convert(), te::common::uri::urisyn::decode(), te::common::uri::path::is_directory_, te::common::uri::urisyn::parse(), te::common::uri::urisyn::PATH_TRAITS, and te::common::uri::path::segments_.

bool TECOMMONEXPORT te::common::uri::parse_hex ( const std::string &  s,
size_t  pos,
char &  chr 
)

Parse hex chars at pos, returning success, and set the char and advance first on success.

Definition at line 181 of file utils.cpp.

Referenced by te::common::uri::urisyn::decode().

bool te::common::uri::parseLoginPassword ( std::string::const_iterator &  first,
std::string::const_iterator  last,
authority v 
)