URI authority component (without userinfo). More...
#include <authority.h>
Public Types | |
enum | host_type_e { null, DOMAIN_NAME, IP_ADDRESS, IPV6_ADDRESS } |
Enumeration. More... | |
Public Member Functions | |
authority () | |
Construct. More... | |
authority (const std::string &v) | |
Construct from string. More... | |
bool | empty () const |
Test if null/empty. More... | |
int | getDefaultPort (const std::string &scheme) |
Get Default port for the protocol. Added by Lauro. More... | |
std::string | getEncodedLogin () const |
Get endoded login. Added by Lauro. More... | |
std::string | getEncodedPassword () const |
Get encoded password. Added by Lauro. More... | |
std::string | getLogin () const |
Get login. Added by Lauro. More... | |
std::string | getPassword () const |
Get password. Added by Lauro. More... | |
const std::string & | host () const |
Get host. More... | |
host_type_e | host_type () const |
Get host type. More... | |
bool | is_null () const |
Test if null/empty. More... | |
std::ostream & | operator<< (std::ostream &os) const |
Stream out. More... | |
unsigned short | port () const |
Get port (0 if none). More... | |
void | port (unsigned short p) |
Set port. Added by Lauro. More... | |
void | setDefaultPort (const std::string &scheme) |
Set Default port for the protocol. Added by Lauro. More... | |
void | setLogin (const std::string &login) |
Set login. Added by Lauro. More... | |
void | setPassword (const std::string &password) |
Set password. Added by Lauro. More... | |
std::string | string () const |
Calculate string. More... | |
Static Public Attributes | |
static const char | IP_LITERAL_BEGIN_CHAR = '[' |
IP literal begin ('[') More... | |
static const char | IP_LITERAL_END_CHAR = ']' |
IP literal end (']') More... | |
static const char | PORT_SEPARATOR_CHAR = ':' |
port separator (':') More... | |
Private Member Functions | |
void | loadDefaultPorts () |
Private Attributes | |
std::string | host_ |
host_type_e | host_type_ |
std::string | login_ |
std::string | password_ |
unsigned short | port_ |
Static Private Attributes | |
static std::map< std::string, unsigned short > | protocol2DefaultPort_ |
Protocol to default port. Added by Lauro. More... | |
Friends | |
bool TECOMMONEXPORT | 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... | |
URI authority component (without userinfo).
The authority string and the type of the authority is stored in this object. The syntax is checked with the corresponding type. For example if this indicates DOMAIN_NAME
then the string can be parsed as a domain_name
object.
Syntax: This does not support userinfo nor IPvFuture. Requires domain-name instead of reg-name.
authority = host [ ":" port ] host = IP-literal | IPv4address | domain-name IP-literal = "[" IPv6address "]" port = *DIGIT
Definition at line 49 of file authority.h.
Enumeration.
Enumerator | |
---|---|
null | |
DOMAIN_NAME |
domain name |
IP_ADDRESS |
IP address. |
IPV6_ADDRESS |
IP v6 address. |
Definition at line 52 of file authority.h.
te::common::uri::authority::authority | ( | ) |
Construct.
Definition at line 42 of file authority.cpp.
References loadDefaultPorts().
Referenced by te::common::URL::getEncodedString(), te::common::URL::getString(), te::common::URL::setHost(), te::common::URL::setHostPort(), te::common::URL::setLogin(), and te::common::URL::setPassword().
te::common::uri::authority::authority | ( | const std::string & | v | ) |
Construct from string.
This test to be sure host is of a valid form (see class description).
std::invalid_argument | if invalid or empty |
Definition at line 43 of file authority.cpp.
References loadDefaultPorts(), and parse.
|
inline |
Test if null/empty.
Definition at line 63 of file authority.h.
int te::common::uri::authority::getDefaultPort | ( | const std::string & | scheme | ) |
Get Default port for the protocol. Added by Lauro.
Definition at line 93 of file authority.cpp.
References protocol2DefaultPort_.
Referenced by te::common::URL::getEncodedString(), and te::common::URL::getString().
std::string te::common::uri::authority::getEncodedLogin | ( | ) | const |
Get endoded login. Added by Lauro.
Definition at line 105 of file authority.cpp.
References te::common::uri::encodeAndConcate(), and login_.
Referenced by te::common::URL::getEncodedString().
std::string te::common::uri::authority::getEncodedPassword | ( | ) | const |
Get encoded password. Added by Lauro.
Definition at line 125 of file authority.cpp.
References te::common::uri::encodeAndConcate(), and password_.
Referenced by te::common::URL::getEncodedString().
std::string te::common::uri::authority::getLogin | ( | ) | const |
Get login. Added by Lauro.
Definition at line 102 of file authority.cpp.
References login_.
Referenced by te::common::URL::getString().
std::string te::common::uri::authority::getPassword | ( | ) | const |
Get password. Added by Lauro.
Definition at line 122 of file authority.cpp.
References password_.
Referenced by te::common::URL::getString().
|
inline |
Get host.
Definition at line 65 of file authority.h.
|
inline |
Get host type.
Definition at line 66 of file authority.h.
|
inline |
Test if null/empty.
Definition at line 64 of file authority.h.
Referenced by te::common::uri::uri::is_null(), and te::common::uri::uri::operator<<().
|
private |
Definition at line 49 of file authority.cpp.
References null, protocol2DefaultPort_, and TE_PROTOCOL_DEFAULT_PORTS_FILE.
Referenced by authority().
std::ostream & te::common::uri::authority::operator<< | ( | std::ostream & | os | ) | const |
Stream out.
Definition at line 144 of file authority.cpp.
References host_, login_, password_, port_, and PORT_SEPARATOR_CHAR.
Referenced by string().
|
inline |
Get port (0 if none).
Definition at line 67 of file authority.h.
Referenced by te::common::URL::setHost(), and te::common::URL::setHostPort().
|
inline |
Set port. Added by Lauro.
Definition at line 68 of file authority.h.
void te::common::uri::authority::setDefaultPort | ( | const std::string & | scheme | ) |
Set Default port for the protocol. Added by Lauro.
Definition at line 87 of file authority.cpp.
References port_, and protocol2DefaultPort_.
Referenced by te::common::URL::setHost().
void te::common::uri::authority::setLogin | ( | const std::string & | login | ) |
Set login. Added by Lauro.
Definition at line 99 of file authority.cpp.
References login_.
Referenced by te::common::uri::parseLoginPassword(), and te::common::URL::setLogin().
void te::common::uri::authority::setPassword | ( | const std::string & | password | ) |
Set password. Added by Lauro.
Definition at line 119 of file authority.cpp.
References password_.
Referenced by te::common::uri::parseLoginPassword(), and te::common::URL::setPassword().
std::string te::common::uri::authority::string | ( | ) | const |
|
friend |
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.
Referenced by authority().
|
private |
Definition at line 86 of file authority.h.
Referenced by operator<<(), and te::common::uri::parse().
|
private |
Definition at line 85 of file authority.h.
Referenced by te::common::uri::parse().
|
static |
IP literal begin ('[')
Definition at line 79 of file authority.h.
Referenced by te::common::uri::parse().
|
static |
IP literal end (']')
Definition at line 80 of file authority.h.
Referenced by te::common::uri::parse().
|
private |
Definition at line 88 of file authority.h.
Referenced by getEncodedLogin(), getLogin(), operator<<(), and setLogin().
|
private |
Definition at line 89 of file authority.h.
Referenced by getEncodedPassword(), getPassword(), operator<<(), and setPassword().
|
private |
Definition at line 87 of file authority.h.
Referenced by operator<<(), te::common::uri::parse(), and setDefaultPort().
|
static |
port separator (':')
Definition at line 81 of file authority.h.
Referenced by operator<<(), and te::common::uri::parse().
|
staticprivate |
Protocol to default port. Added by Lauro.
Definition at line 92 of file authority.h.
Referenced by getDefaultPort(), loadDefaultPorts(), and setDefaultPort().