Writes the MessagePack formatted data to the stream.
More...
#include "nn/nlib/msgpack/MpWriter.h"
Writes the MessagePack formatted data to the stream.
- Description
MpWriter
supports writing boxed object (MpObject
), and native types.
Definition at line 30 of file MpWriter.h.
nn::nlib::msgpack::MpWriter::Close |
( |
| ) |
|
|
inlinenoexcept |
Closes MpWriter
.
- Returns
- Returns
true
when successful.
- Description
- Closes
MpWriter
and detaches the base stream. The base stream will not be closed.
- The object may be reused by calling the
Init
member function again.
Definition at line 42 of file MpWriter.h.
nn::nlib::msgpack::MpWriter::Flush |
( |
| ) |
|
|
inlinenoexcept |
Flushes the write to the stream.
- Returns
- Returns
true
when successful.
Definition at line 35 of file MpWriter.h.
nn::nlib::msgpack::MpWriter::GetErrorValue |
( |
| ) |
const |
|
inlinenoexcept |
Gets the error value.
- Return values
-
0 | No error occurred. |
EILSEQ | MpObject is invalid. |
EINVAL | Error in an argument. |
EEXIST | Attempted to initialize a JsonWriter object that has already been initialized. |
EIO | An error occurred in the base stream. |
EBADF | Attempted to use an uninitialized JsonReader . |
Definition at line 52 of file MpWriter.h.
nn::nlib::msgpack::MpWriter::GetStream |
( |
| ) |
|
|
inlinenoexcept |
Gets the base stream specified in Init
.
- Returns
- Returns the pointer to the stream.
Definition at line 73 of file MpWriter.h.
Sets a stream and initializes the object.
- Parameters
-
- Returns
- Returns
true
when successful.
nn::nlib::msgpack::MpWriter::SetError |
( |
errno_t |
e | ) |
|
|
inlinenoexcept |
Sets an error.
- Parameters
-
[in] | e | Error value to be set. (Any nonzero value is an error.) |
- Description
- It performs nothing if the error is already set.
Definition at line 49 of file MpWriter.h.
template<class T, size_t n>
bool nn::nlib::msgpack::MpWriter::Write |
( |
const T(&) |
vec[n] | ) |
|
Writes text strings or arrays.
- Parameters
-
[in] | vec | Array or string to be written. |
- Template Parameters
-
T | Element type. |
n | Number of elements. |
- Returns
- Returns
true
when successful.
- Description
- When T is
char
, the data is written as a string. Any other types are written as an array. A string must terminate with a null character.
Definition at line 122 of file MpWriter.h.
template<class T>
bool nn::nlib::msgpack::MpWriter::Write |
( |
const T & |
tp | ) |
|
|
inline |
Formats strings and writes them to the display buffer.
- Template Parameters
-
T | Type of object being written. |
- Parameters
-
[in] | tp | Object to write to the stream. |
- Returns
- Returns
true
when successful.
- Description
- Serializes objects and writes them to the stream. Returns
true
if successful. Sets an error and returns false
when it fails.
- Behavior differs according to the type of
T
. Supports serializing the following types. You may serialize user-defined types by using the MpWrite
function.
-
nil, bool
-
Signed and unsigned 8-bit to 64-bit integers.
-
float, double
-
C-style string,
std::string
-
std::pair
-
std::vector
-
Nlist
-
std::map
-
MpObject
Definition at line 133 of file MpWriter.h.
nn::nlib::msgpack::MpWriter::WriteArrayCount |
( |
uint32_t |
n | ) |
|
|
noexcept |
nn::nlib::msgpack::MpWriter::WriteMapCount |
( |
uint32_t |
n | ) |
|
|
noexcept |
nn::nlib::msgpack::MpWriter::WriteRawBody |
( |
const void * |
p, |
|
|
uint32_t |
n |
|
) |
| |
|
noexcept |
Writes byte array data body.
- Parameters
-
[in] | p | Pointer to the byte array. |
[in] | n | Size of the byte array (in bytes). |
- Returns
- Returns
true
when successful.
- Description
- Writes the byte array body. Returns
true
if successful. Sets an error and returns false
when it fails. n must match the value specified in the immediately preceding WriteRawCount
.
nn::nlib::msgpack::MpWriter::WriteRawCount |
( |
uint32_t |
n | ) |
|
|
noexcept |
The documentation for this class was generated from the following files: