cesium-native 0.43.0
Loading...
Searching...
No Matches
CesiumJsonWriter::ExtensionWriterContext Class Reference

A context for writing extensions where known extensions and their handlers can be registered. More...

#include <CesiumJsonWriter/ExtensionWriterContext.h>

Public Member Functions

template<typename TExtended , typename TExtensionHandler >
void registerExtension (const std::string &extensionName)
 Registers an extension for an object.
 
template<typename TExtended , typename TExtensionHandler >
void registerExtension ()
 Registers an extension for an object.
 
ExtensionState getExtensionState (const std::string &extensionName) const
 Returns whether an extension is enabled or disabled.
 
void setExtensionState (const std::string &extensionName, ExtensionState newState)
 Enables or disables an extension.
 
ExtensionHandler< std::any > createExtensionHandler (const std::string_view &extensionName, const std::any &obj, const std::string &extendedObjectType) const
 Attempts to create an ExtensionHandler for the given object, returning nullptr if no handler could be found.
 

Detailed Description

A context for writing extensions where known extensions and their handlers can be registered.

Definition at line 39 of file ExtensionWriterContext.h.

Member Function Documentation

◆ createExtensionHandler()

ExtensionHandler< std::any > CesiumJsonWriter::ExtensionWriterContext::createExtensionHandler ( const std::string_view & extensionName,
const std::any & obj,
const std::string & extendedObjectType ) const

Attempts to create an ExtensionHandler for the given object, returning nullptr if no handler could be found.

Parameters
extensionNameThe name of the extension.
objThe object of unknown type to create the handler for.
extendedObjectTypeThe TypeName of the extended object.
Returns
The handler for this extension, or nullptr if none could be created.

◆ getExtensionState()

ExtensionState CesiumJsonWriter::ExtensionWriterContext::getExtensionState ( const std::string & extensionName) const

Returns whether an extension is enabled or disabled.

By default, all extensions are enabled.

Parameters
extensionNameThe name of the extension.

◆ registerExtension() [1/2]

template<typename TExtended , typename TExtensionHandler >
void CesiumJsonWriter::ExtensionWriterContext::registerExtension ( )
inline

Registers an extension for an object.

The extension name is obtained from TExtensionHandler::ExtensionName.

Template Parameters
TExtendedThe object to extend.
TExtensionHandlerThe extension's writer.

Definition at line 80 of file ExtensionWriterContext.h.

◆ registerExtension() [2/2]

template<typename TExtended , typename TExtensionHandler >
void CesiumJsonWriter::ExtensionWriterContext::registerExtension ( const std::string & extensionName)
inline

Registers an extension for an object.

Template Parameters
TExtendedThe object to extend.
TExtensionHandlerThe extension's writer.
Parameters
extensionNameThe name of the extension.

Definition at line 54 of file ExtensionWriterContext.h.

◆ setExtensionState()

void CesiumJsonWriter::ExtensionWriterContext::setExtensionState ( const std::string & extensionName,
ExtensionState newState )

Enables or disables an extension.

By default, all extensions are enabled. However, if the extension is a statically-typed class and is not registered it will be ignored and a warning will be reported.

When a disabled extension is encountered, it is ignored completely.

Parameters
extensionNameThe name of the extension to be enabled or disabled.
newStateThe new state for the extension.

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