activemq-cpp-3.6.0
|
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. |
Helper class used by the URI classes in encoding and decoding of URI's.
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.
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.
|
inlinevirtual |
bool decaf::internal::net::URIHelper::isValidDomainName | ( | const std::string & | host | ) |
Validates the string past to determine if it is a well formed domain name.
host | - domain name to validate. |
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.
c | - char to inspect |
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
forceServer | - true if the forceServer mode should be active. |
host | - Host string to validate. |
URISyntaxException | if 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.
word | - string value to check. |
bool decaf::internal::net::URIHelper::isValidIP6Address | ( | const std::string & | ipAddress | ) |
Determines if the given address is valid according to the IPv6 spec.
ipAddress | - string ip address value to validate. |
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.
host | - IPv4 address string to parse. |
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
forceServer | |
authority |
URISyntaxException |
Parse the passed in URI.
uri | - the URI to Parse |
forceServer | - if true invalid URI data throws an Exception |
URISyntaxException | if 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.
uri | - the full uri. |
authority | - the Authority to check. |
index | - position in the uri where Authority starts. |
URISyntaxException | if 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.
uri | - the full uri. |
fragment | - the fragment to check. |
index | - position in the uri where fragment starts. |
URISyntaxException | if 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.
uri | - the full uri. |
path | - the path to check. |
index | - position in the uri where path starts. |
URISyntaxException | if 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.
uri | - the full uri. |
query | - the query to check. |
index | - position in the uri where fragment starts. |
URISyntaxException | if 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.
uri | - the URI to check. |
scheme | - the schema section of the URI. |
index | - index in uri where schema starts. |
URISyntaxException | if 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.
uri | - the full uri. |
ssp | - the SSP to check. |
index | - position in the uri where Ssp starts. |
URISyntaxException | if 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.
uri | - the uri to parse. |
userinfo | - supplied user info |
index | - index into the URI string where the data is located. |
URISyntaxException | if an error occurs |