cesium-native 0.64.0
Loading...
Searching...
No Matches
CesiumJsonReader::DictionaryJsonHandler< T, THandler > Class Template Reference

Reads the keys and values of a JSON object into a std::map<std::string, T> or an std::unordered_map<std::string, T>. More...

#include <CesiumJsonReader/DictionaryJsonHandler.h>

Inheritance diagram for CesiumJsonReader::DictionaryJsonHandler< T, THandler >:
CesiumJsonReader::ObjectJsonHandler CesiumJsonReader::JsonHandler CesiumJsonReader::IJsonHandler

Public Member Functions

template<typename... Ts>
 DictionaryJsonHandler (Ts &&... args) noexcept
 Creates a new DictionaryJsonHandler, passing the specified arguments to the constructor of THandler.
 
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::unordered_map<std::string, T>.
 
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::map<std::string, T>.
 
virtual IJsonHandler * readObjectKey (const std::string_view &str) override
 Called when the JSON parser encounters a key while reading an object.
 
- Public Member Functions inherited from CesiumJsonReader::ObjectJsonHandler
virtual IJsonHandler * readObjectStart () override
 Called when the JSON parser encounters the beginning of an object.
 
virtual IJsonHandler * readObjectEnd () override
 Called when the JSON parser encounters the end of an object.
 
- Public Member Functions inherited from CesiumJsonReader::JsonHandler
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 * 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 * 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 * 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 * 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.
 

Additional Inherited Members

- Protected Member Functions inherited from CesiumJsonReader::ObjectJsonHandler
virtual IJsonHandler * StartSubObject () noexcept
 Called when readObjectStart is called when the depth of the ObjectJsonHandler is greater than 0.
 
virtual IJsonHandler * EndSubObject () noexcept
 Called when readObjectEnd is called when the depth of the ObjectJsonHandler is greater than 0.
 
template<typename TAccessor, typename TProperty>
IJsonHandler * property (const char *currentKey, TAccessor &accessor, TProperty &value)
 Called from IJsonHandler::readObjectKey to read a property into an object.
 
const char * getCurrentKey () const noexcept
 Obtains the most recent key handled by this JsonHandler.
 
virtual void reportWarning (const std::string &warning, std::vector< std::string > &&context=std::vector< std::string >()) override
 Report a warning while reading JSON.
 
void setCurrentKey (const char *key) noexcept
 Sets the most recent key handled by this JsonHandler.
 
- Protected Member Functions inherited from CesiumJsonReader::JsonHandler
void reset (IJsonHandler *pParent)
 Resets the parent IJsonHandler of this handler.
 
IJsonHandler * parent ()
 Obtains the parent IJsonHandler of this handler.
 
IJsonHandler * ignoreAndReturnToParent ()
 Ignore a single value and then return to the parent handler.
 
IJsonHandler * ignoreAndContinue ()
 Ignore a single value and the continue processing more tokens with this handler.
 

Detailed Description

template<typename T, typename THandler>
class CesiumJsonReader::DictionaryJsonHandler< T, THandler >

Reads the keys and values of a JSON object into a std::map<std::string, T> or an std::unordered_map<std::string, T>.

Template Parameters
TThe type of values in the map.
THandlerThe type of the IJsonHandler to handle the map values.

Definition at line 20 of file DictionaryJsonHandler.h.

Constructor & Destructor Documentation

◆ DictionaryJsonHandler()

template<typename T, typename THandler>
template<typename... Ts>
CesiumJsonReader::DictionaryJsonHandler< T, THandler >::DictionaryJsonHandler ( Ts &&... args)
inlinenoexcept

Creates a new DictionaryJsonHandler, passing the specified arguments to the constructor of THandler.

Definition at line 27 of file DictionaryJsonHandler.h.

Member Function Documentation

◆ readObjectKey()

template<typename T, typename THandler>
virtual IJsonHandler * CesiumJsonReader::DictionaryJsonHandler< T, THandler >::readObjectKey ( const std::string_view & str)
inlineoverridevirtual

Called when the JSON parser encounters a key while reading an object.

Parameters
strThe key.
Returns
A IJsonHandler that will handle the next read... call. This can be the same handler as the current one.

Reimplemented from CesiumJsonReader::JsonHandler.

Definition at line 57 of file DictionaryJsonHandler.h.

◆ reset() [1/2]

template<typename T, typename THandler>
void CesiumJsonReader::DictionaryJsonHandler< T, THandler >::reset ( IJsonHandler * pParent,
std::map< std::string, T > * pDictionary )
inline

Resets the parent of this IJsonHandler and sets the destination pointer of this handler to an std::map<std::string, T>.

Definition at line 51 of file DictionaryJsonHandler.h.

◆ reset() [2/2]

template<typename T, typename THandler>
void CesiumJsonReader::DictionaryJsonHandler< T, THandler >::reset ( IJsonHandler * pParent,
std::unordered_map< std::string, T > * pDictionary )
inline

Resets the parent of this IJsonHandler and sets the destination pointer of this handler to an std::unordered_map<std::string, T>.

Warning
Technically, there is no reason why you can't call reset twice on the same DictionaryJsonHandler, once with an std::map and once with an std::unordered_map. In practice, if a pointer to an std::unordered_map is present, it will always be used as the destination and the pointer to an std::map will be ignored.

Definition at line 40 of file DictionaryJsonHandler.h.


The documentation for this class was generated from the following file: