3 #include <rapidjson/stringbuffer.h>
4 #include <rapidjson/writer.h>
11 #include <string_view>
22 virtual bool Bool(
bool b);
23 virtual bool Int(
int i);
24 virtual bool Uint(
unsigned int i);
25 virtual bool Uint64(std::uint64_t i);
26 virtual bool Int64(std::int64_t i);
27 virtual bool Double(
double d);
28 virtual bool RawNumber(
const char* str,
unsigned int length,
bool copy);
29 virtual bool Key(std::string_view
string);
30 virtual bool String(std::string_view
string);
31 virtual bool StartObject();
32 virtual bool EndObject();
33 virtual bool StartArray();
34 virtual bool EndArray();
37 virtual void Primitive(std::int32_t value);
38 virtual void Primitive(std::uint32_t value);
39 virtual void Primitive(std::int64_t value);
40 virtual void Primitive(std::uint64_t value);
41 virtual void Primitive(
float value);
42 virtual void Primitive(
double value);
43 virtual void Primitive(std::nullptr_t value);
44 virtual void Primitive(std::string_view
string);
47 virtual void KeyPrimitive(std::string_view keyName, std::int32_t value);
48 virtual void KeyPrimitive(std::string_view keyName, std::uint32_t value);
49 virtual void KeyPrimitive(std::string_view keyName, std::int64_t value);
50 virtual void KeyPrimitive(std::string_view keyName, std::uint64_t value);
53 virtual void KeyPrimitive(std::string_view keyName, std::string_view value);
56 virtual void KeyPrimitive(std::string_view keyName,
float value);
57 virtual void KeyPrimitive(std::string_view keyName,
double value);
60 virtual void KeyPrimitive(std::string_view keyName, std::nullptr_t value);
64 KeyArray(std::string_view keyName, std::function<
void(
void)> insideArray);
67 KeyObject(std::string_view keyName, std::function<
void(
void)> insideObject);
69 virtual std::string toString();
70 virtual std::string_view toStringView();
71 virtual std::vector<std::byte> toBytes();
73 template <
typename ErrorStr>
void emplaceError(ErrorStr&& error) {
74 _errors.emplace_back(std::forward<ErrorStr>(error));
77 template <
typename WarningStr>
void emplaceWarning(WarningStr&& warning) {
78 _warnings.emplace_back(std::forward<WarningStr>(warning));
81 const std::vector<std::string>& getErrors()
const {
return _errors; }
82 const std::vector<std::string>& getWarnings()
const {
return _warnings; }
85 rapidjson::StringBuffer _compactBuffer;
86 std::unique_ptr<rapidjson::Writer<rapidjson::StringBuffer>> _compact;
88 std::vector<std::string> _errors;
89 std::vector<std::string> _warnings;
Classes for writing JSON.