cesium-native 0.43.0
Loading...
Searching...
No Matches
CesiumJsonWriter Namespace Reference

Classes for writing JSON. More...

Classes

class  ExtensionWriterContext
 A context for writing extensions where known extensions and their handlers can be registered. More...
 
class  JsonWriter
 Wrapper around rapidjson::Writer for writing objects to JSON. More...
 
class  PrettyJsonWriter
 Implementation of JsonWriter that "pretty-prints" JSON to the output, formatted with new lines and indentation. More...
 

Enumerations

enum class  ExtensionState { Enabled , Disabled }
 The state of an extension. More...
 

Functions

void writeJsonValue (const CesiumUtility::JsonValue &value, JsonWriter &writer)
 Writes the given CesiumUtility::JsonValue to the provided writer.
 
template<typename TExtended >
void writeJsonExtensions (const TExtended &obj, JsonWriter &jsonWriter, const ExtensionWriterContext &context)
 Writes the extensions attached to the provided object as a new JSON object.
 
template<typename TExtended >
bool hasRegisteredExtensions (const TExtended &obj, JsonWriter &jsonWriter, const ExtensionWriterContext &context)
 Checks if the provided object has any extensions attached that have been registered with the provided ExtensionWriterContext.
 

Detailed Description

Classes for writing JSON.

--- comment: This file was generated by dep-graph-gen. DO NOT EDIT THIS FILE! title: CesiumJsonWriter Dependency Graph --- graph TD classDef dependencyNode fill:#fff,stroke:#ccc,color:#666,font-weight:bold,font-size:28px classDef libraryNode fill:#9f9,font-weight:bold,font-size:28px CesiumJsonWriter[CesiumJsonWriter] --> CesiumUtility[CesiumUtility] class CesiumUtility,CesiumJsonWriter libraryNode

Enumeration Type Documentation

◆ ExtensionState

The state of an extension.

Enumerator
Enabled 

The extension is enabled.

If the extension is a CesiumUtility::JsonValue or a registered statically-typed class it will be written to the serialized model; otherwise it will be ignored and a warning will be reported.

Disabled 

The extension is disabled.

It will not be represented in the serialized model at all.

Definition at line 17 of file ExtensionWriterContext.h.

Function Documentation

◆ hasRegisteredExtensions()

template<typename TExtended >
bool CesiumJsonWriter::hasRegisteredExtensions ( const TExtended & obj,
JsonWriter & jsonWriter,
const ExtensionWriterContext & context )

Checks if the provided object has any extensions attached that have been registered with the provided ExtensionWriterContext.

Template Parameters
TExtendedThe type with extensions attached to write. This type must have an extensions property of type std::unordered_map<std::string, std::any> or a similar type with an empty() method that returns pairs of <std::string, std::any> when iterated.
Parameters
objThe object with extensions to write.
jsonWriterThe writer to write the extensions object to.
contextThe ExtensionWriterContext with registered extensions.
Returns
True if any extensions attached to obj have been registered, false otherwise.

Definition at line 60 of file writeJsonExtensions.h.

◆ writeJsonExtensions()

template<typename TExtended >
void CesiumJsonWriter::writeJsonExtensions ( const TExtended & obj,
JsonWriter & jsonWriter,
const ExtensionWriterContext & context )

Writes the extensions attached to the provided object as a new JSON object.

Template Parameters
TExtendedThe type with extensions attached to write. This type must have an extensions property of type std::unordered_map<std::string, std::any> or a similar type with an empty() method that returns pairs of <std::string, std::any> when iterated.
Parameters
objThe object with extensions to write.
jsonWriterThe writer to write the extensions object to.
contextThe ExtensionWriterContext that provides information on how to write each extension.

Definition at line 24 of file writeJsonExtensions.h.

◆ writeJsonValue()

void CesiumJsonWriter::writeJsonValue ( const CesiumUtility::JsonValue & value,
JsonWriter & writer )

Writes the given CesiumUtility::JsonValue to the provided writer.

Parameters
valueThe value to write.
writerThe writer used to write the provided value.