16 #ifndef INCLUDE_NN_NLIB_MSGPACK_JSONSTREAMGENERATOR_H_ 17 #define INCLUDE_NN_NLIB_MSGPACK_JSONSTREAMGENERATOR_H_ 20 #include "nn/nlib/Swap.h" 23 #if defined(_MSC_VER) && defined(nx_msgpack_EXPORTS) 24 #undef NLIB_VIS_PUBLIC 25 #define NLIB_VIS_PUBLIC NLIB_WINEXPORT 38 omit_utf8_checking(false),
48 kErrorEndArrayRequired,
49 kErrorEndArrayForbidden,
51 kErrorEndMapForbidden,
55 kErrorArrayOrMapRequired,
57 kErrorBinaryNotAvailable,
58 kErrorExtNotAvailable,
69 return Generate(written, str, n, obj, settings);
74 return Generate(written, str, N, obj, settings);
80 return Generate(written, str, N, obj, settings);
83 static std::pair<errno_t, size_t>
86 std::pair<errno_t, size_t> rval;
87 rval.first = Generate(&rval.second, str, n, obj, settings);
91 static std::pair<errno_t, size_t>
94 return Generate(&str[0], N, obj, settings);
96 static std::pair<errno_t, size_t>
99 return Generate(str, n, obj, settings);
102 static std::pair<errno_t, size_t>
105 return Generate(&str[0], N, obj, settings);
115 return Init(settings);
176 struct JsonStreamGeneratorPrivate;
177 JsonStreamGeneratorPrivate* prv_;
185 #if defined(_MSC_VER) && defined(nx_msgpack_EXPORTS) 186 #undef NLIB_VIS_PUBLIC 187 #define NLIB_VIS_PUBLIC NLIB_WINIMPORT 190 #endif // INCLUDE_NN_NLIB_MSGPACK_JSONSTREAMGENERATOR_H_ static errno_t Generate(size_t *written, nlib_utf8_t(&str)[N], const MpObject &obj, const JsonStreamGeneratorSettings &settings) noexcept
A template overload of the above function.
bool strict
If true, generates an error if the first output is not an array or map. The default value is false...
static errno_t Generate(size_t *written, nlib_utf8_t(&str)[N], const MpObject &obj) noexcept
A template overload of the above function.
#define NLIB_DISALLOW_COPY_AND_ASSIGN(TypeName)
Prohibits use of the copy constructor and assignment operator for the class specified by TypeName...
#define NLIB_SAFE_BOOL(class_name, exp)
Defines a safe operator bool function in the class. Uses the C++11 explicit bool if it is available f...
static std::pair< errno_t, size_t > Generate(nlib_utf8_t *str, size_t n, const MpObject &obj) noexcept
A parameter omitted version of the above function which passes settings as the default value...
Error GetError() const noexcept
Gets an error.
constexpr JsonStreamGenerator() noexcept
Instantiates the object with default parameters (default constructor).
static std::pair< errno_t, size_t > Generate(nlib_utf8_t(&str)[N], const MpObject &obj) noexcept
A template overload of the above function.
bool omit_utf8_checking
If true, checking if the string is UTF-8 is skipped when outputting the string. The default value is ...
Object created when MessagePack or JSON is read.
static std::pair< errno_t, size_t > Generate(nlib_utf8_t *str, size_t n, const MpObject &obj, const JsonStreamGeneratorSettings &settings) noexcept
Outputs the content of obj in JSON or msgpack.
bool msgpack
If false, JsonStreamGenerator outputs JSON; if true, it outputs msgpack. The default value is false...
Object created when MessagePack, JSON, or CSV is read.
static std::pair< errno_t, size_t > Generate(nlib_utf8_t(&str)[N], const MpObject &obj, const JsonStreamGeneratorSettings &settings) noexcept
A template overload of the above function.
Implements stream-related classes usually commonly used, various containers, and other gadget classes...
constexpr JsonStreamGeneratorSettings() noexcept
Instantiates the object with default parameters (default constructor). Sets each data member to the d...
#define NLIB_NOEXCEPT
Defines noexcept geared to the environment, or the equivalent.
#define NLIB_CEXPR
Defines constexpr if it is available for use. If not, holds an empty string.
~JsonStreamGenerator() noexcept
Destructor.
static errno_t Generate(size_t *written, nlib_utf8_t *str, size_t n, const MpObject &obj) noexcept
A parameter omitted version of the above function which passes settings as the default value...
bool pretty_print
If true, outputs formatted JSON when outputting JSON. The default value is false. ...
#define NLIB_FINAL
Defines final if it is available for use. If not, holds an empty string.
Data structure used to store the JsonStreamGenerator settings parameters.
JsonStreamGenerator & EmptyMap() noexcept
Outputs an empty map.
The class for outputting JSON or msgpack.
The base class for output streams. This class cannot be instantiated.