3 #include "CesiumJsonWriter/JsonWriter.h"
4 #include "CesiumJsonWriter/Library.h"
10 #include <unordered_map>
37 template <
typename TExtension>
38 using ExtensionHandler = std::function<
49 template <
typename TExtended,
typename TExtensionHandler>
51 using TExtension =
typename TExtensionHandler::ValueType;
54 this->_extensions.emplace(extensionName, ObjectTypeToHandler()).first;
55 it->second.insert_or_assign(
57 [](
const std::any& obj,
60 return TExtensionHandler::write(
61 std::any_cast<const TExtension&>(obj),
75 template <
typename TExtended,
typename TExtensionHandler>
77 registerExtension<TExtended, TExtensionHandler>(
78 TExtensionHandler::ExtensionName);
105 ExtensionHandler<std::any> createExtensionHandler(
106 const std::string_view& extensionName,
108 const std::string& extendedObjectType)
const;
111 using ObjectTypeToHandler =
112 std::unordered_map<std::string, ExtensionHandler<std::any>>;
113 using ExtensionNameMap = std::map<std::string, ObjectTypeToHandler>;
115 ExtensionNameMap _extensions;
116 std::unordered_map<std::string, ExtensionState> _extensionStates;
void setExtensionState(const std::string &extensionName, ExtensionState newState)
Enables or disables an extension.
void registerExtension(const std::string &extensionName)
Registers an extension for an object.
void registerExtension()
Registers an extension for an object.
ExtensionState getExtensionState(const std::string &extensionName) const
Returns whether an extension is enabled or disabled.
Classes for writing JSON.
ExtensionState
The state of an extension.
@ Enabled
The extension is enabled.
@ Disabled
The extension is disabled.