3#include <rapidjson/stringbuffer.h>
4#include <rapidjson/writer.h>
39 virtual bool Int(
int i);
45 virtual bool Uint(
unsigned int i);
51 virtual bool Uint64(std::uint64_t i);
57 virtual bool Int64(std::int64_t i);
73 virtual bool RawNumber(
const char* str,
unsigned int length,
bool copy);
80 virtual bool Key(std::string_view
string);
87 virtual bool String(std::string_view
string);
169 virtual void KeyPrimitive(std::string_view keyName, std::int32_t value);
177 virtual void KeyPrimitive(std::string_view keyName, std::uint32_t value);
185 virtual void KeyPrimitive(std::string_view keyName, std::int64_t value);
193 virtual void KeyPrimitive(std::string_view keyName, std::uint64_t value);
201 virtual void KeyPrimitive(std::string_view keyName, std::string_view value);
225 virtual void KeyPrimitive(std::string_view keyName, std::nullptr_t value);
238 KeyArray(std::string_view keyName, std::function<
void(
void)> insideArray);
250 KeyObject(std::string_view keyName, std::function<
void(
void)> insideObject);
269 _errors.emplace_back(std::forward<ErrorStr>(error));
276 _warnings.emplace_back(std::forward<WarningStr>(warning));
282 const std::vector<std::string>&
getErrors()
const {
return _errors; }
286 const std::vector<std::string>&
getWarnings()
const {
return _warnings; }
289 rapidjson::StringBuffer _compactBuffer;
290 std::unique_ptr<rapidjson::Writer<rapidjson::StringBuffer>> _compact;
292 std::vector<std::string> _errors;
293 std::vector<std::string> _warnings;
Wrapper around rapidjson::Writer for writing objects to JSON.
virtual void KeyPrimitive(std::string_view keyName, double value)
Writes the given key and its corresponding value primitive to the output. This is a convenience funct...
virtual bool Int(int i)
Writes a signed integer value to the output.
virtual void Primitive(std::uint32_t value)
Writes the given primitive to the output. This is a convenience function for Uint.
virtual void KeyPrimitive(std::string_view keyName, std::uint64_t value)
Writes the given key and its corresponding value primitive to the output. This is a convenience funct...
void emplaceWarning(WarningStr &&warning)
Emplaces a new warning into the internal warning buffer.
const std::vector< std::string > & getErrors() const
Obtains the current error buffer.
virtual bool StartObject()
Writes the start of a JSON object to the output.
virtual void Primitive(std::int32_t value)
Writes the given primitive to the output. This is a convenience function for Int.
virtual void Primitive(std::nullptr_t value)
Writes the given primitive to the output. This is a convenience function for Null.
virtual bool Double(double d)
Writes a 64-bit floating point value to the output.
virtual void KeyPrimitive(std::string_view keyName, float value)
Writes the given key and its corresponding value primitive to the output. This is a convenience funct...
virtual void Primitive(float value)
Writes the given primitive to the output. This is a convenience function for Double.
virtual void KeyPrimitive(std::string_view keyName, std::string_view value)
Writes the given key and its corresponding value primitive to the output. This is a convenience funct...
virtual void KeyArray(std::string_view keyName, std::function< void(void)> insideArray)
Writes an array to the output with the given key and calls the provided callback to write values insi...
virtual bool EndObject()
Writes the end of a JSON object to the output.
virtual bool Bool(bool b)
Writes a boolean value to the output.
void emplaceError(ErrorStr &&error)
Emplaces a new error into the internal error buffer.
virtual void KeyObject(std::string_view keyName, std::function< void(void)> insideObject)
Writes an object to the output with the given key and calls the provided callback to write values ins...
virtual bool RawNumber(const char *str, unsigned int length, bool copy)
Writes the given string as a number to the output without any kind of special handling.
virtual std::string toString()
Obtains the written output as a string.
virtual void Primitive(double value)
Writes the given primitive to the output. This is a convenience function for Double.
virtual bool Key(std::string_view string)
Writes the given string as an object key to the output.
virtual void KeyPrimitive(std::string_view keyName, std::int64_t value)
Writes the given key and its corresponding value primitive to the output. This is a convenience funct...
virtual bool Uint64(std::uint64_t i)
Writes an unsigned 64-bit integer value to the output.
virtual void Primitive(std::int64_t value)
Writes the given primitive to the output. This is a convenience function for Int64.
virtual void Primitive(std::string_view string)
Writes the given primitive to the output. This is a convenience function for String.
virtual bool EndArray()
Writes the end of a JSON array to the output.
virtual void Primitive(std::uint64_t value)
Writes the given primitive to the output. This is a convenience function for Uint64.
virtual void KeyPrimitive(std::string_view keyName, std::nullptr_t value)
Writes the given key and its corresponding value primitive to the output. This is a convenience funct...
virtual bool Null()
Writes a null value to the output.
virtual bool String(std::string_view string)
Writes the given string as a value to the output.
virtual void KeyPrimitive(std::string_view keyName, std::uint32_t value)
Writes the given key and its corresponding value primitive to the output. This is a convenience funct...
virtual void KeyPrimitive(std::string_view keyName, std::int32_t value)
Writes the given key and its corresponding value primitive to the output. This is a convenience funct...
virtual std::string_view toStringView()
Obtains the written output as a string_view.
const std::vector< std::string > & getWarnings() const
Obtains the current warning buffer.
virtual bool Uint(unsigned int i)
Writes an unsigned integer value to the output.
virtual std::vector< std::byte > toBytes()
Obtains the written output as a buffer of bytes.
virtual bool Int64(std::int64_t i)
Writes an signed 64-bit integer value to the output.
virtual bool StartArray()
Writes the start of a JSON array to the output.
Classes for writing JSON.