Pyrogenesis HEAD
Pyrogenesis, a RTS Engine
CDebugSerializer Class Reference

Serialize to a human-readable YAML-like format. More...

#include <DebugSerializer.h>

Inheritance diagram for CDebugSerializer:
Collaboration diagram for CDebugSerializer:

Public Member Functions

 CDebugSerializer (const ScriptInterface &scriptInterface, std::ostream &stream, bool includeDebugInfo=true)
 
void Comment (const std::string &comment)
 
void TextLine (const std::string &text)
 
void Indent (int spaces)
 
void Dedent (int spaces)
 
virtual bool IsDebug () const
 Returns true if the serializer is being used in debug mode. More...
 
virtual std::ostream & GetStream ()
 Returns a stream which can be used to serialize data directly. More...
 
- Public Member Functions inherited from ISerializer
virtual ~ISerializer ()
 
void NumberU8 (const char *name, uint8_t value, uint8_t lower, uint8_t upper)
 Serialize a number, which must be lower <= value <= upper. More...
 
void NumberI8 (const char *name, int8_t value, int8_t lower, int8_t upper)
 
void NumberU16 (const char *name, uint16_t value, uint16_t lower, uint16_t upper)
 Serialize a number, which must be lower <= value <= upper. More...
 
void NumberI16 (const char *name, int16_t value, int16_t lower, int16_t upper)
 Serialize a number, which must be lower <= value <= upper. More...
 
void NumberU32 (const char *name, uint32_t value, uint32_t lower, uint32_t upper)
 Serialize a number, which must be lower <= value <= upper. More...
 
void NumberI32 (const char *name, int32_t value, int32_t lower, int32_t upper)
 Serialize a number, which must be lower <= value <= upper. More...
 
void NumberU8_Unbounded (const char *name, uint8_t value)
 Serialize a number. More...
 
void NumberI8_Unbounded (const char *name, int8_t value)
 Serialize a number. More...
 
void NumberU16_Unbounded (const char *name, uint16_t value)
 Serialize a number. More...
 
void NumberI16_Unbounded (const char *name, int16_t value)
 Serialize a number. More...
 
void NumberU32_Unbounded (const char *name, uint32_t value)
 Serialize a number. More...
 
void NumberI32_Unbounded (const char *name, int32_t value)
 Serialize a number. More...
 
void NumberFloat_Unbounded (const char *name, float value)
 Serialize a number. More...
 
void NumberDouble_Unbounded (const char *name, double value)
 Serialize a number. More...
 
void NumberFixed_Unbounded (const char *name, fixed value)
 Serialize a number. More...
 
void Bool (const char *name, bool value)
 Serialize a boolean. More...
 
void StringASCII (const char *name, const std::string &value, uint32_t minlength, uint32_t maxlength)
 Serialize an ASCII string. More...
 
void String (const char *name, const std::wstring &value, uint32_t minlength, uint32_t maxlength)
 Serialize a Unicode string. More...
 
void ScriptVal (const char *name, JS::MutableHandleValue value)
 Serialize a JS::MutableHandleValue. More...
 
void RawBytes (const char *name, const u8 *data, size_t len)
 Serialize a stream of bytes. More...
 
virtual bool IsDebug () const
 Returns true if the serializer is being used in debug mode. More...
 
virtual std::ostream & GetStream ()=0
 Returns a stream which can be used to serialize data directly. More...
 

Protected Member Functions

virtual void PutNumber (const char *name, uint8_t value)
 
virtual void PutNumber (const char *name, int8_t value)
 
virtual void PutNumber (const char *name, uint16_t value)
 
virtual void PutNumber (const char *name, int16_t value)
 
virtual void PutNumber (const char *name, uint32_t value)
 
virtual void PutNumber (const char *name, int32_t value)
 
virtual void PutNumber (const char *name, float value)
 
virtual void PutNumber (const char *name, double value)
 
virtual void PutNumber (const char *name, fixed value)
 
virtual void PutBool (const char *name, bool value)
 
virtual void PutString (const char *name, const std::string &value)
 
virtual void PutScriptVal (const char *name, JS::MutableHandleValue value)
 
virtual void PutRaw (const char *name, const u8 *data, size_t len)
 
virtual void PutNumber (const char *name, uint8_t value)=0
 
virtual void PutNumber (const char *name, int8_t value)=0
 
virtual void PutNumber (const char *name, uint16_t value)=0
 
virtual void PutNumber (const char *name, int16_t value)=0
 
virtual void PutNumber (const char *name, uint32_t value)=0
 
virtual void PutNumber (const char *name, int32_t value)=0
 
virtual void PutNumber (const char *name, float value)=0
 
virtual void PutNumber (const char *name, double value)=0
 
virtual void PutNumber (const char *name, fixed value)=0
 
virtual void PutBool (const char *name, bool value)=0
 
virtual void PutString (const char *name, const std::string &value)=0
 
virtual void PutScriptVal (const char *name, JS::MutableHandleValue value)=0
 
virtual void PutRaw (const char *name, const u8 *data, size_t len)=0
 

Private Member Functions

 NONCOPYABLE (CDebugSerializer)
 

Private Attributes

const ScriptInterfacem_ScriptInterface
 
std::ostream & m_Stream
 
bool m_IsDebug
 
int m_Indent
 

Detailed Description

Serialize to a human-readable YAML-like format.

Constructor & Destructor Documentation

◆ CDebugSerializer()

CDebugSerializer::CDebugSerializer ( const ScriptInterface scriptInterface,
std::ostream &  stream,
bool  includeDebugInfo = true 
)
Parameters
scriptInterfaceScript interface corresponding to any JS::Value passed to ScriptVal()
streamStream to receive UTF-8 encoded output
includeDebugInfoIf true then additional non-deterministic data will be included in the output

Member Function Documentation

◆ Comment()

void CDebugSerializer::Comment ( const std::string &  comment)

◆ Dedent()

void CDebugSerializer::Dedent ( int  spaces)

◆ GetStream()

std::ostream & CDebugSerializer::GetStream ( )
virtual

Returns a stream which can be used to serialize data directly.

(This is particularly useful for chaining multiple serializers together.)

Implements ISerializer.

◆ Indent()

void CDebugSerializer::Indent ( int  spaces)

◆ IsDebug()

bool CDebugSerializer::IsDebug ( ) const
virtual

Returns true if the serializer is being used in debug mode.

Components should serialize non-critical data (e.g. data that is unchanged from the template) only if this is true. (It must still only be used for synchronised, deterministic data.)

Reimplemented from ISerializer.

◆ NONCOPYABLE()

CDebugSerializer::NONCOPYABLE ( CDebugSerializer  )
private

◆ PutBool()

void CDebugSerializer::PutBool ( const char *  name,
bool  value 
)
protectedvirtual

Implements ISerializer.

◆ PutNumber() [1/9]

void CDebugSerializer::PutNumber ( const char *  name,
double  value 
)
protectedvirtual

Implements ISerializer.

◆ PutNumber() [2/9]

void CDebugSerializer::PutNumber ( const char *  name,
fixed  value 
)
protectedvirtual

Implements ISerializer.

◆ PutNumber() [3/9]

void CDebugSerializer::PutNumber ( const char *  name,
float  value 
)
protectedvirtual

Implements ISerializer.

◆ PutNumber() [4/9]

void CDebugSerializer::PutNumber ( const char *  name,
int16_t  value 
)
protectedvirtual

Implements ISerializer.

◆ PutNumber() [5/9]

void CDebugSerializer::PutNumber ( const char *  name,
int32_t  value 
)
protectedvirtual

Implements ISerializer.

◆ PutNumber() [6/9]

void CDebugSerializer::PutNumber ( const char *  name,
int8_t  value 
)
protectedvirtual

Implements ISerializer.

◆ PutNumber() [7/9]

void CDebugSerializer::PutNumber ( const char *  name,
uint16_t  value 
)
protectedvirtual

Implements ISerializer.

◆ PutNumber() [8/9]

void CDebugSerializer::PutNumber ( const char *  name,
uint32_t  value 
)
protectedvirtual

Implements ISerializer.

◆ PutNumber() [9/9]

void CDebugSerializer::PutNumber ( const char *  name,
uint8_t  value 
)
protectedvirtual

Implements ISerializer.

◆ PutRaw()

void CDebugSerializer::PutRaw ( const char *  name,
const u8 data,
size_t  len 
)
protectedvirtual

Implements ISerializer.

◆ PutScriptVal()

void CDebugSerializer::PutScriptVal ( const char *  name,
JS::MutableHandleValue  value 
)
protectedvirtual

Implements ISerializer.

◆ PutString()

void CDebugSerializer::PutString ( const char *  name,
const std::string &  value 
)
protectedvirtual

Implements ISerializer.

◆ TextLine()

void CDebugSerializer::TextLine ( const std::string &  text)

Member Data Documentation

◆ m_Indent

int CDebugSerializer::m_Indent
private

◆ m_IsDebug

bool CDebugSerializer::m_IsDebug
private

◆ m_ScriptInterface

const ScriptInterface& CDebugSerializer::m_ScriptInterface
private

◆ m_Stream

std::ostream& CDebugSerializer::m_Stream
private

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