nlib
|
The class for parsing URIs that use the http and https schemes, and for constructing URI strings. More...
#include "nn/nlib/HttpStyleUri.h"
Public Types | |
typedef std::pair< const char *, const char * > | KeyValue |
The type that stores query keys and values. | |
Public Member Functions | |
HttpStyleUri () noexcept | |
Instantiates the object with default parameters (default constructor). Initializes an object. | |
bool | FromUri (const Uri &uri) noexcept |
Converts from a URI object. More... | |
bool | ToUri (Uri *uri) const noexcept |
Converts to a URI object. More... | |
bool | Parse (const char *str) noexcept |
Parses URIs. More... | |
bool | ComposeString (char *buf, size_t size) const noexcept |
Writes a URI string. More... | |
template<size_t N> | |
bool | ComposeString (char(&buf)[N]) const noexcept |
Calls ComposeString(buf, N) . | |
bool | SetScheme (const char *scheme) noexcept |
Sets the scheme. More... | |
bool | SetUserInfo (const char *userinfo) noexcept |
Sets the user information. More... | |
bool | SetHost (const char *host) noexcept |
Sets the hostname. It does not need to be percent-encoded. More... | |
bool | SetPort (int port) noexcept |
Sets the port number. More... | |
bool | SetPath (const char *path) noexcept |
Sets a path. More... | |
bool | SetQuery (const char *query) noexcept |
Sets a query based on a query string. More... | |
bool | SetFragment (const char *fragment) noexcept |
Sets a fragment string. More... | |
bool | AddQuery (const char *key, const char *value) noexcept |
Adds a key and value to a query. More... | |
const char * | GetScheme () const noexcept |
Gets the name of the URI scheme. The name is either http or https . More... | |
const char * | GetUserInfo () const noexcept |
Gets the user information. More... | |
const char * | GetHost () const noexcept |
Gets the hostname. More... | |
int | GetPort () const noexcept |
Gets the port number. More... | |
size_t | GetNumSegment () const noexcept |
Gets the number of stored segments. More... | |
const char * | GetSegment (size_t i) const noexcept |
Specifies an index and gets a segment. More... | |
bool | IsPathDirectory () const noexcept |
Gets whether the path is in the form of a directory path. More... | |
const char * | GetQueryValue (const char *key) const noexcept |
Specifies a key and gets a value. If not found, returns NULL . More... | |
size_t | GetNumQuery () const noexcept |
Gets the value corresponding to the key. If not found, returns NULL . More... | |
const KeyValue * | GetQueryKeyValue (size_t i) const noexcept |
Specifies an index and gets a key/value pair. If not found, returns NULL . More... | |
const char * | GetFragment () const noexcept |
Gets a fragment string. More... | |
bool | AddBaseUri (const Uri &relative, const HttpStyleUri &base) noexcept |
Resolves the relative path using the base URI. More... | |
void | Reset () noexcept |
Initializes (resets) an object. | |
The class for parsing URIs that use the http and https schemes, and for constructing URI strings.
/test/../../../a/b/c
would be normalized to /a/b/c
and then divided into segments and stored. The percent-encoded characters in each segment are decoded. key=value
pairs connected using the ampersand (&
). The query string is stored in order of the ampersand signs (&
that delimit the key/value pairs and the first equal sign (=
) in each component that separates key
and value
. If there are duplicate key
values, they are stored that way. Any percent-encoded characters in key
and value
are decoded. Definition at line 13 of file HttpStyleUri.h.
|
noexcept |
Resolves the relative path using the base URI.
[in] | relative | A relative path. |
[in] | base | A base URI. |
true
when successful.
|
inlinenoexcept |
Adds a key and value to a query.
[in] | key | A key. |
[in] | value | A value. |
true
when successful.Definition at line 34 of file HttpStyleUri.h.
|
noexcept |
Writes a URI string.
[out] | buf | The pointer to the buffer to which the string was written. |
[in] | size | The size of the buffer. |
true
when successful.ToUri
and Uri::ComposeString
functions.
|
noexcept |
Converts from a URI object.
[in] | uri | The reference to the URI object. |
true
when successful.
|
inlinenoexcept |
Gets a fragment string.
NULL
pointer or an empty string. The meanings are slightly different. NULL
(http://example.com/). Definition at line 59 of file HttpStyleUri.h.
|
inlinenoexcept |
|
inlinenoexcept |
Gets the value corresponding to the key. If not found, returns NULL
.
Definition at line 55 of file HttpStyleUri.h.
|
inlinenoexcept |
Gets the number of stored segments.
Definition at line 43 of file HttpStyleUri.h.
|
inlinenoexcept |
|
inlinenoexcept |
Specifies an index and gets a key/value pair. If not found, returns NULL
.
[in] | i | An index. |
key
and value
are completely percent-decoded. key
or value
might be NULL
or an empty string. This reflects small differences in the query string, as shown below. ?...&&...
, key = NULL
and value = NULL
. <.i> If the query string is something like ?...&=&...
, key = ""
and value = ""
. Definition at line 56 of file HttpStyleUri.h.
|
inlinenoexcept |
Specifies a key and gets a value. If not found, returns NULL
.
[in] | key | Key string. |
Definition at line 52 of file HttpStyleUri.h.
|
inlinenoexcept |
Gets the name of the URI scheme. The name is either http
or https
.
Definition at line 37 of file HttpStyleUri.h.
|
inlinenoexcept |
Specifies an index and gets a segment.
[in] | i | The index for a segment. |
NULL
. The segment string is percent-decoded. Definition at line 46 of file HttpStyleUri.h.
|
inlinenoexcept |
Gets the user information.
Definition at line 40 of file HttpStyleUri.h.
|
inlinenoexcept |
Gets whether the path is in the form of a directory path.
true
if the path is a directory path.Definition at line 49 of file HttpStyleUri.h.
|
noexcept |
Parses URIs.
[in] | str | The URI string. |
true
on success.
|
noexcept |
Sets a fragment string.
[in] | fragment | A fragment string. |
true
when successful.
|
noexcept |
Sets the hostname. It does not need to be percent-encoded.
[in] | host | The hostname. |
true
when successful.
|
noexcept |
Sets a path.
[in] | path | The path string. |
true
when successful.
|
noexcept |
Sets the port number.
[in] | port | A port number. |
true
when successful.
|
inlinenoexcept |
Sets a query based on a query string.
[in] | query | A query string. |
true
when successful.Definition at line 32 of file HttpStyleUri.h.
|
noexcept |
Sets the scheme.
[in] | scheme | The scheme (http or https ). |
true
when successful.http
or https
. If you specify http
, the port number is set to 80. If you specify https
, the port number is set to 81. When the object is first initialized the scheme is set to http
.
|
noexcept |
Sets the user information.
[in] | userinfo | The user information. |
true
when successful.userinfo@hostname
. This is not used under normal circumstances.
|
noexcept |
Converts to a URI object.
[out] | uri | Pointer to the URI object. |
true
when successful. © 2013, 2014, 2015 Nintendo Co., Ltd. All rights reserved.