cesium-native 0.63.0
Loading...
Searching...
No Matches
ArrayJsonHandler.h
1#pragma once
2
3#include <CesiumJsonReader/DoubleJsonHandler.h>
4#include <CesiumJsonReader/IntegerJsonHandler.h>
5#include <CesiumJsonReader/JsonHandler.h>
6#include <CesiumJsonReader/JsonObjectJsonHandler.h>
7#include <CesiumJsonReader/Library.h>
8#include <CesiumJsonReader/StringJsonHandler.h>
9#include <CesiumUtility/Assert.h>
10#include <CesiumUtility/JsonValue.h>
11
12#include <functional>
13#include <memory>
14#include <vector>
15
23template <typename T, typename THandler>
24class CESIUMJSONREADER_API ArrayJsonHandler : public JsonHandler {
25public:
27 using ValueType = std::vector<T>;
28
35 template <typename... Ts>
36 ArrayJsonHandler(Ts&&... args) noexcept
37 : JsonHandler(),
38 _handlerFactory(
39 std::bind(handlerFactory<Ts...>, std::forward<Ts>(args)...)),
40 _objectHandler() {}
41
46 void reset(IJsonHandler* pParent, std::vector<T>* pArray) {
47 JsonHandler::reset(pParent);
48 this->_pArray = pArray;
49 this->_arrayIsOpen = false;
50 this->_objectHandler.reset(this->_handlerFactory());
51 }
52
53 virtual IJsonHandler* readNull() override {
54 return this->invalid("A null")->readNull();
55 }
56
57 virtual IJsonHandler* readBool(bool b) override {
58 return this->invalid("A boolean")->readBool(b);
59 }
60
61 virtual IJsonHandler* readInt32(int32_t i) override {
62 return this->invalid("An integer")->readInt32(i);
63 }
64
65 virtual IJsonHandler* readUint32(uint32_t i) override {
66 return this->invalid("An integer")->readUint32(i);
67 }
68
69 virtual IJsonHandler* readInt64(int64_t i) override {
70 return this->invalid("An integer")->readInt64(i);
71 }
72
73 virtual IJsonHandler* readUint64(uint64_t i) override {
74 return this->invalid("An integer")->readUint64(i);
75 }
76
77 virtual IJsonHandler* readDouble(double d) override {
78 return this->invalid("A double (floating-point)")->readDouble(d);
79 }
80
81 virtual IJsonHandler* readString(const std::string_view& str) override {
82 return this->invalid("A string")->readString(str);
83 }
84
85 virtual IJsonHandler* readObjectStart() override {
86 if (!this->_arrayIsOpen) {
87 return this->invalid("An object")->readObjectStart();
88 }
89
90 CESIUM_ASSERT(this->_pArray);
91 T& o = this->_pArray->emplace_back();
92 this->_objectHandler->reset(this, &o);
93 return this->_objectHandler->readObjectStart();
94 }
95
97 [[maybe_unused]] const std::string_view& str) noexcept override {
98 return nullptr;
99 }
100
101 virtual IJsonHandler* readObjectEnd() noexcept override { return nullptr; }
102
103 virtual IJsonHandler* readArrayStart() override {
104 if (this->_arrayIsOpen) {
105 return this->invalid("An array")->readArrayStart();
106 }
107
108 this->_arrayIsOpen = true;
109 this->_pArray->clear();
110 return this;
111 }
112
113 virtual IJsonHandler* readArrayEnd() override { return this->parent(); }
114
115 virtual void reportWarning(
116 const std::string& warning,
117 std::vector<std::string>&& context =
118 std::vector<std::string>()) override {
119 context.push_back(
120 std::string("[") + std::to_string(this->_pArray->size()) + "]");
121 this->parent()->reportWarning(warning, std::move(context));
122 }
123
124private:
125 IJsonHandler* invalid(const std::string& type) {
126 if (this->_arrayIsOpen) {
127 this->reportWarning(
128 type + " value is not allowed in the object array and has been "
129 "replaced with a default value.");
130 this->_pArray->emplace_back();
131 return this->ignoreAndContinue();
132 } else {
133 this->reportWarning(type + " is not allowed and has been ignored.");
134 return this->ignoreAndReturnToParent();
135 }
136 }
137
138 template <typename... Ts> static THandler* handlerFactory(Ts&&... args) {
139 return new THandler(std::forward<Ts>(args)...);
140 }
141
142 std::vector<T>* _pArray = nullptr;
143 bool _arrayIsOpen = false;
144
145 std::function<THandler*()> _handlerFactory;
146 std::unique_ptr<THandler> _objectHandler;
147};
148
153template <>
154class CESIUMJSONREADER_API
155 ArrayJsonHandler<CesiumUtility::JsonValue, JsonObjectJsonHandler>
156 : public JsonHandler {
157public:
159 using ValueType = std::vector<CesiumUtility::JsonValue>;
160
161 ArrayJsonHandler() noexcept : JsonHandler(), _objectHandler() {}
162
167 void
168 reset(IJsonHandler* pParent, std::vector<CesiumUtility::JsonValue>* pArray) {
169 JsonHandler::reset(pParent);
170 this->_pArray = pArray;
171 this->_arrayIsOpen = false;
172 }
173
174 virtual IJsonHandler* readNull() override {
175 if (!this->_arrayIsOpen) {
176 return this->invalid("A null")->readNull();
177 }
178
179 CESIUM_ASSERT(this->_pArray);
180 this->_pArray->emplace_back(nullptr);
181 return this;
182 }
183
184 virtual IJsonHandler* readBool(bool b) override {
185 if (!this->_arrayIsOpen) {
186 return this->invalid("A bool")->readBool(b);
187 }
188
189 CESIUM_ASSERT(this->_pArray);
190 this->_pArray->emplace_back(b);
191 return this;
192 }
193
194 virtual IJsonHandler* readInt32(int32_t i) override {
195 if (!this->_arrayIsOpen) {
196 return this->invalid("An integer")->readInt32(i);
197 }
198
199 CESIUM_ASSERT(this->_pArray);
200 this->_pArray->emplace_back(i);
201 return this;
202 }
203
204 virtual IJsonHandler* readUint32(uint32_t i) override {
205 if (!this->_arrayIsOpen) {
206 return this->invalid("An integer")->readUint32(i);
207 }
208
209 CESIUM_ASSERT(this->_pArray);
210 this->_pArray->emplace_back(i);
211 return this;
212 }
213
214 virtual IJsonHandler* readInt64(int64_t i) override {
215 if (!this->_arrayIsOpen) {
216 return this->invalid("An integer")->readInt64(i);
217 }
218
219 CESIUM_ASSERT(this->_pArray);
220 this->_pArray->emplace_back(i);
221 return this;
222 }
223
224 virtual IJsonHandler* readUint64(uint64_t i) override {
225 if (!this->_arrayIsOpen) {
226 return this->invalid("An integer")->readUint64(i);
227 }
228
229 CESIUM_ASSERT(this->_pArray);
230 this->_pArray->emplace_back(i);
231 return this;
232 }
233
234 virtual IJsonHandler* readDouble(double d) override {
235 if (!this->_arrayIsOpen) {
236 return this->invalid("A double (floating-point)")->readDouble(d);
237 }
238
239 CESIUM_ASSERT(this->_pArray);
240 this->_pArray->emplace_back(d);
241 return this;
242 }
243
244 virtual IJsonHandler* readString(const std::string_view& str) override {
245 if (!this->_arrayIsOpen) {
246 return this->invalid("A string")->readString(str);
247 }
248
249 CESIUM_ASSERT(this->_pArray);
250 this->_pArray->emplace_back(std::string(str));
251 return this;
252 }
253
254 virtual IJsonHandler* readObjectStart() override {
255 if (!this->_arrayIsOpen) {
256 return this->invalid("An object")->readObjectStart();
257 }
258
259 CESIUM_ASSERT(this->_pArray);
260 CesiumUtility::JsonValue& o = this->_pArray->emplace_back();
261 this->_objectHandler.reset(this, &o);
262 return this->_objectHandler.readObjectStart();
263 }
264
265 virtual IJsonHandler* readObjectKey(const std::string_view& str) override {
266 return this->_objectHandler.readObjectKey(str);
267 }
268
269 virtual IJsonHandler* readObjectEnd() override {
270 return this->_objectHandler.readObjectEnd();
271 }
272
273 virtual IJsonHandler* readArrayStart() override {
274 if (this->_arrayIsOpen) {
275 // An array inside an array
276 CESIUM_ASSERT(this->_pArray);
277 CesiumUtility::JsonValue& o = this->_pArray->emplace_back();
278 this->_objectHandler.reset(this, &o);
279 return this->_objectHandler.readArrayStart();
280 } else {
281 this->_arrayIsOpen = true;
282 this->_pArray->clear();
283 return this;
284 }
285 }
286
287 virtual IJsonHandler* readArrayEnd() override { return this->parent(); }
288
289 virtual void reportWarning(
290 const std::string& warning,
291 std::vector<std::string>&& context =
292 std::vector<std::string>()) override {
293 context.push_back(
294 std::string("[") + std::to_string(this->_pArray->size()) + "]");
295 this->parent()->reportWarning(warning, std::move(context));
296 }
297
298private:
299 IJsonHandler* invalid(const std::string& type) {
300 if (this->_arrayIsOpen) {
301 this->reportWarning(
302 type + " value is not allowed in the JSON value array "
303 "and has been replaced with a default value.");
304 this->_pArray->emplace_back();
305 return this->ignoreAndContinue();
306 } else {
307 this->reportWarning(type + " is not allowed and has been ignored.");
308 return this->ignoreAndReturnToParent();
309 }
310 }
311
312 std::vector<CesiumUtility::JsonValue>* _pArray = nullptr;
313 bool _arrayIsOpen = false;
314 CesiumJsonReader::JsonObjectJsonHandler _objectHandler;
315};
316
323template <>
324class CESIUMJSONREADER_API ArrayJsonHandler<double, DoubleJsonHandler>
325 : public JsonHandler {
326public:
328 using ValueType = std::vector<double>;
329
330 ArrayJsonHandler() noexcept : JsonHandler() {}
331
336 void reset(IJsonHandler* pParent, std::vector<double>* pArray) {
337 JsonHandler::reset(pParent);
338 this->_pArray = pArray;
339 this->_arrayIsOpen = false;
340 }
341
342 virtual IJsonHandler* readNull() override {
343 return this->invalid("A null")->readNull();
344 }
345
346 virtual IJsonHandler* readBool(bool b) override {
347 return this->invalid("A bool")->readBool(b);
348 }
349
350 virtual IJsonHandler* readInt32(int32_t i) override {
351 if (!this->_arrayIsOpen) {
352 return this->invalid("An integer")->readInt32(i);
353 }
354
355 CESIUM_ASSERT(this->_pArray);
356 this->_pArray->emplace_back(static_cast<double>(i));
357 return this;
358 }
359
360 virtual IJsonHandler* readUint32(uint32_t i) override {
361 if (!this->_arrayIsOpen) {
362 return this->invalid("An integer")->readUint32(i);
363 }
364
365 CESIUM_ASSERT(this->_pArray);
366 this->_pArray->emplace_back(static_cast<double>(i));
367 return this;
368 }
369
370 virtual IJsonHandler* readInt64(int64_t i) override {
371 if (!this->_arrayIsOpen) {
372 return this->invalid("An integer")->readInt64(i);
373 }
374
375 CESIUM_ASSERT(this->_pArray);
376 this->_pArray->emplace_back(static_cast<double>(i));
377 return this;
378 }
379
380 virtual IJsonHandler* readUint64(uint64_t i) override {
381 if (!this->_arrayIsOpen) {
382 return this->invalid("An integer")->readUint64(i);
383 }
384
385 CESIUM_ASSERT(this->_pArray);
386 this->_pArray->emplace_back(static_cast<double>(i));
387 return this;
388 }
389
390 virtual IJsonHandler* readDouble(double d) override {
391 if (!this->_arrayIsOpen) {
392 return this->invalid("A double (floating-point)")->readDouble(d);
393 }
394
395 CESIUM_ASSERT(this->_pArray);
396 this->_pArray->emplace_back(d);
397 return this;
398 }
399
400 virtual IJsonHandler* readString(const std::string_view& str) override {
401 return this->invalid("A string")->readString(str);
402 }
403
404 virtual IJsonHandler* readObjectStart() override {
405 return this->invalid("An object")->readObjectStart();
406 }
407
408 virtual IJsonHandler* readArrayStart() override {
409 if (this->_arrayIsOpen) {
410 return this->invalid("An array")->readArrayStart();
411 }
412
413 this->_arrayIsOpen = true;
414 this->_pArray->clear();
415 return this;
416 }
417
418 virtual IJsonHandler* readArrayEnd() override { return this->parent(); }
419
420 virtual void reportWarning(
421 const std::string& warning,
422 std::vector<std::string>&& context =
423 std::vector<std::string>()) override {
424 context.push_back(
425 std::string("[") + std::to_string(this->_pArray->size()) + "]");
426 this->parent()->reportWarning(warning, std::move(context));
427 }
428
429private:
430 IJsonHandler* invalid(const std::string& type) {
431 if (this->_arrayIsOpen) {
432 this->reportWarning(
433 type + " value is not allowed in the double array and has been "
434 "replaced with a default value.");
435 this->_pArray->emplace_back();
436 return this->ignoreAndContinue();
437 } else {
438 this->reportWarning(type + " is not allowed and has been ignored.");
439 return this->ignoreAndReturnToParent();
440 }
441 }
442
443 std::vector<double>* _pArray = nullptr;
444 bool _arrayIsOpen = false;
445};
446
451template <typename T>
452class CESIUMJSONREADER_API ArrayJsonHandler<T, IntegerJsonHandler<T>>
453 : public JsonHandler {
454public:
456 using ValueType = std::vector<T>;
457
458 ArrayJsonHandler() noexcept : JsonHandler() {}
459
464 void reset(IJsonHandler* pParent, std::vector<T>* pArray) {
465 JsonHandler::reset(pParent);
466 this->_pArray = pArray;
467 this->_arrayIsOpen = false;
468 }
469
470 virtual IJsonHandler* readNull() override {
471 return this->invalid("A null")->readNull();
472 }
473
474 virtual IJsonHandler* readBool(bool b) override {
475 return this->invalid("A bool")->readBool(b);
476 }
477
478 virtual IJsonHandler* readInt32(int32_t i) override {
479 if (!this->_arrayIsOpen) {
480 return this->invalid("An integer")->readInt32(i);
481 }
482
483 CESIUM_ASSERT(this->_pArray);
484 this->_pArray->emplace_back(static_cast<T>(i));
485 return this;
486 }
487
488 virtual IJsonHandler* readUint32(uint32_t i) override {
489 if (!this->_arrayIsOpen) {
490 return this->invalid("An integer")->readUint32(i);
491 }
492
493 CESIUM_ASSERT(this->_pArray);
494 this->_pArray->emplace_back(static_cast<T>(i));
495 return this;
496 }
497
498 virtual IJsonHandler* readInt64(int64_t i) override {
499 if (!this->_arrayIsOpen) {
500 return this->invalid("An integer")->readInt64(i);
501 }
502
503 CESIUM_ASSERT(this->_pArray);
504 this->_pArray->emplace_back(static_cast<T>(i));
505 return this;
506 }
507
508 virtual IJsonHandler* readUint64(uint64_t i) override {
509 if (!this->_arrayIsOpen) {
510 return this->invalid("An integer")->readUint64(i);
511 }
512
513 CESIUM_ASSERT(this->_pArray);
514 this->_pArray->emplace_back(static_cast<T>(i));
515 return this;
516 }
517
518 virtual IJsonHandler* readDouble(double d) override {
519 return this->invalid("A double (floating-point)")->readDouble(d);
520 }
521
522 virtual IJsonHandler* readString(const std::string_view& str) override {
523 return this->invalid("A string")->readString(str);
524 }
525
526 virtual IJsonHandler* readObjectStart() override {
527 return this->invalid("An object")->readObjectStart();
528 }
529
530 virtual IJsonHandler* readArrayStart() override {
531 if (this->_arrayIsOpen) {
532 return this->invalid("An array")->readArrayStart();
533 }
534
535 this->_arrayIsOpen = true;
536 this->_pArray->clear();
537 return this;
538 }
539
540 virtual IJsonHandler* readArrayEnd() override { return this->parent(); }
541
542 virtual void reportWarning(
543 const std::string& warning,
544 std::vector<std::string>&& context =
545 std::vector<std::string>()) override {
546 context.push_back(
547 std::string("[") + std::to_string(this->_pArray->size()) + "]");
548 this->parent()->reportWarning(warning, std::move(context));
549 }
550
551private:
552 IJsonHandler* invalid(const std::string& type) {
553 if (this->_arrayIsOpen) {
554 this->reportWarning(
555 type + " value is not allowed in the integer array and has been "
556 "replaced with a default value.");
557 this->_pArray->emplace_back();
558 return this->ignoreAndContinue();
559 } else {
560 this->reportWarning(type + " is not allowed and has been ignored.");
561 return this->ignoreAndReturnToParent();
562 }
563 }
564
565 std::vector<T>* _pArray = nullptr;
566 bool _arrayIsOpen = false;
567};
568
573template <>
574class CESIUMJSONREADER_API ArrayJsonHandler<std::string, StringJsonHandler>
575 : public JsonHandler {
576public:
578 using ValueType = std::vector<std::string>;
579
580 ArrayJsonHandler() noexcept : JsonHandler() {}
581
586 void reset(IJsonHandler* pParent, std::vector<std::string>* pArray) {
587 JsonHandler::reset(pParent);
588 this->_pArray = pArray;
589 this->_arrayIsOpen = false;
590 }
591
592 virtual IJsonHandler* readNull() override {
593 return this->invalid("A null")->readNull();
594 }
595
596 virtual IJsonHandler* readBool(bool b) override {
597 return this->invalid("A bool")->readBool(b);
598 }
599
600 virtual IJsonHandler* readInt32(int32_t i) override {
601 return this->invalid("An integer")->readInt32(i);
602 }
603
604 virtual IJsonHandler* readUint32(uint32_t i) override {
605 return this->invalid("An integer")->readUint32(i);
606 }
607
608 virtual IJsonHandler* readInt64(int64_t i) override {
609 return this->invalid("An integer")->readInt64(i);
610 }
611
612 virtual IJsonHandler* readUint64(uint64_t i) override {
613 return this->invalid("An integer")->readUint64(i);
614 }
615
616 virtual IJsonHandler* readDouble(double d) override {
617 return this->invalid("A double (floating-point)")->readDouble(d);
618 }
619
620 virtual IJsonHandler* readObjectStart() override {
621 return this->invalid("An object")->readObjectStart();
622 }
623
624 virtual IJsonHandler* readArrayStart() override {
625 if (this->_arrayIsOpen) {
626 return this->invalid("An array")->readArrayStart();
627 }
628
629 this->_arrayIsOpen = true;
630 this->_pArray->clear();
631 return this;
632 }
633
634 virtual IJsonHandler* readArrayEnd() override { return this->parent(); }
635
636 virtual IJsonHandler* readString(const std::string_view& str) override {
637 if (!this->_arrayIsOpen) {
638 return this->invalid("A string")->readString(str);
639 }
640
641 CESIUM_ASSERT(this->_pArray);
642 this->_pArray->emplace_back(str);
643 return this;
644 }
645
646 virtual void reportWarning(
647 const std::string& warning,
648 std::vector<std::string>&& context =
649 std::vector<std::string>()) override {
650 context.push_back(
651 std::string("[") + std::to_string(this->_pArray->size()) + "]");
652 this->parent()->reportWarning(warning, std::move(context));
653 }
654
655private:
656 IJsonHandler* invalid(const std::string& type) {
657 if (this->_arrayIsOpen) {
658 this->reportWarning(
659 type + " value is not allowed in the string array and has been "
660 "replaced with a default value.");
661 this->_pArray->emplace_back();
662 return this->ignoreAndContinue();
663 } else {
664 this->reportWarning(type + " is not allowed and has been ignored.");
665 return this->ignoreAndReturnToParent();
666 }
667 }
668
669 std::vector<std::string>* _pArray = nullptr;
670 bool _arrayIsOpen = false;
671};
672
680template <typename T, typename THandler>
681class CESIUMJSONREADER_API
682 ArrayJsonHandler<std::vector<T>, ArrayJsonHandler<T, THandler>>
683 : public JsonHandler {
684public:
686 using ValueType = std::vector<T>;
687
694 template <typename... Ts>
695 ArrayJsonHandler(Ts&&... args) noexcept
696 : JsonHandler(),
697 _handlerFactory(
698 std::bind(handlerFactory<Ts...>, std::forward<Ts>(args)...)),
699 _elementHandler() {}
700
705 void reset(IJsonHandler* pParent, std::vector<std::vector<T>>* pArray) {
706 JsonHandler::reset(pParent);
707 this->_pArray = pArray;
708 this->_arrayIsOpen = false;
709 this->_elementHandler.reset(this->_handlerFactory());
710 }
711
712 virtual IJsonHandler* readNull() override {
713 return this->invalid("A null")->readNull();
714 }
715
716 virtual IJsonHandler* readBool(bool b) override {
717 return this->invalid("A bool")->readBool(b);
718 }
719
720 virtual IJsonHandler* readInt32(int32_t i) override {
721 return this->invalid("An integer")->readInt32(i);
722 }
723
724 virtual IJsonHandler* readUint32(uint32_t i) override {
725 return this->invalid("An integer")->readUint32(i);
726 }
727
728 virtual IJsonHandler* readInt64(int64_t i) override {
729 return this->invalid("An integer")->readInt64(i);
730 }
731
732 virtual IJsonHandler* readUint64(uint64_t i) override {
733 return this->invalid("An integer")->readUint64(i);
734 }
735
736 virtual IJsonHandler* readDouble(double d) override {
737 return this->invalid("A double (floating-point)")->readDouble(d);
738 }
739
740 virtual IJsonHandler* readString(const std::string_view& str) override {
741 return this->invalid("A string")->readString(str);
742 }
743
744 virtual IJsonHandler* readObjectStart() override {
745 return this->invalid("An object")->readObjectStart();
746 }
747
748 virtual IJsonHandler* readArrayStart() override {
749 if (this->_arrayIsOpen) {
750 CESIUM_ASSERT(this->_pArray);
751 std::vector<T>& o = this->_pArray->emplace_back();
752 this->_elementHandler->reset(this, &o);
753 return this->_elementHandler->readArrayStart();
754 } else {
755 this->_arrayIsOpen = true;
756 this->_pArray->clear();
757 return this;
758 }
759 }
760
761 virtual IJsonHandler* readArrayEnd() override { return this->parent(); }
762
763 virtual void reportWarning(
764 const std::string& warning,
765 std::vector<std::string>&& context =
766 std::vector<std::string>()) override {
767 context.push_back(
768 std::string("[") + std::to_string(this->_pArray->size()) + "]");
769 this->parent()->reportWarning(warning, std::move(context));
770 }
771
772private:
773 IJsonHandler* invalid(const std::string& type) {
774 if (this->_arrayIsOpen) {
775 this->reportWarning(
776 type + " value is not allowed in the array of arrays and has been "
777 "replaced with a default value.");
778 this->_pArray->emplace_back();
779 return this->ignoreAndContinue();
780 } else {
781 this->reportWarning(type + " is not allowed and has been ignored.");
782 return this->ignoreAndReturnToParent();
783 }
784 }
785
786 template <typename... Ts>
787 static ArrayJsonHandler<T, THandler>* handlerFactory(Ts&&... args) {
788 return new ArrayJsonHandler<T, THandler>(std::forward<Ts>(args)...);
789 }
790
791 std::vector<std::vector<T>>* _pArray = nullptr;
792 bool _arrayIsOpen = false;
793
794 std::function<ArrayJsonHandler<T, THandler>*()> _handlerFactory;
795 std::unique_ptr<ArrayJsonHandler<T, THandler>> _elementHandler;
796};
797
798} // namespace CesiumJsonReader
virtual IJsonHandler * readInt32(int32_t i) override
Called when the JSON parser encounters an int32 value.
virtual IJsonHandler * readUint32(uint32_t i) override
Called when the JSON parser encounters a uint32 value.
virtual IJsonHandler * readString(const std::string_view &str) override
Called when the JSON parser encounters a string value.
virtual IJsonHandler * readInt64(int64_t i) override
Called when the JSON parser encounters an int64 value.
virtual IJsonHandler * readUint64(uint64_t i) override
Called when the JSON parser encounters a uint64 value.
virtual void reportWarning(const std::string &warning, std::vector< std::string > &&context=std::vector< std::string >()) override
Report a warning while reading JSON.
virtual IJsonHandler * readArrayEnd() override
Called when the JSON parser encounters the end of an array.
virtual IJsonHandler * readObjectKey(const std::string_view &str) override
Called when the JSON parser encounters a key while reading an object.
virtual IJsonHandler * readNull() override
Called when the JSON parser encounters a null.
virtual IJsonHandler * readObjectEnd() override
Called when the JSON parser encounters the end of an object.
void reset(IJsonHandler *pParent, std::vector< CesiumUtility::JsonValue > *pArray)
Resets the parent and destination array of this ArrayJsonHandler.
virtual IJsonHandler * readObjectStart() override
Called when the JSON parser encounters the beginning of an object.
virtual IJsonHandler * readArrayStart() override
Called when the JSON parser encounters the start of an array.
virtual IJsonHandler * readBool(bool b) override
Called when the JSON parser encounters a boolean value.
std::vector< CesiumUtility::JsonValue > ValueType
The destination type.
virtual IJsonHandler * readDouble(double d) override
Called when the JSON parser encounters a double value.
virtual IJsonHandler * readUint32(uint32_t i) override
Called when the JSON parser encounters a uint32 value.
virtual IJsonHandler * readString(const std::string_view &str) override
Called when the JSON parser encounters a string value.
virtual IJsonHandler * readObjectStart() override
Called when the JSON parser encounters the beginning of an object.
virtual IJsonHandler * readArrayStart() override
Called when the JSON parser encounters the start of an array.
virtual void reportWarning(const std::string &warning, std::vector< std::string > &&context=std::vector< std::string >()) override
Report a warning while reading JSON.
virtual IJsonHandler * readArrayEnd() override
Called when the JSON parser encounters the end of an array.
virtual IJsonHandler * readUint64(uint64_t i) override
Called when the JSON parser encounters a uint64 value.
virtual IJsonHandler * readDouble(double d) override
Called when the JSON parser encounters a double value.
virtual IJsonHandler * readNull() override
Called when the JSON parser encounters a null.
void reset(IJsonHandler *pParent, std::vector< T > *pArray)
Resets the parent and destination array of this ArrayJsonHandler.
virtual IJsonHandler * readInt64(int64_t i) override
Called when the JSON parser encounters an int64 value.
virtual IJsonHandler * readInt32(int32_t i) override
Called when the JSON parser encounters an int32 value.
virtual IJsonHandler * readBool(bool b) override
Called when the JSON parser encounters a boolean value.
virtual IJsonHandler * readInt64(int64_t i) override
Called when the JSON parser encounters an int64 value.
virtual IJsonHandler * readUint64(uint64_t i) override
Called when the JSON parser encounters a uint64 value.
virtual IJsonHandler * readNull() override
Called when the JSON parser encounters a null.
virtual IJsonHandler * readDouble(double d) override
Called when the JSON parser encounters a double value.
virtual IJsonHandler * readObjectStart() override
Called when the JSON parser encounters the beginning of an object.
virtual IJsonHandler * readString(const std::string_view &str) override
Called when the JSON parser encounters a string value.
virtual IJsonHandler * readUint32(uint32_t i) override
Called when the JSON parser encounters a uint32 value.
virtual IJsonHandler * readBool(bool b) override
Called when the JSON parser encounters a boolean value.
virtual IJsonHandler * readArrayStart() override
Called when the JSON parser encounters the start of an array.
virtual IJsonHandler * readArrayEnd() override
Called when the JSON parser encounters the end of an array.
void reset(IJsonHandler *pParent, std::vector< double > *pArray)
Resets the parent and destination array of this ArrayJsonHandler.
virtual void reportWarning(const std::string &warning, std::vector< std::string > &&context=std::vector< std::string >()) override
Report a warning while reading JSON.
virtual IJsonHandler * readInt32(int32_t i) override
Called when the JSON parser encounters an int32 value.
virtual IJsonHandler * readArrayEnd() override
Called when the JSON parser encounters the end of an array.
virtual IJsonHandler * readInt32(int32_t i) override
Called when the JSON parser encounters an int32 value.
virtual IJsonHandler * readArrayStart() override
Called when the JSON parser encounters the start of an array.
virtual IJsonHandler * readUint32(uint32_t i) override
Called when the JSON parser encounters a uint32 value.
virtual IJsonHandler * readObjectStart() override
Called when the JSON parser encounters the beginning of an object.
virtual IJsonHandler * readDouble(double d) override
Called when the JSON parser encounters a double value.
void reset(IJsonHandler *pParent, std::vector< std::string > *pArray)
Resets the parent and destination array of this ArrayJsonHandler.
virtual IJsonHandler * readNull() override
Called when the JSON parser encounters a null.
virtual IJsonHandler * readBool(bool b) override
Called when the JSON parser encounters a boolean value.
virtual IJsonHandler * readInt64(int64_t i) override
Called when the JSON parser encounters an int64 value.
virtual IJsonHandler * readString(const std::string_view &str) override
Called when the JSON parser encounters a string value.
std::vector< std::string > ValueType
The destination type.
virtual void reportWarning(const std::string &warning, std::vector< std::string > &&context=std::vector< std::string >()) override
Report a warning while reading JSON.
virtual IJsonHandler * readUint64(uint64_t i) override
Called when the JSON parser encounters a uint64 value.
virtual IJsonHandler * readNull() override
Called when the JSON parser encounters a null.
virtual void reportWarning(const std::string &warning, std::vector< std::string > &&context=std::vector< std::string >()) override
Report a warning while reading JSON.
virtual IJsonHandler * readUint32(uint32_t i) override
Called when the JSON parser encounters a uint32 value.
virtual IJsonHandler * readArrayStart() override
Called when the JSON parser encounters the start of an array.
virtual IJsonHandler * readArrayEnd() override
Called when the JSON parser encounters the end of an array.
virtual IJsonHandler * readUint64(uint64_t i) override
Called when the JSON parser encounters a uint64 value.
void reset(IJsonHandler *pParent, std::vector< std::vector< T > > *pArray)
Resets the parent and destination array of this ArrayJsonHandler.
virtual IJsonHandler * readDouble(double d) override
Called when the JSON parser encounters a double value.
virtual IJsonHandler * readString(const std::string_view &str) override
Called when the JSON parser encounters a string value.
virtual IJsonHandler * readObjectStart() override
Called when the JSON parser encounters the beginning of an object.
virtual IJsonHandler * readBool(bool b) override
Called when the JSON parser encounters a boolean value.
virtual IJsonHandler * readInt64(int64_t i) override
Called when the JSON parser encounters an int64 value.
virtual IJsonHandler * readInt32(int32_t i) override
Called when the JSON parser encounters an int32 value.
virtual IJsonHandler * readObjectStart() override
Called when the JSON parser encounters the beginning of an object.
virtual IJsonHandler * readArrayStart() override
Called when the JSON parser encounters the start of an array.
std::vector< T > ValueType
The destination type.
void reset(IJsonHandler *pParent, std::vector< T > *pArray)
Resets the parent and destination array of this ArrayJsonHandler.
virtual IJsonHandler * readObjectKey(const std::string_view &str) noexcept override
Called when the JSON parser encounters a key while reading an object.
virtual IJsonHandler * readInt64(int64_t i) override
Called when the JSON parser encounters an int64 value.
virtual IJsonHandler * readUint32(uint32_t i) override
Called when the JSON parser encounters a uint32 value.
virtual IJsonHandler * readString(const std::string_view &str) override
Called when the JSON parser encounters a string value.
virtual IJsonHandler * readArrayEnd() override
Called when the JSON parser encounters the end of an array.
ArrayJsonHandler(Ts &&... args) noexcept
Creates a new ArrayJsonHandler.
virtual IJsonHandler * readUint64(uint64_t i) override
Called when the JSON parser encounters a uint64 value.
virtual IJsonHandler * readDouble(double d) override
Called when the JSON parser encounters a double value.
virtual IJsonHandler * readBool(bool b) override
Called when the JSON parser encounters a boolean value.
virtual IJsonHandler * readNull() override
Called when the JSON parser encounters a null.
virtual IJsonHandler * readInt32(int32_t i) override
Called when the JSON parser encounters an int32 value.
virtual void reportWarning(const std::string &warning, std::vector< std::string > &&context=std::vector< std::string >()) override
Report a warning while reading JSON.
virtual IJsonHandler * readObjectEnd() noexcept override
Called when the JSON parser encounters the end of an object.
IJsonHandler for reading double values.
Base interface for all JSON handlers. Types that need to be deserialized from JSON should implement I...
virtual IJsonHandler * readUint32(uint32_t i)=0
Called when the JSON parser encounters a uint32 value.
virtual IJsonHandler * readObjectKey(const std::string_view &str)=0
Called when the JSON parser encounters a key while reading an object.
virtual IJsonHandler * readUint64(uint64_t i)=0
Called when the JSON parser encounters a uint64 value.
virtual IJsonHandler * readNull()=0
Called when the JSON parser encounters a null.
virtual IJsonHandler * readObjectEnd()=0
Called when the JSON parser encounters the end of an object.
virtual IJsonHandler * readDouble(double d)=0
Called when the JSON parser encounters a double value.
virtual IJsonHandler * readBool(bool b)=0
Called when the JSON parser encounters a boolean value.
virtual IJsonHandler * readObjectStart()=0
Called when the JSON parser encounters the beginning of an object.
virtual IJsonHandler * readString(const std::string_view &str)=0
Called when the JSON parser encounters a string value.
virtual IJsonHandler * readInt64(int64_t i)=0
Called when the JSON parser encounters an int64 value.
virtual IJsonHandler * readInt32(int32_t i)=0
Called when the JSON parser encounters an int32 value.
IJsonHandler for reading integer values.
IJsonHandler * parent()
Obtains the parent IJsonHandler of this handler.
void reset(IJsonHandler *pParent)
Resets the parent IJsonHandler of this handler.
IJsonHandler for arbitrary CesiumUtility::JsonValue JsonValue objects.
IJsonHandler for reading string values.
A generic implementation of a value in a JSON structure.
Definition JsonValue.h:53
Classes for reading JSON.
Utility classes for Cesium.
STL namespace.