nlib
|
Class for outputting JSON or msgpack. More...
#include "nn/nlib/msgpack/JsonStreamGenerator.h"
Public Member Functions | |
bool | Flush () noexcept |
Writes data to the stream and flushes the stream. More... | |
JsonStreamGenerator & | StartArray (size_t count) noexcept |
Starts outputting the array. More... | |
JsonStreamGenerator & | StartMap (size_t count) noexcept |
Starts outputting the map. More... | |
JsonStreamGenerator & | Key (const nlib_utf8_t *key) noexcept |
Outputs keys for the associative array. More... | |
JsonStreamGenerator & | EndArray () noexcept |
Finishes the array. More... | |
JsonStreamGenerator & | EndMap () noexcept |
Finishes the map. More... | |
JsonStreamGenerator & | Null () noexcept |
Outputs null . More... | |
JsonStreamGenerator & | Boolean (bool value) noexcept |
Outputs true or false . More... | |
JsonStreamGenerator & | Int8 (int8_t num) noexcept |
Outputs an integer value. More... | |
JsonStreamGenerator & | Uint8 (uint8_t num) noexcept |
Outputs an integer value. More... | |
JsonStreamGenerator & | Int16 (int16_t num) noexcept |
Outputs an integer value. More... | |
JsonStreamGenerator & | Uint16 (uint16_t num) noexcept |
Outputs an integer value. More... | |
JsonStreamGenerator & | Int32 (int32_t num) noexcept |
Outputs an integer value. More... | |
JsonStreamGenerator & | Uint32 (uint32_t num) noexcept |
Outputs an integer value. More... | |
JsonStreamGenerator & | Int64 (int64_t num) noexcept |
Outputs an integer value. More... | |
JsonStreamGenerator & | Uint64 (uint64_t num) noexcept |
Outputs an integer value. More... | |
JsonStreamGenerator & | Float (float num) noexcept |
Outputs a floating-point number. More... | |
JsonStreamGenerator & | String (const nlib_utf8_t *str) noexcept |
Outputs a string. More... | |
JsonStreamGenerator & | Binary (const void *bin, size_t n) noexcept |
Outputs binary data. Currently, only outputting msgpack is supported. More... | |
JsonStreamGenerator & | Ext (int8_t tp, const void *bin, size_t n) noexcept |
Outputs extended data. More... | |
JsonStreamGenerator & | Timestamp (nlib_time t) noexcept |
Outputs a timestamp. For JSON, it is output as a string. More... | |
JsonStreamGenerator & | Object (const MpObject &obj) noexcept |
Outputs MpObject . More... | |
JsonStreamGenerator & | EmptyArray () noexcept |
Outputs an empty array. More... | |
JsonStreamGenerator & | EmptyMap () noexcept |
Outputs an empty map. More... | |
JsonStreamGenerator & | Int8Array (const int8_t *p, size_t count) noexcept |
Outputs an integer array. More... | |
JsonStreamGenerator & | Uint8Array (const uint8_t *p, size_t count) noexcept |
Outputs an integer array. More... | |
JsonStreamGenerator & | Int16Array (const int16_t *p, size_t count) noexcept |
Outputs an integer array. More... | |
JsonStreamGenerator & | Uint16Array (const uint16_t *p, size_t count) noexcept |
Outputs an integer array. More... | |
JsonStreamGenerator & | Int32Array (const int32_t *p, size_t count) noexcept |
Outputs an integer array. More... | |
JsonStreamGenerator & | Uint32Array (const uint32_t *p, size_t count) noexcept |
Outputs an integer array. More... | |
JsonStreamGenerator & | Int64Array (const int64_t *p, size_t count) noexcept |
Outputs an integer array. More... | |
JsonStreamGenerator & | Uint64Array (const uint64_t *p, size_t count) noexcept |
Outputs an integer array. More... | |
JsonStreamGenerator & | FloatArray (const float *p, size_t count) noexcept |
Outputs a single-precision floating point number array. More... | |
JsonStreamGenerator & | DoubleArray (const double *p, size_t count) noexcept |
Outputs a double-precision floating point number array. More... | |
Basic Member Functions | |
constexpr | JsonStreamGenerator () noexcept |
Instantiates the object with default parameters (default constructor). | |
~JsonStreamGenerator () noexcept | |
Destructor. | |
Initialization and Finalization | |
errno_t | Init (const JsonStreamGeneratorSettings &settings) noexcept |
Initializes the generator. More... | |
errno_t | Init () noexcept |
Initializes the parser using the default settings. | |
errno_t | Open (OutputStream *stream) noexcept |
Specifies a stream and starts generating data. More... | |
errno_t | Close () noexcept |
Closes the generator and sets it to the state immediately after it is initialized. More... | |
Error Checking | |
Error | GetError () const noexcept |
Gets an error. More... | |
operator bool () const | |
Returns true if an error has not occurred. | |
Static Public Member Functions | |
static errno_t | Generate (size_t *written, nlib_utf8_t *str, size_t n, const MpObject &obj, const JsonStreamGeneratorSettings &settings) noexcept |
Outputs JSON or msgpack from obj. More... | |
static errno_t | Generate (size_t *written, nlib_utf8_t *str, size_t n, const MpObject &obj) noexcept |
Runs Generate(written, str, n, obj, settings) with the default JsonStreamGeneratorSettings settings specified. | |
template<size_t N> | |
static errno_t | Generate (size_t *written, nlib_utf8_t(&str)[N], const MpObject &obj, const JsonStreamGeneratorSettings &settings) noexcept |
Runs Generate(written, str, N, obj, settings) . | |
template<size_t N> | |
static errno_t | Generate (size_t *written, nlib_utf8_t(&str)[N], const MpObject &obj) noexcept |
Runs Generate(written, str, N, obj, settings) with the default JsonStreamGeneratorSettings settings specified. | |
Class for outputting JSON or msgpack.
Definition at line 41 of file JsonStreamGenerator.h.
|
noexcept |
Outputs binary data. Currently, only outputting msgpack is supported.
[in] | bin | Binary data. |
[in] | n | Size of the binary data. |
|
noexcept |
|
noexcept |
Closes the generator and sets it to the state immediately after it is initialized.
0 | Success. |
EINVAL | Open() is not running. |
Other | errors the stream returns. |
|
noexcept |
Outputs a double-precision floating point number array.
[in] | p | Pointer to a double-precision floating point number array. |
[in] | count | Number of double-precision floating point numbers. |
|
inlinenoexcept |
Outputs an empty array.
Definition at line 168 of file JsonStreamGenerator.h.
|
inlinenoexcept |
Outputs an empty map.
Definition at line 169 of file JsonStreamGenerator.h.
|
noexcept |
Finishes the array.
|
noexcept |
Finishes the map.
|
noexcept |
Outputs extended data.
[in] | tp | Extended data type. |
[in] | bin | Binary data. |
[in] | n | Size of the binary data. |
|
noexcept |
Outputs a floating-point number.
[in] | num | A single-precision floating-point number. |
[in] | num | A double-precision floating-point number. |
|
noexcept |
Outputs a single-precision floating point number array.
[in] | p | Pointer to a single-precision floating point number array. |
[in] | count | Number of single-precision floating point numbers. |
|
noexcept |
Writes data to the stream and flushes the stream.
true
.
|
staticnoexcept |
Outputs JSON or msgpack from obj.
[out] | written | Size of the output data. |
[out] | str | The buffer that stores the output. |
[in] | n | The size of the output buffer. |
[in] | obj | MpObject to be serialized to JSON or msgpack. |
[in] | settings | Parameters for setting the generator. |
0
on success.
|
inlinenoexcept |
Gets an error.
JsonStreamGenerator
.Value | Description |
---|---|
kOk | An error has not occurred. |
kErrorKeyRequired | A key must be output. |
kErrorKeyForbidden | Do not output any key. |
kErrorEndArrayRequired | The array must be finished. |
kErrorEndArrayForbidden | Do not finish the array. |
kErrorEndMapRequired | The map must be finished. |
kErrorEndMapForbidden | Do not finish the map. |
kErrorStringUtf8 | The string or key contains one or more non-UTF-8 characters. |
kErrorStream | An error has occurred in the output stream. |
kErrorOutOfMemory | Failed to allocate memory. |
kErrorArrayOrMapRequired | An array or map must be started. |
kErrorDocumentEnd | The JSON/msgpack document has already finished. |
kErrorBinaryNotAvailable | Binary() is unavailable. |
kErrorExtNotAvailable | Ext() is unavailable, |
kErrorInvalidParam | One or more input parameters are invalid. |
Definition at line 180 of file JsonStreamGenerator.h.
|
noexcept |
Initializes the generator.
[in] | settings | Behavior options. |
0 | Success. |
EALREADY | Already initialized. |
|
noexcept |
|
noexcept |
Outputs an integer array.
[in] | p | Pointer to an integer array. |
[in] | count | Number of integer values. |
|
noexcept |
|
noexcept |
Outputs an integer array.
[in] | p | Pointer to an integer array. |
[in] | count | Number of integer values. |
|
noexcept |
|
noexcept |
Outputs an integer array.
[in] | p | Pointer to an integer array. |
[in] | count | Number of integer values. |
|
noexcept |
|
noexcept |
Outputs an integer array.
[in] | p | Pointer to an integer array. |
[in] | count | Number of integer values. |
|
noexcept |
Outputs keys for the associative array.
[in] | key | Associative array key. |
|
noexcept |
Outputs null
.
|
noexcept |
|
noexcept |
Specifies a stream and starts generating data.
[in] | stream | The stream to write JSON or msgpack. |
0 | Success. |
EINVAL | stream is NULL or JsonStreamGenerator is uninitialized. |
ENOMEM | Memory allocation has failed. |
|
noexcept |
Starts outputting the array.
[in] | count | Size of the array. |
|
noexcept |
Starts outputting the map.
[in] | count | Size of the map. |
|
noexcept |
Outputs a string.
[in] | str | String |
STDSTRING | Class that contains the c_str() member function that returns a C string. |
[in] | str | std::string and other class objects. |
|
noexcept |
Outputs a timestamp. For JSON, it is output as a string.
[in] | t | The time. |
|
noexcept |
|
noexcept |
Outputs an integer array.
[in] | p | Pointer to an integer array. |
[in] | count | Number of integer values. |
|
noexcept |
|
noexcept |
Outputs an integer array.
[in] | p | Pointer to an integer array. |
[in] | count | Number of integer values. |
|
noexcept |
|
noexcept |
Outputs an integer array.
[in] | p | Pointer to an integer array. |
[in] | count | Number of integer values. |
|
noexcept |
|
noexcept |
Outputs an integer array.
[in] | p | Pointer to an integer array. |
[in] | count | Number of integer values. |
© 2012-2017 Nintendo Co., Ltd. All rights reserved.