LeviLamina
Loading...
Searching...
No Matches
JsonHelpers.h
1#pragma once
2
3#include "mc/_HeaderOutputPredefine.h"
4
5// auto generated forward declare list
6// clang-format off
7namespace Json { class Value; }
8// clang-format on
9
10namespace JsonHelpers {
11// functions
12// NOLINTBEGIN
13#ifdef LL_PLAT_C
14MCNAPI void addBoolField(::Json::Value& rootValue, ::std::string const& fieldName, bool const& value);
15
16MCNAPI void addFloatField(::Json::Value& rootValue, ::std::string const& fieldName, double const& value);
17
18MCNAPI void addInt64Field(::Json::Value& rootValue, ::std::string const& fieldName, int64 const& value);
19
20MCNAPI void addIntField(::Json::Value& rootValue, ::std::string const& fieldName, int const& value);
21
22MCNAPI void addObjectArrayField(
23 ::Json::Value& rootValue,
24 ::std::string const& fieldName,
25 ::std::vector<::Json::Value> const& objectArray
26);
27#endif
28
29MCNAPI void addObjectField(::Json::Value& rootValue, ::std::string const& fieldName, ::Json::Value const& object);
30
31#ifdef LL_PLAT_C
32MCNAPI void addStringArrayField(
33 ::Json::Value& rootValue,
34 ::std::string const& fieldName,
35 ::std::vector<::std::string> const& stringArray
36);
37#endif
38
39MCNAPI void addStringField(::Json::Value& rootValue, ::std::string const& fieldName, ::std::string const& value);
40
41#ifdef LL_PLAT_C
42MCNAPI void addUint32Field(::Json::Value& rootValue, ::std::string const& fieldName, uint const& value);
43#endif
44
45MCNAPI void addUint64Field(::Json::Value& rootValue, ::std::string const& fieldName, uint64 const& value);
46
47#ifdef LL_PLAT_C
48MCNAPI ::Json::Value const& getAsArray(::Json::Value const& value, ::Json::Value const& defaultValue);
49
50MCNAPI bool getAsBool(::Json::Value const& value, bool defaultBool);
51
52MCNAPI int getAsInt(::Json::Value const& value, int defaultInt);
53#endif
54
55MCNAPI ::std::string getAsString(::Json::Value const& value, ::std::string_view defaultString);
56
57#ifdef LL_PLAT_C
58MCNAPI ::std::vector<::std::string> getAsStringArray(::Json::Value const& value);
59
60MCNAPI uint getAsUint(::Json::Value const& value, uint defaultUint);
61#endif
62
63MCNAPI ::Json::Value const& getField(::Json::Value const& rootValue, ::std::string const& fieldName);
64
65#ifdef LL_PLAT_C
66MCNAPI ::Json::Value const& getFieldAsArray(::Json::Value const& rootValue, ::std::string const& fieldName);
67#endif
68
69MCNAPI bool getFieldAsBool(::Json::Value const& rootValue, ::std::string const& fieldName, bool defaultBool);
70
71#ifdef LL_PLAT_C
72MCNAPI float getFieldAsFloat(::Json::Value const& rootValue, ::std::string const& fieldName, float defaultFloat);
73
74MCNAPI int getFieldAsInt(::Json::Value const& rootValue, ::std::string const& fieldName, int defaultInt);
75
76MCNAPI int64 getFieldAsInt64(::Json::Value const& rootValue, ::std::string const& fieldName, int64 defaultInt64);
77
78MCNAPI ::std::unordered_map<::std::string, ::std::string>
79getFieldAsLocDictionary(::Json::Value const& rootValue, ::std::string const& fieldName);
80
81MCNAPI ::std::unordered_map<::std::string, ::std::string>
82getFieldAsMapOfKeyValuePairs(::Json::Value const& rootValue, ::std::string const& fieldName);
83#endif
84
85MCNAPI ::Json::Value const& getFieldAsObject(::Json::Value const& rootValue, ::std::string const& fieldName);
86
87#ifdef LL_PLAT_C
88MCNAPI ::std::vector<::std::reference_wrapper<::Json::Value const>>
89getFieldAsObjectArray(::Json::Value const& rootValue, ::std::string const& fieldName);
90
91MCNAPI ::std::optional<uint64> getFieldAsOptUint64(::Json::Value const& rootValue, ::std::string const& fieldName);
92#endif
93
94MCNAPI ::std::string
95getFieldAsString(::Json::Value const& rootValue, ::std::string const& fieldName, ::std::string const& defaultString);
96
97#ifdef LL_PLAT_C
98MCNAPI ::std::vector<::std::string>
99getFieldAsStringArray(::Json::Value const& rootValue, ::std::string const& fieldName);
100
101MCNAPI uint getFieldAsUint(::Json::Value const& rootValue, ::std::string const& fieldName, uint defaultUint);
102
103MCNAPI uint64 getFieldAsUint64(::Json::Value const& rootValue, ::std::string const& fieldName, uint64 defaultUint64);
104
105MCNAPI bool hasField(::Json::Value const& rootValue, ::std::string const& fieldName);
106#endif
107
108MCNAPI bool parseJson(::std::string const& str, ::Json::Value& root);
109
110MCNAPI ::std::string serialize(::Json::Value const& root);
111// NOLINTEND
112
113// static variables
114// NOLINTBEGIN
115MCNAPI ::Json::Value const& EMPTY_JSON();
116// NOLINTEND
117
118} // namespace JsonHelpers
Definition Value.h:16