LeviLamina
Loading...
Searching...
No Matches
Value.h
1#pragma once
2
3#include "mc/_HeaderOutputPredefine.h"
4
5// auto generated inclusion list
6#include "mc/deps/json/ValueType.h"
7
8// auto generated forward declare list
9// clang-format off
10namespace Json { class ValueConstIterator; }
11namespace Json { class ValueIterator; }
12// clang-format on
13
14namespace Json {
15
16class Value {
17public:
18 // Value inner types declare
19 // clang-format off
20 class CZString;
21 struct CZStringCompare;
22 // clang-format on
23
24 // Value inner types define
25 using Members = ::std::vector<::std::string>;
26
28
30
31 using UInt = uint;
32
33 using Int = int;
34
35 using UInt64 = uint64;
36
37 using Int64 = int64;
38
39 using LargestInt = int64;
40
41 using LargestUInt = uint64;
42
43 using ArrayIndex = uint;
44
45 class CZString {
46 public:
47 // member variables
48 // NOLINTBEGIN
49 ::ll::TypedStorage<8, 8, char*> cstr_;
50 // NOLINTEND
51 public:
52 bool operator<(CZString const& other) const {
53 if (cstr_) {
54 return strcmp(cstr_, other.cstr_) < 0;
55 }
56 return false;
57 }
58 template <size_t N>
59 bool operator<(char const (&other)[N]) const {
60 return operator<(std::string_view{other, N - 1});
61 }
62 bool operator<(std::string_view other) const {
63 if (cstr_) {
64 return cstr_ < other;
65 }
66 return false;
67 }
68
69 public:
70 // member functions
71 // NOLINTBEGIN
72 MCAPI CZString();
73
74 MCAPI explicit CZString(char const* cstr);
75
76 MCAPI CZString(::Json::Value::CZString const& other);
77
78 MCAPI CZString(::Json::Value::CZString&& other);
79
80 MCAPI CZString(char* cstr, bool duplicate);
81
82 MCFOLD char const* c_str() const;
83
84 MCAPI ~CZString();
85 // NOLINTEND
86
87 public:
88 // constructor thunks
89 // NOLINTBEGIN
90 MCFOLD void* $ctor();
91
92 MCAPI void* $ctor(char const* cstr);
93
94 MCAPI void* $ctor(::Json::Value::CZString const& other);
95
96 MCAPI void* $ctor(::Json::Value::CZString&& other);
97
98 MCAPI void* $ctor(char* cstr, bool duplicate);
99 // NOLINTEND
100
101 public:
102 // destructor thunk
103 // NOLINTBEGIN
104 MCAPI void $dtor();
105 // NOLINTEND
106 };
107
109 public:
110 // CZStringCompare inner types define
111 using is_transparent = void;
112
113 public:
114 template <class T>
115 constexpr auto operator()(CZString const& l, T const& r) const {
116 return l < r;
117 }
118 template <class T>
119 constexpr auto operator()(T const& l, CZString const& r) const {
120 return l < r;
121 }
122 };
123
124 using ObjectValues = ::std::map<::Json::Value::CZString, ::Json::Value, ::Json::Value::CZStringCompare>;
125
126 using ArrayValues = ::std::vector<::Json::Value*>;
127
129 public:
130 // member variables
131 // NOLINTBEGIN
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>*>
138 map_;
139 ::ll::TypedStorage<8, 8, ::std::vector<::Json::Value*>*> array_;
140 // NOLINTEND
141 };
142
143public:
144 // member variables
145 // NOLINTBEGIN
147 ::Json::ValueType type_;
148 // NOLINTEND
149
150public:
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;
163
164 static bool IsIntegral(double d) {
165 double integral_part;
166 return modf(d, &integral_part) == 0.0;
167 }
168
169public:
170 ValueType type() const { return type_; }
171
172 operator bool() const { return !isNull(); }
173
174 bool isNull() const { return type() == NullValue; }
175
176 bool isBool() const { return type() == BooleanValue; }
177
178 bool isInt() const {
179 switch (type()) {
180 case IntValue:
181 return value_.int_ >= minInt && value_.int_ <= maxInt;
182 case UintValue:
183 return value_.uint_ <= UInt(maxInt);
184 case RealValue:
185 return value_.real_ >= minInt && value_.real_ <= maxInt && IsIntegral(value_.real_);
186 default:
187 break;
188 }
189 return false;
190 }
191
192 bool isUInt() const {
193 switch (type()) {
194 case IntValue:
195 return value_.int_ >= 0 && LargestUInt(value_.int_) <= LargestUInt(maxUInt);
196 case UintValue:
197 return value_.uint_ <= maxUInt;
198 case RealValue:
199 return value_.real_ >= 0 && value_.real_ <= maxUInt && IsIntegral(value_.real_);
200 default:
201 break;
202 }
203 return false;
204 }
205
206 bool isInt64() const {
207 switch (type()) {
208 case IntValue:
209 return true;
210 case UintValue:
211 return value_.uint_ <= UInt64(maxInt64);
212 case RealValue:
213 return value_.real_ > double(minInt64) && value_.real_ < double(maxInt64) && IsIntegral(value_.real_);
214 default:
215 break;
216 }
217 return false;
218 }
219
220 bool isUInt64() const {
221 switch (type()) {
222 case IntValue:
223 return value_.int_ >= 0;
224 case UintValue:
225 return true;
226 case RealValue:
227 return value_.real_ >= 0 && value_.real_ < maxUInt64AsDouble && IsIntegral(value_.real_);
228 default:
229 break;
230 }
231 return false;
232 }
233
234 bool isIntegral() const {
235 switch (type()) {
236 case IntValue:
237 case UintValue:
238 return true;
239 case RealValue:
240 return value_.real_ > double(minInt64) && value_.real_ < maxUInt64AsDouble && IsIntegral(value_.real_);
241 default:
242 break;
243 }
244 return false;
245 }
246
247 bool isDouble() const { return type() == IntValue || type() == UintValue || type() == RealValue; }
248
249 bool isNumeric() const { return isDouble(); }
250
251 bool isString() const { return type() == StringValue; }
252
253 bool isArray() const { return type() == ArrayValue; }
254
255 bool isObject() const { return type() == ObjectValue; }
256
257 Int64 asInt64(Int64 defaultValue = 0) const {
258 switch (type()) {
259 case IntValue:
260 return Int64(value_.int_);
261 case UintValue:
262 return isInt64() ? Int64(value_.uint_) : defaultValue;
263 case RealValue:
264 return isInt64() ? Int64(value_.real_) : defaultValue;
265 case NullValue:
266 return 0;
267 case BooleanValue:
268 return value_.bool_ ? 1 : 0;
269 default:
270 break;
271 }
272 return defaultValue;
273 }
274
275 UInt64 asUInt64(UInt64 defaultValue = 0) const {
276 switch (type()) {
277 case IntValue:
278 return isUInt64() ? UInt64(value_.int_) : defaultValue;
279 case UintValue:
280 return UInt64(value_.uint_);
281 case RealValue:
282 return isUInt64() ? UInt64(value_.real_) : defaultValue;
283 case NullValue:
284 return 0;
285 case BooleanValue:
286 return value_.bool_ ? 1 : 0;
287 default:
288 break;
289 }
290 return defaultValue;
291 }
292
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)); }
296
297 Value(Int value) : Value(IntValue) { value_.int_ = value; }
298 Value(UInt value) : Value(UintValue) { value_.uint_ = value; }
299
300 Value(Int64 value) : Value(IntValue) { value_.int_ = value; }
301 Value(UInt64 value) : Value(UintValue) { value_.uint_ = value; }
302
303 Value(double value) : Value(RealValue) { value_.real_ = value; }
304 Value(bool value) : Value(BooleanValue) { value_.bool_ = value; }
305
306public:
307 // member functions
308 // NOLINTBEGIN
309 MCAPI Value(::Json::Value const& other);
310
311 MCAPI Value(::Json::Value&& other);
312
313 MCAPI Value(::Json::Value::CZString* str);
314
315 MCAPI Value(::Json::ValueType type = NullValue);
316
317 MCAPI Value(char const* value);
318
319 MCAPI Value(::std::string const& value);
320
321 MCAPI void _insert(::Json::Value::CZString&& key, ::Json::Value&& value, bool overwrite);
322
323 MCAPI ::Json::Value& _resolveReference(char const* key);
324
325 MCAPI ::Json::Value& append(::Json::Value&& value);
326
327 MCAPI ::Json::Value& append(::Json::Value const& value);
328
329 MCAPI bool asBool(bool defaultValue) const;
330
331 MCFOLD char const* asCString() const;
332
333 MCAPI double asDouble(double defaultValue) const;
334
335 MCAPI float asFloat(float defaultValue) const;
336
337 MCAPI int asInt(int defaultValue) const;
338
339 MCAPI int64 asLargestInt() const;
340
341 MCAPI uint64 asLargestUInt() const;
342
343 MCAPI ::std::string asString(::std::string const& defaultValue) const;
344
345 MCAPI uint asUInt(uint defaultValue) const;
346
347 MCFOLD ::Json::ValueConstIterator begin() const;
348
349 MCAPI ::Json::ValueIterator begin();
350
351 MCAPI void clear();
352
353 MCAPI int compare(::Json::Value const& other) const;
354
355 MCAPI bool empty() const;
356
357 MCAPI ::Json::ValueConstIterator end() const;
358
359 MCFOLD ::Json::ValueIterator end();
360
361 MCAPI ::Json::Value get(::std::string const& key, ::Json::Value const& defaultValue) const;
362
363 MCAPI ::Json::Value get(char const* key, ::Json::Value const& defaultValue) const;
364
365 MCAPI ::std::vector<::std::string> getMemberNames() const;
366
367 MCAPI bool isConvertibleTo(::Json::ValueType other) const;
368
369 MCAPI bool isMember(char const* key) const;
370
371 MCAPI bool isMember(::std::string const& key) const;
372
373 MCAPI bool operator!=(::Json::Value const& other) const;
374
375 MCAPI bool operator<(::Json::Value const& other) const;
376
377 MCAPI ::Json::Value& operator=(::Json::Value const& other);
378
379 MCAPI ::Json::Value& operator=(::Json::Value&& other);
380
381 MCAPI bool operator==(::Json::Value const& other) const;
382
383 MCAPI bool operator>(::Json::Value const& other) const;
384
385 MCAPI ::Json::Value const& operator[](int index) const;
386
387 MCAPI ::Json::Value const& operator[](char const* key) const;
388
389 MCAPI ::Json::Value const& operator[](::std::string const& key) const;
390
391 MCAPI ::Json::Value& operator[](uint index);
392
393 MCAPI ::Json::Value& operator[](::std::string const& key);
394
395 MCAPI ::Json::Value removeMember(::std::string const& key);
396
397 MCAPI ::Json::Value removeMember(char const* key);
398
399 MCAPI void resize(uint newSize);
400
401 MCAPI uint size() const;
402
403 MCAPI ::std::string toStyledString() const;
404
405 MCAPI ~Value();
406 // NOLINTEND
407
408public:
409 // static variables
410 // NOLINTBEGIN
411 MCAPI static ::Json::Value const& null();
412 // NOLINTEND
413
414public:
415 // constructor thunks
416 // NOLINTBEGIN
417 MCAPI void* $ctor(::Json::Value const& other);
418
419 MCAPI void* $ctor(::Json::Value&& other);
420
421 MCAPI void* $ctor(::Json::Value::CZString* str);
422
423 MCAPI void* $ctor(::Json::ValueType type);
424
425 MCAPI void* $ctor(char const* value);
426
427 MCAPI void* $ctor(int value);
428
429 MCAPI void* $ctor(uint value);
430
431 MCAPI void* $ctor(double value);
432
433 MCAPI void* $ctor(::std::string const& value);
434
435 MCAPI void* $ctor(uint64 value);
436
437 MCAPI void* $ctor(int64 value);
438
439 MCAPI void* $ctor(bool value);
440 // NOLINTEND
441
442public:
443 // destructor thunk
444 // NOLINTBEGIN
445 MCAPI void $dtor();
446 // NOLINTEND
447};
448
449} // namespace Json
Definition ValueConstIterator.h:15
Definition ValueIterator.h:16
Definition Value.h:45
Definition Value.h:16
Definition Value.h:108
Definition Value.h:128