NAP
Public Member Functions | List of all members
Writer Class Referenceabstract

#include <rtti/writer.h>

Public Member Functions

virtual bool start (const ObjectList &rootObjects)=0
 
virtual bool finish ()=0
 
virtual bool startRootObject (const rtti::TypeInfo &type)=0
 
virtual bool finishRootObject ()=0
 
virtual bool startCompound (const rtti::TypeInfo &type)=0
 
virtual bool finishCompound ()=0
 
virtual bool startArray (int length)=0
 
virtual bool finishArray ()=0
 
virtual bool writeProperty (const std::string &propertyName)=0
 
virtual bool writePointer (const std::string &pointeeID)=0
 
virtual bool writePrimitive (const rtti::TypeInfo &type, const rtti::Variant &value)=0
 
virtual bool supportsEmbeddedPointers () const =0
 

Description

This is the interface used by serializeObjects to serialize RTTI objects. Having this interface allows the object hierarchy traversal logic to remain separate from the actual writing logic. This in turn means that the same interface (serializeObjects) can be used to write to a variety of formats (JSON, binary, BSON, etc).

Inheritance diagram for Writer:
[legend]

Member Function Documentation

◆ finish()

virtual bool finish ( )
pure virtual

Called when serialization is finished, after everything has been written (i.e. end of 'document')

Implemented in JSONWriter, and BinaryWriter.

◆ finishArray()

virtual bool finishArray ( )
pure virtual

Called when an array has been completely written

Implemented in JSONWriter, and BinaryWriter.

◆ finishCompound()

virtual bool finishCompound ( )
pure virtual

Called when a compound has been completely written

Implemented in JSONWriter, and BinaryWriter.

◆ finishRootObject()

virtual bool finishRootObject ( )
pure virtual

Called when a root object has been completely written

Implemented in JSONWriter, and BinaryWriter.

◆ start()

virtual bool start ( const ObjectList rootObjects)
pure virtual

Called when serialization starts, but before any objects have been written (i.e. start of 'document')

Parameters
rootObjectsThe list of root objects that will be written to the writer

Implemented in JSONWriter, and BinaryWriter.

◆ startArray()

virtual bool startArray ( int  length)
pure virtual

Called when an array of the specified length is about to be written. Note that the elements are written in a separate call (writePointer or writePrimitive)

Implemented in JSONWriter, and BinaryWriter.

◆ startCompound()

virtual bool startCompound ( const rtti::TypeInfo type)
pure virtual

Called when a compound (i.e. struct nested inside a root object) of the specified type is about to be written

Implemented in JSONWriter, and BinaryWriter.

◆ startRootObject()

virtual bool startRootObject ( const rtti::TypeInfo type)
pure virtual

Called when a root object of the specified type is about to be written

Implemented in JSONWriter, and BinaryWriter.

◆ supportsEmbeddedPointers()

virtual bool supportsEmbeddedPointers ( ) const
pure virtual

Called to determine if this writer supports writing pointers nested in the object pointing to them (embedded pointers)

Implemented in JSONWriter, and BinaryWriter.

◆ writePointer()

virtual bool writePointer ( const std::string &  pointeeID)
pure virtual

Called to write a pointer to an object with the specified ID

Implemented in JSONWriter, and BinaryWriter.

◆ writePrimitive()

virtual bool writePrimitive ( const rtti::TypeInfo type,
const rtti::Variant value 
)
pure virtual

Called to write a primitive type with the specified value

Implemented in JSONWriter, and BinaryWriter.

◆ writeProperty()

virtual bool writeProperty ( const std::string &  propertyName)
pure virtual

Called to write a property of the specified name. Note that the value for the property is written in a separate call (writePointer or writePrimitive)

Implemented in JSONWriter, and BinaryWriter.