activemq-cpp-3.6.0
decaf::internal::net::URIHelper Class Reference

Helper class used by the URI classes in encoding and decoding of URI's. More...

#include <src/main/decaf/internal/net/URIHelper.h>

Public Member Functions

 URIHelper (const std::string &unreserved, const std::string &punct, const std::string &reserved, const std::string &someLegal, const std::string &allLegal)
 Setup the URIHelper with values assigned to the various fields that are used in the validation process.
 URIHelper ()
 Sets up the filter strings with sane defaults.
virtual ~URIHelper ()
URIType parseURI (const std::string &uri, bool forceServer)
 Parse the passed in URI.
void validateScheme (const std::string &uri, const std::string &scheme, int index)
 Validate the schema portin of the URI.
void validateSsp (const std::string &uri, const std::string &ssp, std::size_t index)
 Validate that the URI Ssp Segment contains no invalid encodings.
void validateAuthority (const std::string &uri, const std::string &authority, std::size_t index)
 Validate that the URI Authority Segment contains no invalid encodings.
void validatePath (const std::string &uri, const std::string &path, std::size_t index)
 Validate that the URI Path Segment contains no invalid encodings.
void validateQuery (const std::string &uri, const std::string &query, std::size_t index)
 Validate that the URI Query Segment contains no invalid encodings.
void validateFragment (const std::string &uri, const std::string &fragment, std::size_t index)
 Validate that the URI fragment contains no invalid encodings.
URIType parseAuthority (bool forceServer, const std::string &authority)
 determine the host, port and user-info if the authority parses successfully to a server based authority
void validateUserinfo (const std::string &uri, const std::string &userinfo, std::size_t index)
 Check the supplied user info for validity.
bool isValidHost (bool forceServer, const std::string &host)
 distinguish between IPv4, IPv6, domain name and validate it based on its type
bool isValidDomainName (const std::string &host)
 Validates the string past to determine if it is a well formed domain name.
bool isValidIPv4Address (const std::string &host)
 Validate if the host value is a well formed IPv4 address, this is the form XXX.XXX.XXX.XXX were X is any number 0-9.
bool isValidIP6Address (const std::string &ipAddress)
 Determines if the given address is valid according to the IPv6 spec.
bool isValidIP4Word (const std::string &word)
 Check is the string passed contains a Valid IPv4 word, which is an integer in the range of 0 to 255.
bool isValidHexChar (char c)
 Determines if the given char is a valid Hex char.

Detailed Description

Helper class used by the URI classes in encoding and decoding of URI's.

Constructor & Destructor Documentation

decaf::internal::net::URIHelper::URIHelper ( const std::string &  unreserved,
const std::string &  punct,
const std::string &  reserved,
const std::string &  someLegal,
const std::string &  allLegal 
)

Setup the URIHelper with values assigned to the various fields that are used in the validation process.

The defaults are overridden by these values.

Parameters
unreserved- characters not reserved for use.
punct- allowable punctuation symbols.
reserved- characters not allowed for general use in the URI.
someLegal- characters that are legal in certain cases.
allLegal- characters that are always legal.
decaf::internal::net::URIHelper::URIHelper ( )

Sets up the filter strings with sane defaults.

virtual decaf::internal::net::URIHelper::~URIHelper ( )
inlinevirtual

Member Function Documentation

bool decaf::internal::net::URIHelper::isValidDomainName ( const std::string &  host)

Validates the string past to determine if it is a well formed domain name.

Parameters
host- domain name to validate.
Returns
true if host is well formed.
bool decaf::internal::net::URIHelper::isValidHexChar ( char  c)

Determines if the given char is a valid Hex char.

Valid chars are A-F (upper or lower case) and 0-9.

Parameters
c- char to inspect
Returns
true if c is a valid hex char.
bool decaf::internal::net::URIHelper::isValidHost ( bool  forceServer,
const std::string &  host 
)

distinguish between IPv4, IPv6, domain name and validate it based on its type

Parameters
forceServer- true if the forceServer mode should be active.
host- Host string to validate.
Returns
true if the host value if a valid domain name.
Exceptions
URISyntaxExceptionif the host is invalid and forceServer is true.
bool decaf::internal::net::URIHelper::isValidIP4Word ( const std::string &  word)

Check is the string passed contains a Valid IPv4 word, which is an integer in the range of 0 to 255.

Parameters
word- string value to check.
Returns
true if the word is a valid IPv4 word.
bool decaf::internal::net::URIHelper::isValidIP6Address ( const std::string &  ipAddress)

Determines if the given address is valid according to the IPv6 spec.

Parameters
ipAddress- string ip address value to validate.
Returns
true if the address string is valid.
bool decaf::internal::net::URIHelper::isValidIPv4Address ( const std::string &  host)

Validate if the host value is a well formed IPv4 address, this is the form XXX.XXX.XXX.XXX were X is any number 0-9.

and XXX is not greater than 255.

Parameters
host- IPv4 address string to parse.
Returns
true if host is a well formed IPv4 address.
URIType decaf::internal::net::URIHelper::parseAuthority ( bool  forceServer,
const std::string &  authority 
)

determine the host, port and user-info if the authority parses successfully to a server based authority

behavior in error cases: if forceServer is true, throw URISyntaxException with the proper diagnostic messages. if forceServer is false assume this is a registry based uri, and just return leaving the host, port and user-info fields undefined.

and there are some error cases where URISyntaxException is thrown regardless of the forceServer parameter e.g. mal-formed ipv6 address

Parameters
forceServer
authority
Returns
a URIType instance containing the parsed data.
Exceptions
URISyntaxException
URIType decaf::internal::net::URIHelper::parseURI ( const std::string &  uri,
bool  forceServer 
)

Parse the passed in URI.

Parameters
uri- the URI to Parse
forceServer- if true invalid URI data throws an Exception
Returns
a URIType instance containing the parsed data.
Exceptions
URISyntaxExceptionif forceServer is true and the URI is invalid.
void decaf::internal::net::URIHelper::validateAuthority ( const std::string &  uri,
const std::string &  authority,
std::size_t  index 
)

Validate that the URI Authority Segment contains no invalid encodings.

Parameters
uri- the full uri.
authority- the Authority to check.
index- position in the uri where Authority starts.
Exceptions
URISyntaxExceptionif the fragment has errors.
void decaf::internal::net::URIHelper::validateFragment ( const std::string &  uri,
const std::string &  fragment,
std::size_t  index 
)

Validate that the URI fragment contains no invalid encodings.

Parameters
uri- the full uri.
fragment- the fragment to check.
index- position in the uri where fragment starts.
Exceptions
URISyntaxExceptionif the fragment has errors.
void decaf::internal::net::URIHelper::validatePath ( const std::string &  uri,
const std::string &  path,
std::size_t  index 
)

Validate that the URI Path Segment contains no invalid encodings.

Parameters
uri- the full uri.
path- the path to check.
index- position in the uri where path starts.
Exceptions
URISyntaxExceptionif the fragment has errors.
void decaf::internal::net::URIHelper::validateQuery ( const std::string &  uri,
const std::string &  query,
std::size_t  index 
)

Validate that the URI Query Segment contains no invalid encodings.

Parameters
uri- the full uri.
query- the query to check.
index- position in the uri where fragment starts.
Exceptions
URISyntaxExceptionif the fragment has errors.
void decaf::internal::net::URIHelper::validateScheme ( const std::string &  uri,
const std::string &  scheme,
int  index 
)

Validate the schema portin of the URI.

Parameters
uri- the URI to check.
scheme- the schema section of the URI.
index- index in uri where schema starts.
Exceptions
URISyntaxExceptionif the fragment has errors.
void decaf::internal::net::URIHelper::validateSsp ( const std::string &  uri,
const std::string &  ssp,
std::size_t  index 
)

Validate that the URI Ssp Segment contains no invalid encodings.

Parameters
uri- the full uri.
ssp- the SSP to check.
index- position in the uri where Ssp starts.
Exceptions
URISyntaxExceptionif the fragment has errors.
void decaf::internal::net::URIHelper::validateUserinfo ( const std::string &  uri,
const std::string &  userinfo,
std::size_t  index 
)

Check the supplied user info for validity.

Parameters
uri- the uri to parse.
userinfo- supplied user info
index- index into the URI string where the data is located.
Returns
true if valid
Exceptions
URISyntaxExceptionif an error occurs

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