25 using Members = ::std::vector<::std::string>;
35 using UInt64 = uint64;
39 using LargestInt = int64;
41 using LargestUInt = uint64;
43 using ArrayIndex = uint;
49 ::ll::TypedStorage<8, 8, char*> cstr_;
52 bool operator<(
CZString const& other)
const {
54 return strcmp(cstr_, other.cstr_) < 0;
59 bool operator<(
char const (&other)[N])
const {
60 return operator<(std::string_view{other, N - 1});
62 bool operator<(std::string_view other)
const {
80 MCAPI
void* $ctor(
char const* cstr);
93 using is_transparent = void;
97 constexpr auto operator()(
CZString const& l, T
const& r)
const {
101 constexpr auto operator()(T
const& l,
CZString const& r)
const {
106 using ObjectValues = ::std::map<::Json::Value::CZString, ::Json::Value, ::Json::Value::CZStringCompare>;
108 using ArrayValues = ::std::vector<::Json::Value*>;
114 ::ll::TypedStorage<8, 8, int64> int_;
115 ::ll::TypedStorage<8, 8, uint64> uint_;
116 ::ll::TypedStorage<8, 8, double> real_;
117 ::ll::TypedStorage<1, 8, bool> bool_;
118 ::ll::TypedStorage<8, 8, ::Json::Value::CZString*> string_;
119 ::ll::TypedStorage<8, 8, ::std::map<::Json::Value::CZString, ::Json::Value, ::Json::Value::CZStringCompare>*>
121 ::ll::TypedStorage<8, 8, ::std::vector<::Json::Value*>*> array_;
129 ::Json::ValueType type_;
133 using enum ::Json::ValueType;
134 static constexpr LargestInt minLargestInt = LargestInt(~(LargestUInt(-1) / 2));
135 static constexpr LargestInt maxLargestInt = LargestInt(LargestUInt(-1) / 2);
136 static constexpr LargestUInt maxLargestUInt = LargestUInt(-1);
137 static constexpr Int minInt = Int(~(UInt(-1) / 2));
138 static constexpr Int maxInt = Int(UInt(-1) / 2);
139 static constexpr UInt maxUInt = UInt(-1);
140 static constexpr Int64 minInt64 = Int64(~(UInt64(-1) / 2));
141 static constexpr Int64 maxInt64 = Int64(UInt64(-1) / 2);
142 static constexpr UInt64 maxUInt64 = UInt64(-1);
143 static constexpr UInt defaultRealPrecision = 17;
144 static constexpr double maxUInt64AsDouble = 18446744073709551615.0;
146 static bool IsIntegral(
double d) {
147 double integral_part;
148 return modf(d, &integral_part) == 0.0;
152 ValueType type()
const {
return type_; }
154 operator bool()
const {
return !isNull(); }
156 bool isNull()
const {
return type() == NullValue; }
158 bool isBool()
const {
return type() == BooleanValue; }
163 return value_.int_ >= minInt && value_.int_ <= maxInt;
165 return value_.uint_ <= UInt(maxInt);
167 return value_.real_ >= minInt && value_.real_ <= maxInt && IsIntegral(value_.real_);
174 bool isUInt()
const {
177 return value_.int_ >= 0 && LargestUInt(value_.int_) <= LargestUInt(maxUInt);
179 return value_.uint_ <= maxUInt;
181 return value_.real_ >= 0 && value_.real_ <= maxUInt && IsIntegral(value_.real_);
188 bool isInt64()
const {
193 return value_.uint_ <= UInt64(maxInt64);
195 return value_.real_ > double(minInt64) && value_.real_ < double(maxInt64) && IsIntegral(value_.real_);
202 bool isUInt64()
const {
205 return value_.int_ >= 0;
209 return value_.real_ >= 0 && value_.real_ < maxUInt64AsDouble && IsIntegral(value_.real_);
216 bool isIntegral()
const {
222 return value_.real_ > double(minInt64) && value_.real_ < maxUInt64AsDouble && IsIntegral(value_.real_);
229 bool isDouble()
const {
return type() == IntValue || type() == UintValue || type() == RealValue; }
231 bool isNumeric()
const {
return isDouble(); }
233 bool isString()
const {
return type() == StringValue; }
235 bool isArray()
const {
return type() == ArrayValue; }
237 bool isObject()
const {
return type() == ObjectValue; }
239 Int64 asInt64(Int64 defaultValue = 0)
const {
242 return Int64(value_.int_);
244 return isInt64() ? Int64(value_.uint_) : defaultValue;
246 return isInt64() ? Int64(value_.real_) : defaultValue;
250 return value_.bool_ ? 1 : 0;
257 UInt64 asUInt64(UInt64 defaultValue = 0)
const {
260 return isUInt64() ? UInt64(value_.int_) : defaultValue;
262 return UInt64(value_.uint_);
264 return isUInt64() ? UInt64(value_.real_) : defaultValue;
268 return value_.bool_ ? 1 : 0;
275 Value& operator[](
char const* key) {
return operator[](std::string{key}); }
276 Value& operator[](
int key) {
return operator[](uint(key)); }
277 Value
const& operator[](uint key)
const {
return operator[](
int(key)); }
279 Value(Int value) : Value(IntValue) { value_.int_ = value; }
280 Value(UInt value) : Value(UintValue) { value_.uint_ = value; }
282 Value(Int64 value) : Value(IntValue) { value_.int_ = value; }
283 Value(UInt64 value) : Value(UintValue) { value_.uint_ = value; }
285 Value(
double value) : Value(RealValue) { value_.real_ = value; }
286 Value(
bool value) : Value(BooleanValue) { value_.bool_ = value; }
295 MCAPI Value(::Json::ValueType type = NullValue);
297 MCAPI Value(
char const* value);
299 MCAPI Value(::std::string
const& value);
301 MCAPI ::Json::Value& _resolveReference(
char const* key);
307 MCAPI
bool asBool(
bool defaultValue)
const;
309 MCAPI
double asDouble(
double defaultValue)
const;
311 MCAPI
float asFloat(
float defaultValue)
const;
313 MCAPI
int asInt(
int defaultValue)
const;
315 MCAPI ::std::string asString(::std::string
const& defaultValue)
const;
317 MCAPI uint asUInt(uint defaultValue)
const;
319 MCFOLD ::Json::ValueConstIterator begin()
const;
321 MCAPI ::Json::ValueIterator begin();
325 MCAPI
bool empty()
const;
327 MCAPI ::Json::ValueConstIterator end()
const;
329 MCFOLD ::Json::ValueIterator end();
331 MCAPI ::Json::Value get(::std::string
const& key,
::Json::Value const& defaultValue)
const;
333 MCAPI ::Json::Value get(
char const* key,
::Json::Value const& defaultValue)
const;
335 MCAPI ::std::vector<::std::string> getMemberNames()
const;
337 MCAPI
bool isConvertibleTo(::Json::ValueType other)
const;
339 MCAPI
bool isMember(
char const* key)
const;
341 MCAPI
bool isMember(::std::string
const& key)
const;
353 MCAPI ::Json::Value
const& operator[](
int index)
const;
355 MCAPI ::Json::Value
const& operator[](
char const* key)
const;
357 MCAPI ::Json::Value
const& operator[](::std::string
const& key)
const;
359 MCAPI ::Json::Value& operator[](uint index);
361 MCAPI ::Json::Value& operator[](::std::string
const& key);
363 MCAPI ::Json::Value removeMember(
char const* key);
365 MCAPI
void resize(uint newSize);
367 MCAPI uint size()
const;
369 MCAPI ::std::string toStyledString()
const;
377 MCAPI static ::Json::Value
const& null();
387 MCAPI
void* $ctor(::Json::ValueType type);
389 MCAPI
void* $ctor(
char const* value);
391 MCAPI
void* $ctor(::std::string
const& value);