All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
te::common::uri::authority Class Reference

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...
 

Detailed Description

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.

Member Enumeration Documentation

Enumeration.

Enumerator
null 
DOMAIN_NAME 

domain name

IP_ADDRESS 

IP address.

IPV6_ADDRESS 

IP v6 address.

Definition at line 52 of file authority.h.

Constructor & Destructor Documentation

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).

Exceptions
std::invalid_argumentif invalid or empty

Definition at line 43 of file authority.cpp.

References loadDefaultPorts(), and parse.

Member Function Documentation

bool te::common::uri::authority::empty ( ) const
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().

const std::string& te::common::uri::authority::host ( ) const
inline

Get host.

Definition at line 65 of file authority.h.

host_type_e te::common::uri::authority::host_type ( ) const
inline

Get host type.

Definition at line 66 of file authority.h.

bool te::common::uri::authority::is_null ( ) const
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<<().

void te::common::uri::authority::loadDefaultPorts ( )
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().

unsigned short te::common::uri::authority::port ( ) const
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().

void te::common::uri::authority::port ( unsigned short  p)
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

Calculate string.

Definition at line 139 of file authority.cpp.

References operator<<().

Friends And Related Function Documentation

bool TECOMMONEXPORT parse ( std::string::const_iterator &  first,
std::string::const_iterator  last,
authority v 
)
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().

Member Data Documentation

std::string te::common::uri::authority::host_
private

Definition at line 86 of file authority.h.

Referenced by operator<<(), and te::common::uri::parse().

host_type_e te::common::uri::authority::host_type_
private

Definition at line 85 of file authority.h.

Referenced by te::common::uri::parse().

const char te::common::uri::authority::IP_LITERAL_BEGIN_CHAR = '['
static

IP literal begin ('[')

Definition at line 79 of file authority.h.

Referenced by te::common::uri::parse().

const char te::common::uri::authority::IP_LITERAL_END_CHAR = ']'
static

IP literal end (']')

Definition at line 80 of file authority.h.

Referenced by te::common::uri::parse().

std::string te::common::uri::authority::login_
private

Definition at line 88 of file authority.h.

Referenced by getEncodedLogin(), getLogin(), operator<<(), and setLogin().

std::string te::common::uri::authority::password_
private

Definition at line 89 of file authority.h.

Referenced by getEncodedPassword(), getPassword(), operator<<(), and setPassword().

unsigned short te::common::uri::authority::port_
private

Definition at line 87 of file authority.h.

Referenced by operator<<(), te::common::uri::parse(), and setDefaultPort().

const char te::common::uri::authority::PORT_SEPARATOR_CHAR = ':'
static

port separator (':')

Definition at line 81 of file authority.h.

Referenced by operator<<(), and te::common::uri::parse().

std::map< std::string, unsigned short > te::common::uri::authority::protocol2DefaultPort_
staticprivate

Protocol to default port. Added by Lauro.

Definition at line 92 of file authority.h.

Referenced by getDefaultPort(), loadDefaultPorts(), and setDefaultPort().


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