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_;
53 bool operator<(
CZString const& other)
const {
55 return strcmp(cstr_, other.cstr_) < 0;
60 bool operator<(
char const (&other)[N])
const {
61 return operator<(std::string_view{other, N - 1});
63 bool operator<(std::string_view other)
const {
75 MCAPI
explicit CZString(
char const* cstr);
81 MCAPI
CZString(
char* cstr,
bool duplicate);
83 MCFOLD
char const* c_str()
const;
93 MCAPI
void* $ctor(
char const* cstr);
99 MCAPI
void* $ctor(
char* cstr,
bool duplicate);
112 using is_transparent = void;
116 constexpr auto operator()(
CZString const& l, T
const& r)
const {
120 constexpr auto operator()(T
const& l,
CZString const& r)
const {
125 using ObjectValues = ::std::map<::Json::Value::CZString, ::Json::Value, ::Json::Value::CZStringCompare>;
127 using ArrayValues = ::std::vector<::Json::Value*>;
133 ::ll::TypedStorage<8, 8, int64> int_;
134 ::ll::TypedStorage<8, 8, uint64> uint_;
135 ::ll::TypedStorage<8, 8, double> real_;
136 ::ll::TypedStorage<1, 8, bool> bool_;
137 ::ll::TypedStorage<8, 8, ::Json::Value::CZString*> string_;
138 ::ll::TypedStorage<8, 8, ::std::map<::Json::Value::CZString, ::Json::Value, ::Json::Value::CZStringCompare>*>
140 ::ll::TypedStorage<8, 8, ::std::vector<::Json::Value*>*> array_;
148 ::Json::ValueType type_;
152 using enum ::Json::ValueType;
153 static constexpr LargestInt minLargestInt = LargestInt(~(LargestUInt(-1) / 2));
154 static constexpr LargestInt maxLargestInt = LargestInt(LargestUInt(-1) / 2);
155 static constexpr LargestUInt maxLargestUInt = LargestUInt(-1);
156 static constexpr Int minInt = Int(~(UInt(-1) / 2));
157 static constexpr Int maxInt = Int(UInt(-1) / 2);
158 static constexpr UInt maxUInt = UInt(-1);
159 static constexpr Int64 minInt64 = Int64(~(UInt64(-1) / 2));
160 static constexpr Int64 maxInt64 = Int64(UInt64(-1) / 2);
161 static constexpr UInt64 maxUInt64 = UInt64(-1);
162 static constexpr UInt defaultRealPrecision = 17;
163 static constexpr double maxUInt64AsDouble = 18446744073709551615.0;
165 static bool IsIntegral(
double d) {
166 double integral_part;
167 return modf(d, &integral_part) == 0.0;
171 ValueType type()
const {
return type_; }
173 operator bool()
const {
return !isNull(); }
175 bool isNull()
const {
return type() == NullValue; }
177 bool isBool()
const {
return type() == BooleanValue; }
182 return value_.int_ >= minInt && value_.int_ <= maxInt;
184 return value_.uint_ <= UInt(maxInt);
186 return value_.real_ >= minInt && value_.real_ <= maxInt && IsIntegral(value_.real_);
193 bool isUInt()
const {
196 return value_.int_ >= 0 && LargestUInt(value_.int_) <= LargestUInt(maxUInt);
198 return value_.uint_ <= maxUInt;
200 return value_.real_ >= 0 && value_.real_ <= maxUInt && IsIntegral(value_.real_);
207 bool isInt64()
const {
212 return value_.uint_ <= UInt64(maxInt64);
214 return value_.real_ > double(minInt64) && value_.real_ < double(maxInt64) && IsIntegral(value_.real_);
221 bool isUInt64()
const {
224 return value_.int_ >= 0;
228 return value_.real_ >= 0 && value_.real_ < maxUInt64AsDouble && IsIntegral(value_.real_);
235 bool isIntegral()
const {
241 return value_.real_ > double(minInt64) && value_.real_ < maxUInt64AsDouble && IsIntegral(value_.real_);
248 bool isDouble()
const {
return type() == IntValue || type() == UintValue || type() == RealValue; }
250 bool isNumeric()
const {
return isDouble(); }
252 bool isString()
const {
return type() == StringValue; }
254 bool isArray()
const {
return type() == ArrayValue; }
256 bool isObject()
const {
return type() == ObjectValue; }
258 Int64 asInt64(Int64 defaultValue = 0)
const {
261 return Int64(value_.int_);
263 return isInt64() ? Int64(value_.uint_) : defaultValue;
265 return isInt64() ? Int64(value_.real_) : defaultValue;
269 return value_.bool_ ? 1 : 0;
276 UInt64 asUInt64(UInt64 defaultValue = 0)
const {
279 return isUInt64() ? UInt64(value_.int_) : defaultValue;
281 return UInt64(value_.uint_);
283 return isUInt64() ? UInt64(value_.real_) : defaultValue;
287 return value_.bool_ ? 1 : 0;
294 Value& operator[](
char const* key) {
return operator[](std::string{key}); }
295 Value& operator[](
int key) {
return operator[](uint(key)); }
296 Value
const& operator[](uint key)
const {
return operator[](
int(key)); }
298 Value(Int value) : Value(IntValue) { value_.int_ = value; }
299 Value(UInt value) : Value(UintValue) { value_.uint_ = value; }
301 Value(Int64 value) : Value(IntValue) { value_.int_ = value; }
302 Value(UInt64 value) : Value(UintValue) { value_.uint_ = value; }
304 Value(
double value) : Value(RealValue) { value_.real_ = value; }
305 Value(
bool value) : Value(BooleanValue) { value_.bool_ = value; }
316 MCAPI Value(::Json::ValueType type = NullValue);
318 MCAPI Value(
char const* value);
320 MCAPI Value(::std::string
const& value);
324 MCAPI ::Json::Value& _resolveReference(
char const* key);
330 MCAPI
bool asBool(
bool defaultValue)
const;
332 MCFOLD
char const* asCString()
const;
334 MCAPI
double asDouble(
double defaultValue)
const;
336 MCAPI
float asFloat(
float defaultValue)
const;
338 MCAPI
int asInt(
int defaultValue)
const;
340 MCAPI int64 asLargestInt()
const;
342 MCAPI uint64 asLargestUInt()
const;
344 MCAPI ::std::string asString(::std::string
const& defaultValue)
const;
346 MCAPI uint asUInt(uint defaultValue)
const;
348 MCFOLD ::Json::ValueConstIterator begin()
const;
350 MCAPI ::Json::ValueIterator begin();
356 MCAPI
bool empty()
const;
358 MCAPI ::Json::ValueConstIterator end()
const;
360 MCFOLD ::Json::ValueIterator end();
362 MCAPI ::Json::Value get(uint index,
::Json::Value const& defaultValue)
const;
364 MCAPI ::Json::Value get(::std::string
const& key,
::Json::Value const& defaultValue)
const;
366 MCAPI ::Json::Value get(
char const* key,
::Json::Value const& defaultValue)
const;
368 MCAPI ::std::vector<::std::string> getMemberNames()
const;
370 MCAPI
bool isConvertibleTo(::Json::ValueType other)
const;
372 MCAPI
bool isMember(
char const* key)
const;
374 MCAPI
bool isMember(::std::string
const& key)
const;
388 MCAPI ::Json::Value
const& operator[](
int index)
const;
390 MCAPI ::Json::Value
const& operator[](
char const* key)
const;
392 MCAPI ::Json::Value
const& operator[](::std::string
const& key)
const;
394 MCAPI ::Json::Value& operator[](uint index);
396 MCAPI ::Json::Value& operator[](::std::string
const& key);
398 MCAPI ::Json::Value removeMember(::std::string
const& key);
400 MCAPI ::Json::Value removeMember(
char const* key);
402 MCAPI
void resize(uint newSize);
404 MCAPI uint size()
const;
406 MCAPI ::std::string toStyledString()
const;
414 MCAPI static ::Json::Value
const& null();
426 MCAPI
void* $ctor(::Json::ValueType type);
428 MCAPI
void* $ctor(
char const* value);
430 MCAPI
void* $ctor(
int value);
432 MCAPI
void* $ctor(uint value);
434 MCAPI
void* $ctor(
double value);
436 MCAPI
void* $ctor(::std::string
const& value);
438 MCAPI
void* $ctor(uint64 value);
440 MCAPI
void* $ctor(int64 value);
442 MCAPI
void* $ctor(
bool value);