Plasma Engine  2.0
Loading...
Searching...
No Matches
plOpenDdlWriter Class Reference

The base class for OpenDDL writers. More...

#include <OpenDdlWriter.h>

Classes

struct  DdlState
 

Public Types

enum class  TypeStringMode { Compliant , ShortenedUnsignedInt , Shortest }
 
enum class  FloatPrecisionMode { Readable , Exact }
 

Public Member Functions

 plOpenDdlWriter ()
 Constructor.
 
void SetOutputStream (plStreamWriter *pOutput)
 All output is written to this binary stream.
 
void SetCompactMode (bool bCompact)
 Configures how much whitespace is output.
 
void SetPrimitiveTypeStringMode (TypeStringMode mode)
 Configures how verbose the type strings are going to be written.
 
void SetFloatPrecisionMode (FloatPrecisionMode mode)
 Configures how float values are output.
 
FloatPrecisionMode GetFloatPrecisionMode () const
 Returns how float values are output.
 
void SetIndentation (plInt8 iIndentation)
 Allows to set the indentation. Negative values are possible. This makes it possible to set the indentation e.g. to -2, thus the output will only have indentation after a level of 3 has been reached.
 
void BeginObject (plStringView sType, plStringView sName={}, bool bGlobalName=false, bool bSingleLine=false)
 Begins outputting an object.
 
void EndObject ()
 Ends outputting an object.
 
void BeginPrimitiveList (plOpenDdlPrimitiveType type, plStringView sName={}, bool bGlobalName=false)
 Begins outputting a list of primitives of the given type.
 
void EndPrimitiveList ()
 Ends outputting the list of primitives.
 
void WriteBool (const bool *pValues, plUInt32 uiCount=1)
 Writes a number of values to the primitive list. Can be called multiple times between BeginPrimitiveList() / EndPrimitiveList().
 
void WriteInt8 (const plInt8 *pValues, plUInt32 uiCount=1)
 Writes a number of values to the primitive list. Can be called multiple times between BeginPrimitiveList() / EndPrimitiveList().
 
void WriteInt16 (const plInt16 *pValues, plUInt32 uiCount=1)
 Writes a number of values to the primitive list. Can be called multiple times between BeginPrimitiveList() / EndPrimitiveList().
 
void WriteInt32 (const plInt32 *pValues, plUInt32 uiCount=1)
 Writes a number of values to the primitive list. Can be called multiple times between BeginPrimitiveList() / EndPrimitiveList().
 
void WriteInt64 (const plInt64 *pValues, plUInt32 uiCount=1)
 Writes a number of values to the primitive list. Can be called multiple times between BeginPrimitiveList() / EndPrimitiveList().
 
void WriteUInt8 (const plUInt8 *pValues, plUInt32 uiCount=1)
 Writes a number of values to the primitive list. Can be called multiple times between BeginPrimitiveList() / EndPrimitiveList().
 
void WriteUInt16 (const plUInt16 *pValues, plUInt32 uiCount=1)
 Writes a number of values to the primitive list. Can be called multiple times between BeginPrimitiveList() / EndPrimitiveList().
 
void WriteUInt32 (const plUInt32 *pValues, plUInt32 uiCount=1)
 Writes a number of values to the primitive list. Can be called multiple times between BeginPrimitiveList() / EndPrimitiveList().
 
void WriteUInt64 (const plUInt64 *pValues, plUInt32 uiCount=1)
 Writes a number of values to the primitive list. Can be called multiple times between BeginPrimitiveList() / EndPrimitiveList().
 
void WriteFloat (const float *pValues, plUInt32 uiCount=1)
 Writes a number of values to the primitive list. Can be called multiple times between BeginPrimitiveList() / EndPrimitiveList().
 
void WriteDouble (const double *pValues, plUInt32 uiCount=1)
 Writes a number of values to the primitive list. Can be called multiple times between BeginPrimitiveList() / EndPrimitiveList().
 
void WriteString (const plStringView &sString)
 Writes a single string to the primitive list. Can be called multiple times between BeginPrimitiveList() / EndPrimitiveList().
 
void WriteBinaryAsString (const void *pData, plUInt32 uiBytes)
 Writes a single string to the primitive list, but the value is a HEX representation of the given binary data.
 

Protected Types

enum  State {
  Invalid = -5 , Empty = -4 , ObjectSingleLine = -3 , ObjectMultiLine = -2 ,
  ObjectStart = -1 , PrimitivesBool = 0 , PrimitivesInt8 , PrimitivesInt16 ,
  PrimitivesInt32 , PrimitivesInt64 , PrimitivesUInt8 , PrimitivesUInt16 ,
  PrimitivesUInt32 , PrimitivesUInt64 , PrimitivesFloat , PrimitivesDouble ,
  PrimitivesString
}
 

Protected Member Functions

PL_ALWAYS_INLINE void OutputString (plStringView s)
 
PL_ALWAYS_INLINE void OutputString (plStringView s, plUInt32 uiElementCount)
 
void OutputEscapedString (const plStringView &string)
 
void OutputIndentation ()
 
void OutputPrimitiveTypeNameCompliant (plOpenDdlPrimitiveType type)
 
void OutputPrimitiveTypeNameShort (plOpenDdlPrimitiveType type)
 
void OutputPrimitiveTypeNameShortest (plOpenDdlPrimitiveType type)
 
void WritePrimitiveType (plOpenDdlWriter::State exp)
 
void OutputObjectName (plStringView sName, bool bGlobalName)
 
void WriteBinaryAsHex (const void *pData, plUInt32 uiBytes)
 
void OutputObjectBeginning ()
 

Protected Attributes

plInt32 m_iIndentation = 0
 
bool m_bCompactMode = false
 
TypeStringMode m_TypeStringMode = TypeStringMode::ShortenedUnsignedInt
 
FloatPrecisionMode m_FloatPrecisionMode = FloatPrecisionMode::Exact
 
plStreamWriterm_pOutput = nullptr
 
plStringBuilder m_sTemp
 
plHybridArray< DdlState, 16 > m_StateStack
 

Detailed Description

The base class for OpenDDL writers.

Declares a common interface for writing OpenDDL files.

Member Enumeration Documentation

◆ FloatPrecisionMode

Enumerator
Readable 

Float values are printed as readable numbers. Precision might get lost though.

Exact 

Float values are printed as HEX, representing the exact binary data.

◆ TypeStringMode

Enumerator
Compliant 

All primitive types are written as the OpenDDL standard defines them (very verbose)

ShortenedUnsignedInt 

unsigned_intX is shortened to uintX

Shortest 

All primitive type names are shortened to one or two characters: i1, i2, i3, i4, u1, u2, u3, u4, b, s, f, d (int, uint, bool, string, float, double)

Member Function Documentation

◆ OutputObjectName()

void plOpenDdlWriter::OutputObjectName ( plStringView sName,
bool bGlobalName )
protected
Test
This code path is untested

◆ WriteBinaryAsString()

void plOpenDdlWriter::WriteBinaryAsString ( const void * pData,
plUInt32 uiBytes )

Writes a single string to the primitive list, but the value is a HEX representation of the given binary data.

Test
plOpenDdlWriter::WriteBinaryAsString

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