nlib
nn::nlib::UriQueryDecoder< K, V > Class Template Referencefinal

The class template to parse URI queries. More...

#include "nn/nlib/Uri.h"

Public Member Functions

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.
 

Detailed Description

template<size_t K = 64, size_t V = 192>
class nn::nlib::UriQueryDecoder< K, V >

The class template to parse URI queries.

Template Parameters
KThe size of the buffer to store the decoded key string.
VThe 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.

Member Function Documentation

◆ GetFirstValueByName()

template<size_t K, size_t V>
std::pair< errno_t, const char * > nn::nlib::UriQueryDecoder< K, V >::GetFirstValueByName ( const char *  key)
noexcept

Decodes and gets the value string corresponding to the key.

Parameters
[in]keyThe key string corresponding to the value.
Return values
0,thedecoded value string Successful.
ESRCH,NULLNo key string that matches the key exists.
EBADF,NULLNo query string has been set.
ENOENT,NULLThe end of the query string has been reached.
ELISEQ,NULLFailed to decode the query string.
ERANGE,NULLInsufficient buffer size to store the decoded query string.

Definition at line 467 of file Uri.h.

◆ GetKey()

template<size_t K, size_t V>
std::pair< errno_t, const char * > nn::nlib::UriQueryDecoder< K, V >::GetKey ( )
noexcept

Decodes and gets the key string.

Return values
0,thedecoded key string Successful.
EBADF,NULLNo query string has been set.
ENOENT,NULLThe end of the query string has been reached.
ELISEQ,NULLFailed to decode the query string.
ERANGE,NULLInsufficient 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>
std::pair< errno_t, const char * > nn::nlib::UriQueryDecoder< K, V >::GetValue ( )
noexcept

Decodes and gets the value string.

Return values
0,thedecoded value string Successful.
EBADF,NULLNo query string has been set.
ENOENT,NULLThe end of the query string has been reached.
ELISEQ,NULLFailed to decode the query string.
ERANGE,NULLInsufficient 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>
bool nn::nlib::UriQueryDecoder< K, V >::HasNext ( )
noexcept

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>
errno_t nn::nlib::UriQueryDecoder< K, V >::Init ( const Uri uri)
noexcept

Sets and initializes a query string.

Parameters
[in]uriThe successfully parsed Uri object.
Return values
0Success.
EINVALThe uri is in an error status.

Definition at line 387 of file Uri.h.

◆ MoveNext()

template<size_t K, size_t V>
errno_t nn::nlib::UriQueryDecoder< K, V >::MoveNext ( )
noexcept

Moves to the location where the next key and value can be obtained.

Return values
0Success.
ENOENTThe 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: