3 #ifndef INCLUDE_NN_NLIB_MSGPACK_JSONSTREAMGENERATOR_H_ 4 #define INCLUDE_NN_NLIB_MSGPACK_JSONSTREAMGENERATOR_H_ 8 #if defined(_MSC_VER) && defined(nx_msgpack_EXPORTS) 10 #define NLIB_VIS_PUBLIC NLIB_WINEXPORT 22 : msgpack(false), pretty_print(false),
23 omit_utf8_checking(false), strict(false) {}
32 ERROR_ENDARRAY_REQUIRED,
33 ERROR_ENDARRAY_FORBIDDEN,
34 ERROR_ENDMAP_REQUIRED,
35 ERROR_ENDMAP_FORBIDDEN,
39 ERROR_ARRAY_OR_MAP_REQUIRED,
41 ERROR_BINARY_NOT_AVAILABLE,
42 ERROR_EXT_NOT_AVAILABLE,
47 static errno_t Generate(
size_t* written,
char* str,
size_t n,
const MpObject& obj,
53 return Generate(written, str, n, obj, settings);
58 return Generate(written, str, N, obj, settings);
63 return Generate(written, str, N, obj, settings);
71 return Init(settings);
99 template<
class STDSTRING>
101 return String(str.c_str());
115 Error
GetError() const NLIB_NOEXCEPT {
return error_; }
128 struct JsonStreamGeneratorPrivate;
129 JsonStreamGeneratorPrivate* prv_;
136 #if defined(_MSC_VER) && defined(nx_msgpack_EXPORTS) 137 #undef NLIB_VIS_PUBLIC 138 #define NLIB_VIS_PUBLIC NLIB_WINIMPORT 141 #endif // INCLUDE_NN_NLIB_MSGPACK_JSONSTREAMGENERATOR_H_ static errno_t Generate(size_t *written, char(&str)[N], const MpObject &obj) noexcept
Runs Generate(written, str, N, obj, settings) with the default JsonStreamGeneratorSettings settings s...
errno_t Init() noexcept
Initializes the parser using the default settings.
bool strict
If true, generates an error if the first output is not an array or map.
JsonStreamGenerator & EmptyArray() noexcept
Outputs an empty array.
#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...
JsonStreamGenerator & EndArray() noexcept
Finishes the array.
Error GetError() const noexcept
Gets an error.
JsonStreamGenerator() noexcept
Instantiates the object with default parameters (default constructor).
bool omit_utf8_checking
If true, checking if the string is UTF-8 is skipped when outputting the string.
Object created when MessagePack or JSON is read.
static errno_t Generate(size_t *written, char(&str)[N], const MpObject &obj, const JsonStreamGeneratorSettings &settings) noexcept
Runs Generate(written, str, N, obj, settings).
static errno_t Generate(size_t *written, char *str, size_t n, const MpObject &obj) noexcept
Runs Generate(written, str, n, obj, settings) with the default JsonStreamGeneratorSettings settings s...
JsonStreamGenerator & String(const STDSTRING &str) noexcept
Outputs a string.
bool msgpack
If true, JsonStreamGenerator outputs JSON; if false, it outputs msgpack.
Object created when MessagePack, JSON, or CSV is read.
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.
bool pretty_print
If true, outputs formatted JSON when outputting JSON.
#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 & EndMap() noexcept
Finishes the map.
JsonStreamGenerator & EmptyMap() noexcept
Outputs an empty map.
Class for outputting JSON or msgpack.
The base class for output streams. This class cannot be instantiated.