Pyrogenesis HEAD
Pyrogenesis, a RTS Engine
CStdDeserializer Class Reference

#include <StdDeserializer.h>

Inheritance diagram for CStdDeserializer:
Collaboration diagram for CStdDeserializer:

Public Member Functions

 CStdDeserializer (const ScriptInterface &scriptInterface, std::istream &stream)
 
virtual ~CStdDeserializer ()
 
virtual void ScriptVal (const char *name, JS::MutableHandleValue out)
 Deserialize a JS::Value, replacing 'out'. More...
 
virtual void ScriptObjectAssign (const char *name, JS::HandleValue objVal)
 Deserialize an object and assign its properties to objVal (Essentially equivalent to Object.assign(objVal, serialized)) More...
 
virtual void ScriptString (const char *name, JS::MutableHandleString out)
 Deserialize a JSString. More...
 
virtual std::istream & GetStream ()
 Returns a stream which can be used to deserialize data directly. More...
 
virtual void RequireBytesInStream (size_t numBytes)
 Throws an exception if the stream definitely cannot provide the required number of bytes. More...
 
void TraceMember (JSTracer *trc)
 
- Public Member Functions inherited from IDeserializer
virtual ~IDeserializer ()
 
virtual void NumberU8 (const char *name, uint8_t &out, uint8_t lower, uint8_t upper)
 
virtual void NumberI8 (const char *name, int8_t &out, int8_t lower, int8_t upper)
 
virtual void NumberU16 (const char *name, uint16_t &out, uint16_t lower, uint16_t upper)
 
virtual void NumberI16 (const char *name, int16_t &out, int16_t lower, int16_t upper)
 
virtual void NumberU32 (const char *name, uint32_t &out, uint32_t lower, uint32_t upper)
 
virtual void NumberI32 (const char *name, int32_t &out, int32_t lower, int32_t upper)
 
virtual void NumberU8_Unbounded (const char *name, uint8_t &out)
 
virtual void NumberI8_Unbounded (const char *name, int8_t &out)
 
virtual void NumberU16_Unbounded (const char *name, uint16_t &out)
 
virtual void NumberI16_Unbounded (const char *name, int16_t &out)
 
virtual void NumberU32_Unbounded (const char *name, uint32_t &out)
 
virtual void NumberI32_Unbounded (const char *name, int32_t &out)
 
virtual void NumberFloat_Unbounded (const char *name, float &out)
 
virtual void NumberDouble_Unbounded (const char *name, double &out)
 
virtual void NumberFixed_Unbounded (const char *name, fixed &out)
 
virtual void Bool (const char *name, bool &out)
 
virtual void StringASCII (const char *name, std::string &out, uint32_t minlength, uint32_t maxlength)
 
virtual void String (const char *name, std::wstring &out, uint32_t minlength, uint32_t maxlength)
 
virtual void ScriptVal (const char *name, JS::MutableHandleValue out)=0
 Deserialize a JS::Value, replacing 'out'. More...
 
virtual void ScriptObjectAssign (const char *name, JS::HandleValue objVal)=0
 Deserialize an object and assign its properties to objVal (Essentially equivalent to Object.assign(objVal, serialized)) More...
 
virtual void ScriptString (const char *name, JS::MutableHandleString out)=0
 Deserialize a JSString. More...
 
virtual void RawBytes (const char *name, u8 *data, size_t len)
 
virtual int GetVersion () const
 
virtual std::istream & GetStream ()=0
 Returns a stream which can be used to deserialize data directly. More...
 
virtual void RequireBytesInStream (size_t numBytes)=0
 Throws an exception if the stream definitely cannot provide the required number of bytes. More...
 

Static Public Member Functions

static void Trace (JSTracer *trc, void *data)
 

Protected Member Functions

virtual void Get (const char *name, u8 *data, size_t len)
 
virtual void Get (const char *name, u8 *data, size_t len)=0
 

Private Member Functions

 NONCOPYABLE (CStdDeserializer)
 
JS::Value ReadScriptVal (const char *name, JS::HandleObject preexistingObject)
 
void ReadStringLatin1 (const char *name, std::vector< JS::Latin1Char > &str)
 
void ReadStringUTF16 (const char *name, std::u16string &str)
 
virtual void AddScriptBackref (JS::HandleObject obj)
 
virtual void GetScriptBackref (size_t tag, JS::MutableHandleObject ret)
 

Private Attributes

std::vector< JS::Heap< JSObject * > > m_ScriptBackrefs
 
const ScriptInterfacem_ScriptInterface
 
std::istream & m_Stream
 

Constructor & Destructor Documentation

◆ CStdDeserializer()

CStdDeserializer::CStdDeserializer ( const ScriptInterface scriptInterface,
std::istream &  stream 
)

◆ ~CStdDeserializer()

CStdDeserializer::~CStdDeserializer ( )
virtual

Member Function Documentation

◆ AddScriptBackref()

void CStdDeserializer::AddScriptBackref ( JS::HandleObject  obj)
privatevirtual

◆ Get()

void CStdDeserializer::Get ( const char *  name,
u8 data,
size_t  len 
)
protectedvirtual

Implements IDeserializer.

◆ GetScriptBackref()

void CStdDeserializer::GetScriptBackref ( size_t  tag,
JS::MutableHandleObject  ret 
)
privatevirtual

◆ GetStream()

std::istream & CStdDeserializer::GetStream ( )
virtual

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

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

Implements IDeserializer.

◆ NONCOPYABLE()

CStdDeserializer::NONCOPYABLE ( CStdDeserializer  )
private

◆ ReadScriptVal()

JS::Value CStdDeserializer::ReadScriptVal ( const char *  name,
JS::HandleObject  preexistingObject 
)
private

◆ ReadStringLatin1()

void CStdDeserializer::ReadStringLatin1 ( const char *  name,
std::vector< JS::Latin1Char > &  str 
)
private

◆ ReadStringUTF16()

void CStdDeserializer::ReadStringUTF16 ( const char *  name,
std::u16string &  str 
)
private

◆ RequireBytesInStream()

void CStdDeserializer::RequireBytesInStream ( size_t  numBytes)
virtual

Throws an exception if the stream definitely cannot provide the required number of bytes.

(It might be conservative and not throw an exception in some cases where the stream actually can't provide the required bytes.) (This should be used when allocating memory based on data in the stream, e.g. reading strings, to avoid dangerously large allocations when the data is invalid.)

Implements IDeserializer.

◆ ScriptObjectAssign()

void CStdDeserializer::ScriptObjectAssign ( const char *  name,
JS::HandleValue  objVal 
)
virtual

Deserialize an object and assign its properties to objVal (Essentially equivalent to Object.assign(objVal, serialized))

Implements IDeserializer.

◆ ScriptString()

void CStdDeserializer::ScriptString ( const char *  name,
JS::MutableHandleString  out 
)
virtual

Deserialize a JSString.

Implements IDeserializer.

◆ ScriptVal()

void CStdDeserializer::ScriptVal ( const char *  name,
JS::MutableHandleValue  out 
)
virtual

Deserialize a JS::Value, replacing 'out'.

Implements IDeserializer.

◆ Trace()

void CStdDeserializer::Trace ( JSTracer *  trc,
void *  data 
)
static

◆ TraceMember()

void CStdDeserializer::TraceMember ( JSTracer *  trc)

Member Data Documentation

◆ m_ScriptBackrefs

std::vector<JS::Heap<JSObject*> > CStdDeserializer::m_ScriptBackrefs
private

◆ m_ScriptInterface

const ScriptInterface& CStdDeserializer::m_ScriptInterface
private

◆ m_Stream

std::istream& CStdDeserializer::m_Stream
private

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