Classes | |
class | Url |
Url manipulation class. More... | |
struct | ViewOptions |
class | UrlBase |
Generic Url base class. More... | |
struct | UrlComponents |
struct | UrlAuthority |
Typedefs | |
typedef BLOCXX_NAMESPACE::COWReference < UrlBase > | UrlRef |
Copy-On-Write Url reference. | |
typedef BLOCXX_NAMESPACE::Map < BLOCXX_NAMESPACE::String, BLOCXX_NAMESPACE::String > | ParamMap |
Enumerations | |
enum | EEncoding { E_ENCODED, E_DECODED } |
Functions | |
BLOCXX_DECLARE_EXCEPTION (Url) | |
BLOCXX_DECLARE_EXCEPTION2 (UrlParsing, UrlException) | |
BLOCXX_DECLARE_EXCEPTION2 (UrlDecoding, UrlException) | |
BLOCXX_DECLARE_EXCEPTION2 (UrlBadComponent, UrlException) | |
BLOCXX_DECLARE_EXCEPTION2 (UrlNotAllowed, UrlException) | |
BLOCXX_DECLARE_EXCEPTION2 (UrlNotSupported, UrlException) | |
BLOCXX_NAMESPACE::String | encode (const BLOCXX_NAMESPACE::String &str, const BLOCXX_NAMESPACE::String &safe="", limal::url::EEncoding eflag=E_DECODED) |
BLOCXX_NAMESPACE::String | encode_buf (const limal::ByteBuffer &buf, const BLOCXX_NAMESPACE::String &safe="", limal::url::EEncoding eflag=E_DECODED) |
BLOCXX_NAMESPACE::String | decode (const BLOCXX_NAMESPACE::String &str) |
limal::ByteBuffer | decode_buf (const BLOCXX_NAMESPACE::String &str, bool allowNUL) |
BLOCXX_NAMESPACE::String | encode_octet (const unsigned char c) |
int | decode_octet (const char *hex) |
BLOCXX_NAMESPACE::StringArray | split (const BLOCXX_NAMESPACE::String &pstr, const BLOCXX_NAMESPACE::String &psep) |
limal::url::ParamMap | split (const BLOCXX_NAMESPACE::String &pstr, const BLOCXX_NAMESPACE::String &psep, const BLOCXX_NAMESPACE::String &vsep, EEncoding eflag=E_ENCODED) |
BLOCXX_NAMESPACE::String | join (const BLOCXX_NAMESPACE::StringArray &parr, const BLOCXX_NAMESPACE::String &psep) |
BLOCXX_NAMESPACE::String | join (const limal::url::ParamMap &pmap, const BLOCXX_NAMESPACE::String &psep, const BLOCXX_NAMESPACE::String &vsep, const BLOCXX_NAMESPACE::String &safe) |
UrlComponents | parse_url_string (const BLOCXX_NAMESPACE::String &url) |
UrlAuthority | parse_url_authority (const BLOCXX_NAMESPACE::String &authority) |
typedef BLOCXX_NAMESPACE ::Map< BLOCXX_NAMESPACE ::String, BLOCXX_NAMESPACE ::String> limal::url::ParamMap |
A parameter map container. A string map, containing key and value pairs parsed from a PathParam- or Query-String.
typedef BLOCXX_NAMESPACE ::COWReference<UrlBase> limal::url::UrlRef |
Copy-On-Write Url reference.
limal::url::BLOCXX_DECLARE_EXCEPTION | ( | Url | ) |
limal::url::BLOCXX_DECLARE_EXCEPTION2 | ( | UrlNotSupported | , | |
UrlException | ||||
) |
limal::url::BLOCXX_DECLARE_EXCEPTION2 | ( | UrlNotAllowed | , | |
UrlException | ||||
) |
limal::url::BLOCXX_DECLARE_EXCEPTION2 | ( | UrlBadComponent | , | |
UrlException | ||||
) |
limal::url::BLOCXX_DECLARE_EXCEPTION2 | ( | UrlDecoding | , | |
UrlException | ||||
) |
limal::url::BLOCXX_DECLARE_EXCEPTION2 | ( | UrlParsing | , | |
UrlException | ||||
) |
BLOCXX_NAMESPACE ::String limal::url::decode | ( | const BLOCXX_NAMESPACE::String & | str | ) |
Decodes a percent-encoded string into a string.
Replaces all occurences of "%<hex><hex>"
in the str
string with the character encoded using the two hexadecimal digits that follows the "%" character.
For example, the encoded string "%40%3F%3D%26%25" will be decoded to "@?=&%".
str | A string to decode. |
UrlDecodingException | if str contains encoded NUL byte. |
limal::ByteBuffer limal::url::decode_buf | ( | const BLOCXX_NAMESPACE::String & | str, | |
bool | allowNUL | |||
) |
Decodes a percent-encoded string into a byte buffer.
Replaces all occurences of "%<hex><hex>"
in the str
string with the character encoded using the two hexadecimal digits that follows the "%" character.
For example, the encoded string "%40%3F%3D%26%25" will be decoded to "@?=&%".
str | An encoded string to decode. | |
allowNUL | A flag, if "%00" (encoded '\0' ) is allowed. |
UrlDecodingException | if allowNUL str contains encoded NUL byte ("%00" ). |
int limal::url::decode_octet | ( | const char * | hex | ) |
Decode one character.
Decode the hex
parameter pointing to (at least) two hexadecimal digits into its character value and return it.
Example:
char *str = "%40"; char *pct = strchr(str, '%'); int chr = pct ? decode_octet(pct+1) : -1; // chr is set to the '@' ASCII character now.
hex | Pointer to two hex characters representing the character value in percent-encoded strings. |
hex
characters or -1 if hex
does not point to two hexadecimal characters. BLOCXX_NAMESPACE ::String limal::url::encode | ( | const BLOCXX_NAMESPACE::String & | str, | |
const BLOCXX_NAMESPACE::String & | safe = "" , |
|||
limal::url::EEncoding | eflag = E_DECODED | |||
) |
Encodes a string using URL percent encoding.
By default, all characters except of "a-zA-Z0-9_.-" will be encoded. Additional characters from the set ":/?#[]@!$&'()*+,;=", that are safe for a URL compoent without encoding, can be specified in the safe
argument.
If the eflag
parameter is set to E_ENCODED, then already encoded substrings will be detected and not encoded a second time.
The following function call will encode the "@" character as "%40", but skip encoding of the "%" character, because the eflag
is set to E_ENCODED and "%ba" is detected as a valid encoded character.
limal::url::encode("foo%bar@localhost", "", E_ENCODED);
With eflag
set to E_DECODED, the "%" character would be encoded as well. The complete encoded string would be "foo%25bar%40localhost".
str | A string to encode. | |
safe | Characters safe to skip in encoding, e.g. "/" for path names. | |
eflag | If to detect and skip already encoded substrings. |
BLOCXX_NAMESPACE ::String limal::url::encode_buf | ( | const limal::ByteBuffer & | buf, | |
const BLOCXX_NAMESPACE::String & | safe = "" , |
|||
limal::url::EEncoding | eflag = E_DECODED | |||
) |
Encodes a byte buffer using URL percent encoding.
For more informations, see encode() function.
buf | A string buffer to encode (binary data). | |
safe | Characters safe to skip in encoding, e.g. "/" for path names. | |
eflag | If to detect and skip already encoded substrings. |
BLOCXX_NAMESPACE ::String limal::url::encode_octet | ( | const unsigned char | c | ) |
Encode one character.
Encode the specified character c
into its "%<hex><hex>"
representation.
c | A character to encode. |
BLOCXX_NAMESPACE ::String limal::url::join | ( | const limal::url::ParamMap & | pmap, | |
const BLOCXX_NAMESPACE::String & | psep, | |||
const BLOCXX_NAMESPACE::String & | vsep, | |||
const BLOCXX_NAMESPACE::String & | safe | |||
) |
Join parameter map to a string.
Creates a string containing all parameter key-value pairs from the parameter map pmap
, that will be joined using the psep
character and the parameter key is separated from the parameter value using the vsep
character. Both, key and value will be automatically encoded.
Usual parameter separators are '&'
for Query- and '
,' for PathParam-Strings. A usual parameter-value separator is '='
for both, Query- and PathParam-Strings.
See encode() function from details about the safe
characters.
pmap | Reference to a parameter map. | |
psep | Separator character to use between key-value pairs. | |
vsep | Separator character to use between keys and values. | |
safe | List of characters to accept without encoding. |
UrlNotSupportedException | if psep or vsep separator is empty. |
BLOCXX_NAMESPACE ::String limal::url::join | ( | const BLOCXX_NAMESPACE::StringArray & | parr, | |
const BLOCXX_NAMESPACE::String & | psep | |||
) |
Join parameter array into a string.
Creates a string containing all substrings from the parr
separated by psep
separator character. The substrings in parr
should be already URL percent encoded and should't contain psep
characters.
Usual parameter separators are '&'
for Query- and '
,' for PathParam-Strings.
parr | Reference to encoded parameter array. | |
psep | Parameter separator character to use. |
UrlAuthority limal::url::parse_url_authority | ( | const BLOCXX_NAMESPACE::String & | authority | ) |
UrlComponents limal::url::parse_url_string | ( | const BLOCXX_NAMESPACE::String & | url | ) |
limal::url::ParamMap limal::url::split | ( | const BLOCXX_NAMESPACE::String & | pstr, | |
const BLOCXX_NAMESPACE::String & | psep, | |||
const BLOCXX_NAMESPACE::String & | vsep, | |||
EEncoding | eflag = E_ENCODED | |||
) |
Split into a parameter map.
Splits a parameter string pstr
into substrings using psep
as separator and then, each substring into key and value pair using vsep
as separator between parameter key and value and adds them to the parameter map pmap
.
If a parameter substring doesn't contain any value separator vsep
, the substring is used as a parameter key and value is set to an empty string.
Usual parameter separators are '&'
for Query- and '
,' for PathParam-Strings. A usual parameter-value separator is '='
for both, Query- and PathParam-Strings.
If the encoding flag eflag
is set to E_DECODED
, then the key and values are dedcoded before they are stored in the map.
pstr | Reference to the PathParam- or Query-String to split. | |
psep | Separator character to split key-value pairs. | |
vsep | Separator character to split key and value. | |
eflag | Flag if the key and value strings should be URL percent decoded before they're stored in the map. |
UrlNotSupportedException | if psep or vsep separator is empty. |
BLOCXX_NAMESPACE ::StringArray limal::url::split | ( | const BLOCXX_NAMESPACE::String & | pstr, | |
const BLOCXX_NAMESPACE::String & | psep | |||
) |
Split into a parameter array.
Splits a parameter string pstr
at psep
characters into an array of substrings.
Usual parameter separators are '&'
for Query- and '
,' for PathParams-Strings.
pstr | Reference to the PathParam- or Query-String to split. | |
psep | Parameter separator character to split at. |
UrlNotSupportedException | if psep separator is empty. |