3#include <CesiumJsonReader/JsonHandler.h>
4#include <CesiumJsonReader/Library.h>
5#include <CesiumUtility/IntrusivePointer.h>
13class CESIUMJSONREADER_API ObjectJsonHandler :
public JsonHandler {
15 ObjectJsonHandler() noexcept : JsonHandler() {}
45 template <typename TAccessor, typename TProperty>
47 property(const
char* currentKey, TAccessor& accessor, TProperty& value) {
48 this->_currentKey = currentKey;
50 if constexpr (isOptional<TProperty>::value) {
52 accessor.reset(
this, &value.value());
53 }
else if constexpr (isIntrusivePointer<TProperty>::value) {
55 accessor.reset(
this, value.get());
57 accessor.reset(
this, &value);
70 const
std::
string& warning,
71 std::vector<
std::
string>&& context =
std::vector<
std::
string>()) override;
80 template <typename T> struct isOptional {
81 static constexpr bool value =
false;
84 template <
typename T>
struct isOptional<
std::optional<T>> {
85 static constexpr bool value =
true;
88 template <
typename T>
struct isIntrusivePointer {
89 static constexpr bool value =
false;
93 struct isIntrusivePointer<CesiumUtility::IntrusivePointer<T>> {
94 static constexpr bool value =
true;
98 const char* _currentKey =
nullptr;
Base interface for all JSON handlers. Types that need to be deserialized from JSON should implement I...
IJsonHandler * property(const char *currentKey, TAccessor &accessor, TProperty &value)
Called from IJsonHandler::readObjectKey to read a property into an object.
virtual IJsonHandler * EndSubObject() noexcept
Called when readObjectEnd is called when the depth of the ObjectJsonHandler is greater than 0.
virtual IJsonHandler * readObjectEnd() override
Called when the JSON parser encounters the end of an object.
virtual IJsonHandler * readObjectStart() override
Called when the JSON parser encounters the beginning of an object.
void setCurrentKey(const char *key) noexcept
Sets the most recent key handled by this JsonHandler.
virtual IJsonHandler * StartSubObject() noexcept
Called when readObjectStart is called when the depth of the ObjectJsonHandler is greater than 0.
virtual void reportWarning(const std::string &warning, std::vector< std::string > &&context=std::vector< std::string >()) override
Report a warning while reading JSON.
const char * getCurrentKey() const noexcept
Obtains the most recent key handled by this JsonHandler.
Classes for reading JSON.