dodo  0.0.1
A C++ library to create containerized Linux services
dodo::network::URI Class Reference

Uniform Resource Identifier. More...

#include <uri.hpp>

Collaboration diagram for dodo::network::URI:

Public Member Functions

 URI ()
 Construct an empty URI. More...
 
 URI (const std::string &scheme, const std::string &userinfo, const std::string &host, const std::string &port, const std::string &path, const std::string &query, const std::string &fragment)
 Construct an URI from iits components. More...
 
 URI (const URI &uri)
 Copy constructor. More...
 
 ~URI ()
 Desctructor. More...
 
std::string asString () const
 Return the URI as a std::string. More...
 
std::string getFragment () const
 Return the fragment std::string. More...
 
std::string getHost () const
 Return the host std::string. More...
 
std::string getPath () const
 Return the path std::string. More...
 
std::string getPort () const
 Return the port std::string. More...
 
std::string getQuery () const
 Return the query std::string. More...
 
std::string getScheme () const
 Return the URI scheme std::string. More...
 
std::string getUserInfo () const
 Return the user-info std::string. More...
 
bool operator!= (const URI &uri)
 Inequality operator. More...
 
bool operator< (const URI &uri)
 Ordering operator. More...
 
URIoperator= (const URI &uri)
 Assignment operator. More...
 
bool operator== (const URI &uri)
 Equality operator. More...
 
bool parse (const std::string &s, size_t &idxfail)
 Parse the string as an URI. More...
 
void setFragment (const std::string &fragment)
 Set the URI fragment. More...
 
void setHost (const std::string &host)
 Set the URI host. More...
 
void setPath (const std::string &path)
 Set the URI path. More...
 
void setPort (const std::string &port)
 Set the URI port. More...
 
void setQuery (const std::string &query)
 Set the URI query. More...
 
void setScheme (const std::string &scheme)
 Set the URI scheme. More...
 
void setUserInfo (const std::string &userinfo)
 Set the URI user-info. More...
 

Private Types

enum  ParseState {
  psSchemeStart, psSchemeEnd, psAuthorityStart, psUserInfoEnd,
  psHostStart, psHostEnd, psPortStart, psPortEnd,
  psPathStart, psPathEnd, psQueryStart, psQueryEnd,
  psFragmentStart, psTCP6Start, psPCTEncoded, psError,
  psDone
}
 States for the parsingg automaton. More...
 

Private Member Functions

void reset ()
 Reste all data to empty strings. More...
 
bool verifyOctetChar (char c)
 Check if c is a valid Octet. More...
 
bool verifyPathChar (char c)
 Check if c is a valid Path char. More...
 
bool verifyQueryFragmentChar (char c)
 Check if c is a valid Fragment char. More...
 
bool verifySchemeChar (char c)
 Check if c is a valid Scheme char. More...
 
bool verifyTCP6Char (char c)
 Check if c is a valid TCP6 address char. More...
 
bool verifyUserInfoHostChar (char c)
 Check if c is a valid UserInfo or host char. More...
 

Private Attributes

std::string fragment_
 The fragment. More...
 
std::string host_
 The host. More...
 
std::string path_
 The path. More...
 
std::string port_
 The port. More...
 
std::string query_
 The query. More...
 
std::string scheme_
 The scheme. More...
 
std::string userinfo_
 The userinfo. More...
 

Detailed Description

Uniform Resource Identifier.

See also
https://en.wikipedia.org/wiki/Uniform_Resource_Identifier

Definition at line 36 of file uri.hpp.

Member Enumeration Documentation

◆ ParseState

States for the parsingg automaton.

Definition at line 243 of file uri.hpp.

Constructor & Destructor Documentation

◆ URI() [1/3]

dodo::network::URI::URI ( )
inline

Construct an empty URI.

Definition at line 42 of file uri.hpp.

References reset().

Here is the call graph for this function:

◆ URI() [2/3]

dodo::network::URI::URI ( const std::string &  scheme,
const std::string &  userinfo,
const std::string &  host,
const std::string &  port,
const std::string &  path,
const std::string &  query,
const std::string &  fragment 
)
inline

Construct an URI from iits components.

Parameters
schemeThe scheme.
userinfoThe userinfo.
hostThe host.
portThe port.
pathThe path.
queryThe query.
fragmentThe fragment.

Definition at line 54 of file uri.hpp.

◆ URI() [3/3]

dodo::network::URI::URI ( const URI uri)
inline

Copy constructor.

Parameters
uriThe URI to copy.

Definition at line 73 of file uri.hpp.

◆ ~URI()

dodo::network::URI::~URI ( )
inline

Desctructor.

Definition at line 78 of file uri.hpp.

Member Function Documentation

◆ asString()

std::string dodo::network::URI::asString ( ) const

Return the URI as a std::string.

Returns
the std::string representation of the URI.

Definition at line 43 of file uri.cpp.

References fragment_, host_, path_, port_, query_, scheme_, and userinfo_.

◆ getFragment()

std::string dodo::network::URI::getFragment ( ) const
inline

Return the fragment std::string.

Returns
the fragment of the URI.

Definition at line 171 of file uri.hpp.

References fragment_.

◆ getHost()

std::string dodo::network::URI::getHost ( ) const
inline

Return the host std::string.

Returns
the host of the URI.

Definition at line 123 of file uri.hpp.

References host_.

◆ getPath()

std::string dodo::network::URI::getPath ( ) const
inline

Return the path std::string.

Returns
the path of the URI.

Definition at line 147 of file uri.hpp.

References path_.

◆ getPort()

std::string dodo::network::URI::getPort ( ) const
inline

Return the port std::string.

Returns
the port of the URI.

Definition at line 135 of file uri.hpp.

References port_.

◆ getQuery()

std::string dodo::network::URI::getQuery ( ) const
inline

Return the query std::string.

Returns
the query of the URI.

Definition at line 159 of file uri.hpp.

References query_.

◆ getScheme()

std::string dodo::network::URI::getScheme ( ) const
inline

Return the URI scheme std::string.

Returns
the scheme of the URI.

Definition at line 99 of file uri.hpp.

References scheme_.

◆ getUserInfo()

std::string dodo::network::URI::getUserInfo ( ) const
inline

Return the user-info std::string.

Returns
the user-info of the URI.

Definition at line 111 of file uri.hpp.

References userinfo_.

◆ operator!=()

bool dodo::network::URI::operator!= ( const URI uri)
inline

Inequality operator.

Parameters
uriThe URI to compare to.
Returns
true if the URIs are unequal.

Definition at line 215 of file uri.hpp.

References fragment_, host_, path_, port_, query_, scheme_, and userinfo_.

◆ operator<()

bool dodo::network::URI::operator< ( const URI uri)
inline

Ordering operator.

Parameters
uriThe URI to compare to.
Returns
true if this URI has lower order.

Definition at line 230 of file uri.hpp.

References fragment_, host_, path_, port_, query_, scheme_, and userinfo_.

◆ operator=()

URI& dodo::network::URI::operator= ( const URI uri)
inline

Assignment operator.

Parameters
uriThe URI to assign.
Returns
a reference to this URI.

Definition at line 184 of file uri.hpp.

References fragment_, host_, path_, port_, query_, scheme_, and userinfo_.

◆ operator==()

bool dodo::network::URI::operator== ( const URI uri)
inline

Equality operator.

Parameters
uriThe URI to compare to.
Returns
true if the URIs are equal.

Definition at line 200 of file uri.hpp.

References fragment_, host_, path_, port_, query_, scheme_, and userinfo_.

◆ parse()

bool dodo::network::URI::parse ( const std::string &  s,
size_t &  idxfail 
)

Parse the string as an URI.

Rteurn false and set idxfail to the failing char if the pasre fails, true if the pasre succeeds.

Parameters
sThe string to parse
idxfailIf parse fails, the index of the failing character
Returns
true if the pasre was successful.

Definition at line 109 of file uri.cpp.

References fragment_, host_, path_, port_, query_, reset(), scheme_, userinfo_, verifyPathChar(), verifyQueryFragmentChar(), verifySchemeChar(), verifyTCP6Char(), and verifyUserInfoHostChar().

Here is the call graph for this function:

◆ reset()

void dodo::network::URI::reset ( )
private

Reste all data to empty strings.

Definition at line 33 of file uri.cpp.

References fragment_, host_, path_, port_, query_, scheme_, and userinfo_.

Referenced by parse(), and URI().

Here is the caller graph for this function:

◆ setFragment()

void dodo::network::URI::setFragment ( const std::string &  fragment)
inline

Set the URI fragment.

Parameters
fragmentThe fragment to set.

Definition at line 177 of file uri.hpp.

References fragment_.

◆ setHost()

void dodo::network::URI::setHost ( const std::string &  host)
inline

Set the URI host.

Parameters
hostThe host to set.

Definition at line 129 of file uri.hpp.

References host_.

◆ setPath()

void dodo::network::URI::setPath ( const std::string &  path)
inline

Set the URI path.

Parameters
pathThe path to set.

Definition at line 153 of file uri.hpp.

References path_.

◆ setPort()

void dodo::network::URI::setPort ( const std::string &  port)
inline

Set the URI port.

Parameters
portThe port to set.

Definition at line 141 of file uri.hpp.

References port_.

◆ setQuery()

void dodo::network::URI::setQuery ( const std::string &  query)
inline

Set the URI query.

Parameters
queryThe query to set.

Definition at line 165 of file uri.hpp.

References query_.

◆ setScheme()

void dodo::network::URI::setScheme ( const std::string &  scheme)
inline

Set the URI scheme.

Parameters
schemeThe scheme to set.

Definition at line 105 of file uri.hpp.

References scheme_.

◆ setUserInfo()

void dodo::network::URI::setUserInfo ( const std::string &  userinfo)
inline

Set the URI user-info.

Parameters
userinfoThe user-info to set.

Definition at line 117 of file uri.hpp.

References userinfo_.

◆ verifyOctetChar()

bool dodo::network::URI::verifyOctetChar ( char  c)
private

Check if c is a valid Octet.

Parameters
cThe char to check.
Returns
true if the char is ok.

Definition at line 64 of file uri.cpp.

Referenced by verifyUserInfoHostChar().

Here is the caller graph for this function:

◆ verifyPathChar()

bool dodo::network::URI::verifyPathChar ( char  c)
private

Check if c is a valid Path char.

Parameters
cThe char to check.
Returns
true if the char is ok.

Definition at line 94 of file uri.cpp.

References verifyUserInfoHostChar().

Referenced by parse().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ verifyQueryFragmentChar()

bool dodo::network::URI::verifyQueryFragmentChar ( char  c)
private

Check if c is a valid Fragment char.

Parameters
cThe char to check.
Returns
true if the char is ok.

Definition at line 101 of file uri.cpp.

References verifyUserInfoHostChar().

Referenced by parse().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ verifySchemeChar()

bool dodo::network::URI::verifySchemeChar ( char  c)
private

Check if c is a valid Scheme char.

Parameters
cThe char to check.
Returns
true if the char is ok.

Definition at line 56 of file uri.cpp.

Referenced by parse().

Here is the caller graph for this function:

◆ verifyTCP6Char()

bool dodo::network::URI::verifyTCP6Char ( char  c)
private

Check if c is a valid TCP6 address char.

Parameters
cThe char to check.
Returns
true if the char is ok.

Definition at line 73 of file uri.cpp.

Referenced by parse().

Here is the caller graph for this function:

◆ verifyUserInfoHostChar()

bool dodo::network::URI::verifyUserInfoHostChar ( char  c)
private

Check if c is a valid UserInfo or host char.

Parameters
cThe char to check.
Returns
true if the char is ok.

Definition at line 79 of file uri.cpp.

References verifyOctetChar().

Referenced by parse(), verifyPathChar(), and verifyQueryFragmentChar().

Here is the call graph for this function:
Here is the caller graph for this function:

Field Documentation

◆ fragment_

std::string dodo::network::URI::fragment_
private

The fragment.

Definition at line 324 of file uri.hpp.

Referenced by asString(), getFragment(), operator!=(), operator<(), operator=(), operator==(), parse(), reset(), and setFragment().

◆ host_

std::string dodo::network::URI::host_
private

The host.

Definition at line 316 of file uri.hpp.

Referenced by asString(), getHost(), operator!=(), operator<(), operator=(), operator==(), parse(), reset(), and setHost().

◆ path_

std::string dodo::network::URI::path_
private

The path.

Definition at line 320 of file uri.hpp.

Referenced by asString(), getPath(), operator!=(), operator<(), operator=(), operator==(), parse(), reset(), and setPath().

◆ port_

std::string dodo::network::URI::port_
private

The port.

Definition at line 318 of file uri.hpp.

Referenced by asString(), getPort(), operator!=(), operator<(), operator=(), operator==(), parse(), reset(), and setPort().

◆ query_

std::string dodo::network::URI::query_
private

The query.

Definition at line 322 of file uri.hpp.

Referenced by asString(), getQuery(), operator!=(), operator<(), operator=(), operator==(), parse(), reset(), and setQuery().

◆ scheme_

std::string dodo::network::URI::scheme_
private

The scheme.

Definition at line 312 of file uri.hpp.

Referenced by asString(), getScheme(), operator!=(), operator<(), operator=(), operator==(), parse(), reset(), and setScheme().

◆ userinfo_

std::string dodo::network::URI::userinfo_
private

The userinfo.

Definition at line 314 of file uri.hpp.

Referenced by asString(), getUserInfo(), operator!=(), operator<(), operator=(), operator==(), parse(), reset(), and setUserInfo().


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