3#include "CesiumUtility/Assert.h"
4#include "IntegerJsonHandler.h"
6#include "ObjectJsonHandler.h"
9#include <unordered_map>
19template <
typename T,
typename THandler>
26 template <
typename... Ts>
42 std::unordered_map<std::string, T>* pDictionary) {
43 ObjectJsonHandler::reset(pParent);
44 this->_pDictionary1 = pDictionary;
52 ObjectJsonHandler::reset(pParent);
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;
Reads the keys and values of a JSON object into a std::map<std::string, T> or an std::unordered_map<s...
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...
IJsonHandler for handling JSON objects.
Classes for reading JSON.