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 {
74 MCAPI
explicit CZString(
char const* cstr);
80 MCAPI
CZString(
char* cstr,
bool duplicate);
82 MCFOLD
char const* c_str()
const;
92 MCAPI
void* $ctor(
char const* cstr);
98 MCAPI
void* $ctor(
char* cstr,
bool duplicate);
111 using is_transparent = void;
115 constexpr auto operator()(
CZString const& l, T
const& r)
const {
119 constexpr auto operator()(T
const& l,
CZString const& r)
const {
124 using ObjectValues = ::std::map<::Json::Value::CZString, ::Json::Value, ::Json::Value::CZStringCompare>;
126 using ArrayValues = ::std::vector<::Json::Value*>;
132 ::ll::TypedStorage<8, 8, int64> int_;
133 ::ll::TypedStorage<8, 8, uint64> uint_;
134 ::ll::TypedStorage<8, 8, double> real_;
135 ::ll::TypedStorage<1, 8, bool> bool_;
136 ::ll::TypedStorage<8, 8, ::Json::Value::CZString*> string_;
137 ::ll::TypedStorage<8, 8, ::std::map<::Json::Value::CZString, ::Json::Value, ::Json::Value::CZStringCompare>*>
139 ::ll::TypedStorage<8, 8, ::std::vector<::Json::Value*>*> array_;
147 ::Json::ValueType type_;
151 using enum ::Json::ValueType;
152 static constexpr LargestInt minLargestInt = LargestInt(~(LargestUInt(-1) / 2));
153 static constexpr LargestInt maxLargestInt = LargestInt(LargestUInt(-1) / 2);
154 static constexpr LargestUInt maxLargestUInt = LargestUInt(-1);
155 static constexpr Int minInt = Int(~(UInt(-1) / 2));
156 static constexpr Int maxInt = Int(UInt(-1) / 2);
157 static constexpr UInt maxUInt = UInt(-1);
158 static constexpr Int64 minInt64 = Int64(~(UInt64(-1) / 2));
159 static constexpr Int64 maxInt64 = Int64(UInt64(-1) / 2);
160 static constexpr UInt64 maxUInt64 = UInt64(-1);
161 static constexpr UInt defaultRealPrecision = 17;
162 static constexpr double maxUInt64AsDouble = 18446744073709551615.0;
164 static bool IsIntegral(
double d) {
165 double integral_part;
166 return modf(d, &integral_part) == 0.0;
170 ValueType type()
const {
return type_; }
172 operator bool()
const {
return !isNull(); }
174 bool isNull()
const {
return type() == NullValue; }
176 bool isBool()
const {
return type() == BooleanValue; }
181 return value_.int_ >= minInt && value_.int_ <= maxInt;
183 return value_.uint_ <= UInt(maxInt);
185 return value_.real_ >= minInt && value_.real_ <= maxInt && IsIntegral(value_.real_);
192 bool isUInt()
const {
195 return value_.int_ >= 0 && LargestUInt(value_.int_) <= LargestUInt(maxUInt);
197 return value_.uint_ <= maxUInt;
199 return value_.real_ >= 0 && value_.real_ <= maxUInt && IsIntegral(value_.real_);
206 bool isInt64()
const {
211 return value_.uint_ <= UInt64(maxInt64);
213 return value_.real_ > double(minInt64) && value_.real_ < double(maxInt64) && IsIntegral(value_.real_);
220 bool isUInt64()
const {
223 return value_.int_ >= 0;
227 return value_.real_ >= 0 && value_.real_ < maxUInt64AsDouble && IsIntegral(value_.real_);
234 bool isIntegral()
const {
240 return value_.real_ > double(minInt64) && value_.real_ < maxUInt64AsDouble && IsIntegral(value_.real_);
247 bool isDouble()
const {
return type() == IntValue || type() == UintValue || type() == RealValue; }
249 bool isNumeric()
const {
return isDouble(); }
251 bool isString()
const {
return type() == StringValue; }
253 bool isArray()
const {
return type() == ArrayValue; }
255 bool isObject()
const {
return type() == ObjectValue; }
257 Int64 asInt64(Int64 defaultValue = 0)
const {
260 return Int64(value_.int_);
262 return isInt64() ? Int64(value_.uint_) : defaultValue;
264 return isInt64() ? Int64(value_.real_) : defaultValue;
268 return value_.bool_ ? 1 : 0;
275 UInt64 asUInt64(UInt64 defaultValue = 0)
const {
278 return isUInt64() ? UInt64(value_.int_) : defaultValue;
280 return UInt64(value_.uint_);
282 return isUInt64() ? UInt64(value_.real_) : defaultValue;
286 return value_.bool_ ? 1 : 0;
293 Value& operator[](
char const* key) {
return operator[](std::string{key}); }
294 Value& operator[](
int key) {
return operator[](uint(key)); }
295 Value
const& operator[](uint key)
const {
return operator[](
int(key)); }
297 Value(Int value) : Value(IntValue) { value_.int_ = value; }
298 Value(UInt value) : Value(UintValue) { value_.uint_ = value; }
300 Value(Int64 value) : Value(IntValue) { value_.int_ = value; }
301 Value(UInt64 value) : Value(UintValue) { value_.uint_ = value; }
303 Value(
double value) : Value(RealValue) { value_.real_ = value; }
304 Value(
bool value) : Value(BooleanValue) { value_.bool_ = value; }
315 MCAPI Value(::Json::ValueType type = NullValue);
317 MCAPI Value(
char const* value);
319 MCAPI Value(::std::string
const& value);
323 MCAPI ::Json::Value& _resolveReference(
char const* key);
329 MCAPI
bool asBool(
bool defaultValue)
const;
331 MCFOLD
char const* asCString()
const;
333 MCAPI
double asDouble(
double defaultValue)
const;
335 MCAPI
float asFloat(
float defaultValue)
const;
337 MCAPI
int asInt(
int defaultValue)
const;
339 MCAPI int64 asLargestInt()
const;
341 MCAPI uint64 asLargestUInt()
const;
343 MCAPI ::std::string asString(::std::string
const& defaultValue)
const;
345 MCAPI uint asUInt(uint defaultValue)
const;
347 MCFOLD ::Json::ValueConstIterator begin()
const;
349 MCAPI ::Json::ValueIterator begin();
355 MCAPI
bool empty()
const;
357 MCAPI ::Json::ValueConstIterator end()
const;
359 MCFOLD ::Json::ValueIterator end();
361 MCAPI ::Json::Value get(::std::string
const& key,
::Json::Value const& defaultValue)
const;
363 MCAPI ::Json::Value get(
char const* key,
::Json::Value const& defaultValue)
const;
365 MCAPI ::std::vector<::std::string> getMemberNames()
const;
367 MCAPI
bool isConvertibleTo(::Json::ValueType other)
const;
369 MCAPI
bool isMember(
char const* key)
const;
371 MCAPI
bool isMember(::std::string
const& key)
const;
385 MCAPI ::Json::Value
const& operator[](
int index)
const;
387 MCAPI ::Json::Value
const& operator[](
char const* key)
const;
389 MCAPI ::Json::Value
const& operator[](::std::string
const& key)
const;
391 MCAPI ::Json::Value& operator[](uint index);
393 MCAPI ::Json::Value& operator[](::std::string
const& key);
395 MCAPI ::Json::Value removeMember(::std::string
const& key);
397 MCAPI ::Json::Value removeMember(
char const* key);
399 MCAPI
void resize(uint newSize);
401 MCAPI uint size()
const;
403 MCAPI ::std::string toStyledString()
const;
411 MCAPI static ::Json::Value
const& null();
423 MCAPI
void* $ctor(::Json::ValueType type);
425 MCAPI
void* $ctor(
char const* value);
427 MCAPI
void* $ctor(
int value);
429 MCAPI
void* $ctor(uint value);
431 MCAPI
void* $ctor(
double value);
433 MCAPI
void* $ctor(::std::string
const& value);
435 MCAPI
void* $ctor(uint64 value);
437 MCAPI
void* $ctor(int64 value);
439 MCAPI
void* $ctor(
bool value);