5#include <rapidjson/prettywriter.h>
6#include <rapidjson/stringbuffer.h>
21 rapidjson::StringBuffer _prettyBuffer;
22 std::unique_ptr<rapidjson::PrettyWriter<rapidjson::StringBuffer>> pretty;
29 bool Bool(
bool b)
override;
30 bool Int(
int i)
override;
31 bool Uint(
unsigned int i)
override;
32 bool Uint64(std::uint64_t i)
override;
33 bool Int64(std::int64_t i)
override;
35 bool RawNumber(
const char* str,
unsigned int length,
bool copy)
override;
36 bool Key(std::string_view
string)
override;
37 bool String(std::string_view
string)
override;
52 void KeyPrimitive(std::string_view keyName, std::int32_t value)
override;
53 void KeyPrimitive(std::string_view keyName, std::uint32_t value)
override;
54 void KeyPrimitive(std::string_view keyName, std::int64_t value)
override;
55 void KeyPrimitive(std::string_view keyName, std::uint64_t value)
override;
56 void KeyPrimitive(std::string_view keyName, std::string_view value)
override;
58 void KeyPrimitive(std::string_view keyName,
double value)
override;
59 void KeyPrimitive(std::string_view keyName, std::nullptr_t value)
override;
61 void KeyArray(std::string_view keyName, std::function<
void(
void)> insideArray)
64 std::string_view keyName,
65 std::function<
void(
void)> insideObject)
override;
69 std::vector<std::byte>
toBytes()
override;
Wrapper around rapidjson::Writer for writing objects to JSON.
Implementation of JsonWriter that "pretty-prints" JSON to the output, formatted with new lines and in...
void KeyPrimitive(std::string_view keyName, std::nullptr_t value) override
Writes the given key and its corresponding value primitive to the output. This is a convenience funct...
void Primitive(std::int32_t value) override
Writes the given primitive to the output. This is a convenience function for Int.
bool StartArray() override
Writes the start of a JSON array to the output.
bool Null() override
Writes a null value to the output.
std::string toString() override
Obtains the written output as a string.
void Primitive(double value) override
Writes the given primitive to the output. This is a convenience function for Double.
bool String(std::string_view string) override
Writes the given string as a value to the output.
void KeyPrimitive(std::string_view keyName, std::uint64_t value) override
Writes the given key and its corresponding value primitive to the output. This is a convenience funct...
void KeyObject(std::string_view keyName, std::function< void(void)> insideObject) override
Writes an object to the output with the given key and calls the provided callback to write values ins...
void KeyPrimitive(std::string_view keyName, float value) override
Writes the given key and its corresponding value primitive to the output. This is a convenience funct...
bool RawNumber(const char *str, unsigned int length, bool copy) override
Writes the given string as a number to the output without any kind of special handling.
std::string_view toStringView() override
Obtains the written output as a string_view.
bool Bool(bool b) override
Writes a boolean value to the output.
void KeyPrimitive(std::string_view keyName, double value) override
Writes the given key and its corresponding value primitive to the output. This is a convenience funct...
bool Uint(unsigned int i) override
Writes an unsigned integer value to the output.
void Primitive(float value) override
Writes the given primitive to the output. This is a convenience function for Double.
bool EndArray() override
Writes the end of a JSON array to the output.
void Primitive(std::uint32_t value) override
Writes the given primitive to the output. This is a convenience function for Uint.
bool StartObject() override
Writes the start of a JSON object to the output.
void KeyPrimitive(std::string_view keyName, std::int32_t value) override
Writes the given key and its corresponding value primitive to the output. This is a convenience funct...
bool Double(double d) override
Writes a 64-bit floating point value to the output.
bool Key(std::string_view string) override
Writes the given string as an object key to the output.
std::vector< std::byte > toBytes() override
Obtains the written output as a buffer of bytes.
void Primitive(std::string_view string) override
Writes the given primitive to the output. This is a convenience function for String.
bool Int(int i) override
Writes a signed integer value to the output.
bool Int64(std::int64_t i) override
Writes an signed 64-bit integer value to the output.
void KeyPrimitive(std::string_view keyName, std::uint32_t value) override
Writes the given key and its corresponding value primitive to the output. This is a convenience funct...
void KeyPrimitive(std::string_view keyName, std::string_view value) override
Writes the given key and its corresponding value primitive to the output. This is a convenience funct...
void KeyArray(std::string_view keyName, std::function< void(void)> insideArray) override
Writes an array to the output with the given key and calls the provided callback to write values insi...
void Primitive(std::uint64_t value) override
Writes the given primitive to the output. This is a convenience function for Uint64.
bool EndObject() override
Writes the end of a JSON object to the output.
void Primitive(std::int64_t value) override
Writes the given primitive to the output. This is a convenience function for Int64.
bool Uint64(std::uint64_t i) override
Writes an unsigned 64-bit integer value to the output.
void KeyPrimitive(std::string_view keyName, std::int64_t value) override
Writes the given key and its corresponding value primitive to the output. This is a convenience funct...
void Primitive(std::nullptr_t value) override
Writes the given primitive to the output. This is a convenience function for Null.
Classes for writing JSON.