The class template to parse URI queries.
More...
#include "nn/nlib/Uri.h"
|
constexpr | UriQueryDecoder () noexcept |
| Instantiates the object with default parameters (default constructor).
|
|
errno_t | Init (const Uri &uri) noexcept |
| Sets and initializes a query string. More...
|
|
void | Reset () noexcept |
| Resets to the state that was set immediately after the constructor was executed.
|
|
bool | HasNext () noexcept |
| Returns a value indicating whether the end of the query has been reached. More...
|
|
errno_t | MoveNext () noexcept |
| Moves to the location where the next key and value can be obtained. More...
|
|
std::pair< errno_t, const char * > | GetKey () noexcept |
| Decodes and gets the key string. More...
|
|
std::pair< errno_t, const char * > | GetValue () noexcept |
| Decodes and gets the value string. More...
|
|
std::pair< errno_t, const char * > | GetFirstValueByName (const char *key) noexcept |
| Decodes and gets the value string corresponding to the key. More...
|
|
void | Rewind () noexcept |
| Restores to the state that was set immediately after Init() was executed.
|
|
template<size_t K = 64, size_t V = 192>
class nn::nlib::UriQueryDecoder< K, V >
The class template to parse URI queries.
- Template Parameters
-
K | The size of the buffer to store the decoded key string. |
V | The size of the buffer to store the decoded value string. |
- Description
- Receives a query string from the
Uri
class and sequentially gets the key and value. The class is implemented with only its header specified and no dynamic memory is allocated for the internal buffer. The size of the internal buffer can be specified using the template parameter.
- Examples:
- misc/uri/uri.cpp.
Definition at line 346 of file Uri.h.
◆ GetFirstValueByName()
template<size_t K, size_t V>
Decodes and gets the value string corresponding to the key.
- Parameters
-
[in] | key | The key string corresponding to the value. |
- Return values
-
0,the | decoded value string Successful. |
ESRCH,NULL | No key string that matches the key exists. |
EBADF,NULL | No query string has been set. |
ENOENT,NULL | The end of the query string has been reached. |
ELISEQ,NULL | Failed to decode the query string. |
ERANGE,NULL | Insufficient buffer size to store the decoded query string. |
Definition at line 467 of file Uri.h.
◆ GetKey()
template<size_t K, size_t V>
Decodes and gets the key string.
- Return values
-
0,the | decoded key string Successful. |
EBADF,NULL | No query string has been set. |
ENOENT,NULL | The end of the query string has been reached. |
ELISEQ,NULL | Failed to decode the query string. |
ERANGE,NULL | Insufficient buffer size to store the decoded query string. |
- Description
- Specifying an empty key causes an empty string key to be obtained. Even if the specified key string contains no '=' character, it is still handled as a key string and its decoded string is obtained.
Definition at line 435 of file Uri.h.
◆ GetValue()
template<size_t K, size_t V>
Decodes and gets the value string.
- Return values
-
0,the | decoded value string Successful. |
EBADF,NULL | No query string has been set. |
ENOENT,NULL | The end of the query string has been reached. |
ELISEQ,NULL | Failed to decode the query string. |
ERANGE,NULL | Insufficient buffer size to store the decoded query string. |
- Description
- Specifying an empty value causes an empty string value to be obtained.
Definition at line 449 of file Uri.h.
◆ HasNext()
template<size_t K, size_t V>
Returns a value indicating whether the end of the query has been reached.
- Returns
- Returns
true
if the end of the query has not been reached.
Definition at line 408 of file Uri.h.
◆ Init()
template<size_t K, size_t V>
Sets and initializes a query string.
- Parameters
-
[in] | uri | The successfully parsed Uri object. |
- Return values
-
0 | Success. |
EINVAL | The uri is in an error status. |
Definition at line 387 of file Uri.h.
◆ MoveNext()
template<size_t K, size_t V>
Moves to the location where the next key and value can be obtained.
- Return values
-
0 | Success. |
ENOENT | The end of the query has been reached. |
Definition at line 420 of file Uri.h.
The documentation for this class was generated from the following files: