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