The class that supports URI Template (RFC 6570, Level 3).
More...
#include "nn/nlib/UriTemplate.h"
|
errno_t | SetTemplate (const char *first, const char *last) noexcept |
| Sets a template. More...
|
|
errno_t | SetTemplate (const char *str) noexcept |
| A parameter omitted version of the above function which receives a null terminated string.
|
|
errno_t | SetParameter (const char *param, const char *value) noexcept |
| Sets parameters and their values. More...
|
|
void | ResetParameter () noexcept |
| Clears all settings for parameters and their values.
|
|
errno_t | Resolve (size_t *written, char *str, size_t n) const noexcept |
| Takes the string with assigned values in the URI template and writes it to str. More...
|
|
template<size_t N> |
errno_t | Resolve (size_t *written, char(&str)[N]) const noexcept |
| A template overload of the above function.
|
|
std::pair< errno_t, size_t > | Resolve (char *str, size_t n) const noexcept |
| Takes the string with assigned values in the URI template and writes it to str. More...
|
|
template<size_t N> |
std::pair< errno_t, size_t > | Resolve (char(&str)[N]) const noexcept |
| A template overload of the above function.
|
|
|
constexpr | UriTemplate () noexcept |
| Instantiates the object with default parameters (default constructor).
|
|
| ~UriTemplate () noexcept |
| Destructor.
|
|
| UriTemplate (UriTemplate &&rhs) |
| Instantiates the object (move constructor).
|
|
UriTemplate & | operator= (UriTemplate &&rhs) |
| Move assignment operator.
|
|
void | Reset () noexcept |
| Resets this object to the state immediately after the default constructor was executed.
|
|
|
static bool | IsUriTemplate (const char *first, const char *last) noexcept |
| Determines whether the string is a URI Template with a level up to Level 3. More...
|
|
static bool | IsUriTemplate (const char *str) noexcept |
| A parameter omitted version of the above function which receives a null terminated string.
|
|
The class that supports URI Template (RFC 6570, Level 3).
- Description
- A URI template refers to text that consists of a URI string, as defined in RFC 6570, and variables each enclosed in braces ( { } ). Creating the actual URI is a simple task of instantiating the variables.
- The
UriTemplate
class supports RFC 6570 Level 1, Level 2, and Level 3.
- Sample code is provided below.
SUCCEED_IF(e == 0);
SUCCEED_IF(e == 0);
SUCCEED_IF(e == 0);
char str[256];
SUCCEED_IF(rval.first == 0);
- For more information about URI Template, see the RFC 6570 documentation.
- See also
- https://tools.ietf.org/html/rfc6570 (RFC6570)
- Examples:
- misc/uri/uri.cpp.
Definition at line 29 of file UriTemplate.h.
◆ IsUriTemplate()
nn::nlib::UriTemplate::IsUriTemplate |
( |
const char * |
first, |
|
|
const char * |
last |
|
) |
| |
|
staticnoexcept |
Determines whether the string is a URI Template with a level up to Level 3.
- Parameters
-
[in] | first | The first character of the string you want to inspect. |
[in] | last | The last character of the string you want to inspect. |
- Return values
-
Returns | true if the string is a URI Template, otherwise returns false. |
◆ Resolve() [1/2]
nn::nlib::UriTemplate::Resolve |
( |
size_t * |
written, |
|
|
char * |
str, |
|
|
size_t |
n |
|
) |
| const |
|
noexcept |
Takes the string with assigned values in the URI template and writes it to str.
- Parameters
-
[out] | written | The number of written characters (not including the null character). |
[out] | str | The buffer to which the string is stored. |
[in] | n | The size of the buffer. |
- Returns
- Returns
0
on success.
◆ Resolve() [2/2]
nn::nlib::UriTemplate::Resolve |
( |
char * |
str, |
|
|
size_t |
n |
|
) |
| const |
|
inlinenoexcept |
Takes the string with assigned values in the URI template and writes it to str.
- Parameters
-
[out] | str | The buffer to which the string is stored. |
[in] | n | The size of the buffer. |
- Returns
- A pair of the error value and the number of written characters (not including the null characters).
Definition at line 50 of file UriTemplate.h.
◆ SetParameter()
nn::nlib::UriTemplate::SetParameter |
( |
const char * |
param, |
|
|
const char * |
value |
|
) |
| |
|
noexcept |
Sets parameters and their values.
- Parameters
-
[in] | param | A variable name. |
[in] | value | A value. |
- Return values
-
0 | No error occurred. |
EINVAL | param is NULL or an empty string. |
- Description
- An empty string entered for the value results in different behavior than
NULL
. If NULL
, the value is undefined.
◆ SetTemplate()
nn::nlib::UriTemplate::SetTemplate |
( |
const char * |
first, |
|
|
const char * |
last |
|
) |
| |
|
noexcept |
Sets a template.
- Parameters
-
[in] | first | The first character of the template string. |
[in] | last | The last character of the template string. |
- Return values
-
0 | No error occurred. |
EINVAL | Indicates that str is NULL . |
EILSEQ | A variable list inside braces ( { } ) is invalid. |
ERANGE | The template string is too long. |
ENOMEM | Indicates that internal memory allocation failed. |
- Description
- Sets a template. Characters that require percent-encoding are percent-encoded as appropriate.
The documentation for this class was generated from the following files: