3#include <CesiumJsonReader/IntegerJsonHandler.h>
4#include <CesiumJsonReader/Library.h>
5#include <CesiumJsonReader/ObjectJsonHandler.h>
6#include <CesiumUtility/Assert.h>
9#include <unordered_map>
19template <
typename T,
typename THandler>
26 template <
typename... Ts>
28 : ObjectJsonHandler(), _item(std::forward<Ts>(args)...) {}
42 std::unordered_map<std::string, T>* pDictionary) {
44 this->_pDictionary1 = pDictionary;
53 this->_pDictionary2 = pDictionary;
58 CESIUM_ASSERT(this->_pDictionary1 || this->_pDictionary2);
60 if (this->_pDictionary1) {
61 auto it = this->_pDictionary1->emplace(str, T()).first;
63 return this->
property(it->first.c_str(), this->_item, it->second);
66 auto it = this->_pDictionary2->emplace(str, T()).first;
68 return this->
property(it->first.c_str(), this->_item, it->second);
72 std::unordered_map<std::string, T>* _pDictionary1 =
nullptr;
73 std::map<std::string, T>* _pDictionary2 =
nullptr;
virtual IJsonHandler * readObjectKey(const std::string_view &str) override
Called when the JSON parser encounters a key while reading an object.
void reset(IJsonHandler *pParent, std::unordered_map< std::string, T > *pDictionary)
Resets the parent of this IJsonHandler and sets the destination pointer of this handler to an std::un...
void reset(IJsonHandler *pParent, std::map< std::string, T > *pDictionary)
Resets the parent of this IJsonHandler and sets the destination pointer of this handler to an std::ma...
DictionaryJsonHandler(Ts &&... args) noexcept
Creates a new DictionaryJsonHandler, passing the specified arguments to the constructor of THandler.
Base interface for all JSON handlers. Types that need to be deserialized from JSON should implement I...
void reset(IJsonHandler *pParent)
Resets the parent IJsonHandler of this handler.
IJsonHandler * property(const char *currentKey, TAccessor &accessor, TProperty &value)
Called from IJsonHandler::readObjectKey to read a property into an object.
Classes for reading JSON.