![]() |
Plasma Engine
2.0
|
The base class for JSON writers. More...
#include <JSONWriter.h>
Public Types | |
enum class | WhitespaceMode { All , LessIndentation , NoIndentation , NewlinesOnly , None } |
Modes to configure how much whitespace the JSON writer will output. More... | |
enum class | ArrayMode { InOneLine , OneLinePerItem } |
Modes to configure how arrays are written. More... | |
Public Member Functions | |
plJSONWriter () | |
Constructor. | |
virtual | ~plJSONWriter () |
Destructor. | |
void | SetWhitespaceMode (WhitespaceMode whitespaceMode) |
Configures how much whitespace is output. | |
void | SetArrayMode (ArrayMode arrayMode) |
Configures how arrays are written. | |
void | AddVariableBool (plStringView sName, bool value) |
Shorthand for "BeginVariable(szName); WriteBool(value); EndVariable(); ". | |
void | AddVariableInt32 (plStringView sName, plInt32 value) |
Shorthand for "BeginVariable(szName); WriteInt32(value); EndVariable(); ". | |
void | AddVariableUInt32 (plStringView sName, plUInt32 value) |
Shorthand for "BeginVariable(szName); WriteUInt32(value); EndVariable(); ". | |
void | AddVariableInt64 (plStringView sName, plInt64 value) |
Shorthand for "BeginVariable(szName); WriteInt64(value); EndVariable(); ". | |
void | AddVariableUInt64 (plStringView sName, plUInt64 value) |
Shorthand for "BeginVariable(szName); WriteUInt64(value); EndVariable(); ". | |
void | AddVariableFloat (plStringView sName, float value) |
Shorthand for "BeginVariable(szName); WriteFloat(value); EndVariable(); ". | |
void | AddVariableDouble (plStringView sName, double value) |
Shorthand for "BeginVariable(szName); WriteDouble(value); EndVariable(); ". | |
void | AddVariableString (plStringView sName, plStringView value) |
Shorthand for "BeginVariable(szName); WriteString(value); EndVariable(); ". | |
void | AddVariableNULL (plStringView sName) |
Shorthand for "BeginVariable(szName); WriteNULL(value); EndVariable(); ". | |
void | AddVariableTime (plStringView sName, plTime value) |
Shorthand for "BeginVariable(szName); WriteTime(value); EndVariable(); ". | |
void | AddVariableUuid (plStringView sName, plUuid value) |
Shorthand for "BeginVariable(szName); WriteUuid(value); EndVariable(); ". | |
void | AddVariableAngle (plStringView sName, plAngle value) |
Shorthand for "BeginVariable(szName); WriteAngle(value); EndVariable(); ". | |
void | AddVariableColor (plStringView sName, const plColor &value) |
Shorthand for "BeginVariable(szName); WriteColor(value); EndVariable(); ". | |
void | AddVariableColorGamma (plStringView sName, const plColorGammaUB &value) |
Shorthand for "BeginVariable(szName); WriteColorGamma(value); EndVariable(); ". | |
void | AddVariableVec2 (plStringView sName, const plVec2 &value) |
Shorthand for "BeginVariable(szName); WriteVec2(value); EndVariable(); ". | |
void | AddVariableVec3 (plStringView sName, const plVec3 &value) |
Shorthand for "BeginVariable(szName); WriteVec3(value); EndVariable(); ". | |
void | AddVariableVec4 (plStringView sName, const plVec4 &value) |
Shorthand for "BeginVariable(szName); WriteVec4(value); EndVariable(); ". | |
void | AddVariableVec2I32 (plStringView sName, const plVec2I32 &value) |
Shorthand for "BeginVariable(szName); WriteVec2I32(value); EndVariable(); ". | |
void | AddVariableVec3I32 (plStringView sName, const plVec3I32 &value) |
Shorthand for "BeginVariable(szName); WriteVec3I32(value); EndVariable(); ". | |
void | AddVariableVec4I32 (plStringView sName, const plVec4I32 &value) |
Shorthand for "BeginVariable(szName); WriteVec4I32(value); EndVariable(); ". | |
void | AddVariableQuat (plStringView sName, const plQuat &value) |
Shorthand for "BeginVariable(szName); WriteQuat(value); EndVariable(); ". | |
void | AddVariableMat3 (plStringView sName, const plMat3 &value) |
Shorthand for "BeginVariable(szName); WriteMat3(value); EndVariable(); ". | |
void | AddVariableMat4 (plStringView sName, const plMat4 &value) |
Shorthand for "BeginVariable(szName); WriteMat4(value); EndVariable(); ". | |
void | AddVariableDataBuffer (plStringView sName, const plDataBuffer &value) |
Shorthand for "BeginVariable(szName); WriteDataBuffer(value); EndVariable(); ". | |
void | AddVariableVariant (plStringView sName, const plVariant &value) |
Shorthand for "BeginVariable(szName); WriteVariant(value); EndVariable(); ". | |
virtual void | WriteBool (bool value)=0 |
Writes a bool to the JSON file. Can only be called between BeginVariable() / EndVariable() or BeginArray() / EndArray(). | |
virtual void | WriteInt32 (plInt32 value)=0 |
Writes an int32 to the JSON file. Can only be called between BeginVariable() / EndVariable() or BeginArray() / EndArray(). | |
virtual void | WriteUInt32 (plUInt32 value)=0 |
Writes a uint32 to the JSON file. Can only be called between BeginVariable() / EndVariable() or BeginArray() / EndArray(). | |
virtual void | WriteInt64 (plInt64 value)=0 |
Writes an int64 to the JSON file. Can only be called between BeginVariable() / EndVariable() or BeginArray() / EndArray(). | |
virtual void | WriteUInt64 (plUInt64 value)=0 |
Writes a uint64 to the JSON file. Can only be called between BeginVariable() / EndVariable() or BeginArray() / EndArray(). | |
virtual void | WriteFloat (float value)=0 |
Writes a float to the JSON file. Can only be called between BeginVariable() / EndVariable() or BeginArray() / EndArray(). | |
virtual void | WriteDouble (double value)=0 |
Writes a double to the JSON file. Can only be called between BeginVariable() / EndVariable() or BeginArray() / EndArray(). | |
virtual void | WriteString (plStringView value)=0 |
Writes a string to the JSON file. Can only be called between BeginVariable() / EndVariable() or BeginArray() / EndArray(). | |
virtual void | WriteNULL ()=0 |
Writes the value 'null' to the JSON file. Can only be called between BeginVariable() / EndVariable() or BeginArray() / EndArray(). | |
virtual void | WriteTime (plTime value)=0 |
Writes a time value to the JSON file. Can only be called between BeginVariable() / EndVariable() or BeginArray() / EndArray(). | |
virtual void | WriteColor (const plColor &value)=0 |
Writes an plColor to the JSON file. Can only be called between BeginVariable() / EndVariable() or BeginArray() / EndArray(). | |
virtual void | WriteColorGamma (const plColorGammaUB &value)=0 |
Writes an plColorGammaUB to the JSON file. Can only be called between BeginVariable() / EndVariable() or BeginArray() / EndArray(). | |
virtual void | WriteVec2 (const plVec2 &value)=0 |
Writes an plVec2 to the JSON file. Can only be called between BeginVariable() / EndVariable() or BeginArray() / EndArray(). | |
virtual void | WriteVec3 (const plVec3 &value)=0 |
Writes an plVec3 to the JSON file. Can only be called between BeginVariable() / EndVariable() or BeginArray() / EndArray(). | |
virtual void | WriteVec4 (const plVec4 &value)=0 |
Writes an plVec4 to the JSON file. Can only be called between BeginVariable() / EndVariable() or BeginArray() / EndArray(). | |
virtual void | WriteVec2I32 (const plVec2I32 &value)=0 |
Writes an plVec2I32 to the JSON file. Can only be called between BeginVariable() / EndVariable() or BeginArray() / EndArray(). | |
virtual void | WriteVec3I32 (const plVec3I32 &value)=0 |
Writes an plVec3I32 to the JSON file. Can only be called between BeginVariable() / EndVariable() or BeginArray() / EndArray(). | |
virtual void | WriteVec4I32 (const plVec4I32 &value)=0 |
Writes an plVec4I32 to the JSON file. Can only be called between BeginVariable() / EndVariable() or BeginArray() / EndArray(). | |
virtual void | WriteQuat (const plQuat &value)=0 |
Writes an plQuat to the JSON file. Can only be called between BeginVariable() / EndVariable() or BeginArray() / EndArray(). | |
virtual void | WriteMat3 (const plMat3 &value)=0 |
Writes an plMat3 to the JSON file. Can only be called between BeginVariable() / EndVariable() or BeginArray() / EndArray(). | |
virtual void | WriteMat4 (const plMat4 &value)=0 |
Writes an plMat4 to the JSON file. Can only be called between BeginVariable() / EndVariable() or BeginArray() / EndArray(). | |
virtual void | WriteUuid (const plUuid &value)=0 |
Writes an plUuid to the JSON file. Can only be called between BeginVariable() / EndVariable() or BeginArray() / EndArray(). | |
virtual void | WriteAngle (plAngle value)=0 |
Writes an plAngle to the JSON file. Can only be called between BeginVariable() / EndVariable() or BeginArray() / EndArray(). | |
virtual void | WriteDataBuffer (const plDataBuffer &value)=0 |
Writes an plDataBuffer to the JSON file. Can only be called between BeginVariable() / EndVariable() or BeginArray() / EndArray(). | |
virtual void | WriteVariant (const plVariant &value) |
The default implementation dispatches all supported types to WriteBool, WriteInt32, etc. and asserts on the more complex types. | |
virtual void | WriteBinaryData (plStringView sDataType, const void *pData, plUInt32 uiBytes, plStringView sValueString=nullptr)=0 |
Outputs a chunk of memory in some JSON form that can be interpreted as binary data when reading it again. | |
virtual void | BeginVariable (plStringView sName)=0 |
Begins outputting a variable. szName is the variable name. | |
virtual void | EndVariable ()=0 |
Ends outputting a variable. | |
virtual void | BeginArray (plStringView sName=nullptr)=0 |
Begins outputting an array variable. | |
virtual void | EndArray ()=0 |
Ends outputting an array variable. | |
virtual void | BeginObject (plStringView sName=nullptr)=0 |
Begins outputting an object variable. | |
virtual void | EndObject ()=0 |
Ends outputting an object variable. | |
bool | HadWriteError () const |
Indicates if an error was encountered while writing. | |
Protected Member Functions | |
void | SetWriteErrorState () |
called internally when there was an error during writing | |
Protected Attributes | |
WhitespaceMode | m_WhitespaceMode = WhitespaceMode::All |
ArrayMode | m_ArrayMode = ArrayMode::InOneLine |
The base class for JSON writers.
Declares a common interface for writing JSON files. Also implements some utility functions built on top of the interface (AddVariable()).
|
strong |
|
strong |
Modes to configure how much whitespace the JSON writer will output.
|
pure virtual |
Begins outputting an array variable.
If szName is nullptr this will create an anonymous array, which is necessary when you want to put an array as a value into another array. BeginArray() with a non-nullptr value for szName is identical to calling BeginVariable() first. In this case EndArray() will also end the variable definition, so no additional call to EndVariable() is required.
Implemented in plStandardJSONWriter.
|
pure virtual |
Begins outputting an object variable.
If szName is nullptr this will create an anonymous object, which is necessary when you want to put an object as a value into an array. BeginObject() with a non-nullptr value for szName is identical to calling BeginVariable() first. In this case EndObject() will also end the variable definition, so no additional call to EndVariable() is required.
Implemented in plStandardJSONWriter.
|
pure virtual |
Begins outputting a variable. szName is the variable name.
Between BeginVariable() and EndVariable() you can call the WriteXYZ functions once to write out the variable's data. You can also call BeginArray() and BeginObject() without a variable name to output an array or object variable.
Implemented in plStandardJSONWriter.
|
pure virtual |
Ends outputting an array variable.
Implemented in plStandardJSONWriter.
|
pure virtual |
Ends outputting an object variable.
Implemented in plStandardJSONWriter.
|
pure virtual |
Ends outputting a variable.
Implemented in plStandardJSONWriter.
bool plJSONWriter::HadWriteError | ( | ) | const |
Indicates if an error was encountered while writing.
If any error was encountered at any time during writing, this will return true
|
pure virtual |
Writes an plAngle to the JSON file. Can only be called between BeginVariable() / EndVariable() or BeginArray() / EndArray().
Implemented in plStandardJSONWriter.
|
pure virtual |
Outputs a chunk of memory in some JSON form that can be interpreted as binary data when reading it again.
How exactly the raw data is represented in JSON is up to the derived class. szDataType allows to additionally output a string that identifies the type of data.
Implemented in plStandardJSONWriter.
|
pure virtual |
Writes a bool to the JSON file. Can only be called between BeginVariable() / EndVariable() or BeginArray() / EndArray().
Implemented in plStandardJSONWriter.
|
pure virtual |
Writes an plColor to the JSON file. Can only be called between BeginVariable() / EndVariable() or BeginArray() / EndArray().
Implemented in plStandardJSONWriter.
|
pure virtual |
Writes an plColorGammaUB to the JSON file. Can only be called between BeginVariable() / EndVariable() or BeginArray() / EndArray().
Implemented in plStandardJSONWriter.
|
pure virtual |
Writes an plDataBuffer to the JSON file. Can only be called between BeginVariable() / EndVariable() or BeginArray() / EndArray().
Implemented in plStandardJSONWriter.
|
pure virtual |
Writes a double to the JSON file. Can only be called between BeginVariable() / EndVariable() or BeginArray() / EndArray().
Implemented in plStandardJSONWriter.
|
pure virtual |
Writes a float to the JSON file. Can only be called between BeginVariable() / EndVariable() or BeginArray() / EndArray().
Implemented in plStandardJSONWriter.
|
pure virtual |
Writes an int32 to the JSON file. Can only be called between BeginVariable() / EndVariable() or BeginArray() / EndArray().
Implemented in plStandardJSONWriter.
|
pure virtual |
Writes an int64 to the JSON file. Can only be called between BeginVariable() / EndVariable() or BeginArray() / EndArray().
Implemented in plStandardJSONWriter.
|
pure virtual |
Writes an plMat3 to the JSON file. Can only be called between BeginVariable() / EndVariable() or BeginArray() / EndArray().
Implemented in plStandardJSONWriter.
|
pure virtual |
Writes an plMat4 to the JSON file. Can only be called between BeginVariable() / EndVariable() or BeginArray() / EndArray().
Implemented in plStandardJSONWriter.
|
pure virtual |
Writes the value 'null' to the JSON file. Can only be called between BeginVariable() / EndVariable() or BeginArray() / EndArray().
Implemented in plStandardJSONWriter.
|
pure virtual |
Writes an plQuat to the JSON file. Can only be called between BeginVariable() / EndVariable() or BeginArray() / EndArray().
Implemented in plStandardJSONWriter.
|
pure virtual |
Writes a string to the JSON file. Can only be called between BeginVariable() / EndVariable() or BeginArray() / EndArray().
Implemented in plStandardJSONWriter.
|
pure virtual |
Writes a time value to the JSON file. Can only be called between BeginVariable() / EndVariable() or BeginArray() / EndArray().
Implemented in plStandardJSONWriter.
|
pure virtual |
Writes a uint32 to the JSON file. Can only be called between BeginVariable() / EndVariable() or BeginArray() / EndArray().
Implemented in plStandardJSONWriter.
|
pure virtual |
Writes a uint64 to the JSON file. Can only be called between BeginVariable() / EndVariable() or BeginArray() / EndArray().
Implemented in plStandardJSONWriter.
|
pure virtual |
Writes an plUuid to the JSON file. Can only be called between BeginVariable() / EndVariable() or BeginArray() / EndArray().
Implemented in plStandardJSONWriter.
|
virtual |
The default implementation dispatches all supported types to WriteBool, WriteInt32, etc. and asserts on the more complex types.
A derived class may override this function to implement support for the remaining variant types, if required.
|
pure virtual |
Writes an plVec2 to the JSON file. Can only be called between BeginVariable() / EndVariable() or BeginArray() / EndArray().
Implemented in plStandardJSONWriter.
|
pure virtual |
Writes an plVec2I32 to the JSON file. Can only be called between BeginVariable() / EndVariable() or BeginArray() / EndArray().
Implemented in plStandardJSONWriter.
|
pure virtual |
Writes an plVec3 to the JSON file. Can only be called between BeginVariable() / EndVariable() or BeginArray() / EndArray().
Implemented in plStandardJSONWriter.
|
pure virtual |
Writes an plVec3I32 to the JSON file. Can only be called between BeginVariable() / EndVariable() or BeginArray() / EndArray().
Implemented in plStandardJSONWriter.
|
pure virtual |
Writes an plVec4 to the JSON file. Can only be called between BeginVariable() / EndVariable() or BeginArray() / EndArray().
Implemented in plStandardJSONWriter.
|
pure virtual |
Writes an plVec4I32 to the JSON file. Can only be called between BeginVariable() / EndVariable() or BeginArray() / EndArray().
Implemented in plStandardJSONWriter.