Rebel Fork Framework
Urho3D::Archive Class Referenceabstract

#include <Urho3D/IO/Archive.h>

Inheritance diagram for Urho3D::Archive:
Urho3D::ArchiveBase Urho3D::ArchiveBaseT< BinaryInputArchiveBlock, IsInputBool, false > Urho3D::ArchiveBaseT< BinaryOutputArchiveBlock, IsInputBool, false > Urho3D::ArchiveBaseT< BlockType, IsInputBool, false > Urho3D::ArchiveBaseT< BlockType, IsInputBool, true > Urho3D::ArchiveBaseT< JSONInputArchiveBlock, IsInputBool, true > Urho3D::ArchiveBaseT< JSONOutputArchiveBlock, IsInputBool, true > Urho3D::ArchiveBaseT< XMLInputArchiveBlock, IsInputBool, true > Urho3D::ArchiveBaseT< XMLOutputArchiveBlock, IsInputBool, true > Urho3D::ArchiveBaseT< BlockType, IsInputBool, IsHumanReadableBool >

Public Member Functions

virtual ContextGetContext ()=0
 Get context.
 
virtual ea::string_view GetName () const =0
 Return name of the archive if applicable.
 
virtual unsigned GetChecksum ()=0
 Return a checksum if applicable.
 
virtual bool IsInput () const =0
 
virtual bool IsHumanReadable () const =0
 
virtual bool IsUnorderedAccessSupportedInCurrentBlock () const =0
 
virtual bool HasElementOrBlock (const char *name) const =0
 
virtual bool IsEOF () const =0
 Whether the archive can no longer be serialized.
 
virtual ea::string GetCurrentBlockPath () const =0
 Return current string stack.
 
virtual void BeginBlock (const char *name, unsigned &sizeHint, bool safe, ArchiveBlockType type)=0
 
virtual void EndBlock () noexcept=0
 End archive block. May postpone ArchiveException until later.
 
virtual void Flush ()=0
 Flush all pending events. Should be called at least once before destructor.
 
ArchiveBlock OpenBlock (const char *name, unsigned sizeHint, bool safe, ArchiveBlockType type)
 
Serialize primitive element
virtual void Serialize (const char *name, bool &value)=0
 
virtual void Serialize (const char *name, signed char &value)=0
 
virtual void Serialize (const char *name, unsigned char &value)=0
 
virtual void Serialize (const char *name, short &value)=0
 
virtual void Serialize (const char *name, unsigned short &value)=0
 
virtual void Serialize (const char *name, int &value)=0
 
virtual void Serialize (const char *name, unsigned int &value)=0
 
virtual void Serialize (const char *name, long long &value)=0
 
virtual void Serialize (const char *name, unsigned long long &value)=0
 
virtual void Serialize (const char *name, float &value)=0
 
virtual void Serialize (const char *name, double &value)=0
 
virtual void Serialize (const char *name, ea::string &value)=0
 
virtual void SerializeBytes (const char *name, void *bytes, unsigned size)=0
 Serialize bytes. Size is not encoded and should be provided externally!
 
virtual void SerializeVLE (const char *name, unsigned &value)=0
 Serialize Variable Length Encoded unsigned integer, up to 29 significant bits.
 
virtual unsigned SerializeVersion (unsigned version)=0
 Serialize version number. 0 is invalid version.
 
ArchiveBlock OpenSequentialBlock (const char *name)
 Open Sequential block. Will be automatically closed when returned object is destroyed. More...
 
ArchiveBlock OpenUnorderedBlock (const char *name)
 Open Unordered block. Will be automatically closed when returned object is destroyed.
 
ArchiveBlock OpenArrayBlock (const char *name, unsigned sizeHint=0)
 Open Array block. Will be automatically closed when returned object is destroyed.
 
ArchiveBlock OpenSafeSequentialBlock (const char *name)
 Open safe Sequential block. Will be automatically closed when returned object is destroyed.
 
ArchiveBlock OpenSafeUnorderedBlock (const char *name)
 Open safe Unordered block. Will be automatically closed when returned object is destroyed.
 

Static Public Member Functions

static bool ValidateName (ea::string_view name)
 Validate element or block name.
 

Detailed Description

Archive interface.

  • Archive is a hierarchical structure of blocks and elements.
  • Archive must have exactly one root block.
  • Any block may contain other blocks or elements of any type.
  • Any block or element may have name. Use C++ naming conventions for identifiers, arbitrary strings are not allowed. Name "key" is reserved.
  • Unsafe block must not be closed until all the items are serialized.

Member Function Documentation

◆ BeginBlock()

virtual void Urho3D::Archive::BeginBlock ( const char *  name,
unsigned &  sizeHint,
bool  safe,
ArchiveBlockType  type 
)
pure virtual

Begin archive block. Size is required for Array blocks. It is guaranteed that errors occurred during serialization of the safe block don't affect data outside of the block.

Implemented in Urho3D::XMLInputArchive, Urho3D::JSONInputArchive, Urho3D::BinaryInputArchive, Urho3D::XMLOutputArchive, Urho3D::JSONOutputArchive, and Urho3D::BinaryOutputArchive.

◆ HasElementOrBlock()

◆ IsHumanReadable()

virtual bool Urho3D::Archive::IsHumanReadable ( ) const
pure virtual

Whether the human-readability is preferred over performance and output size.

  • Binary serialization is disfavored.
  • String hashes are serialized as strings, if possible.
  • Enumerators serialized as strings, if possible.
  • Simple compound types like Vector3 are serialized as formatted strings instead of blocks.

Implemented in Urho3D::ArchiveBaseT< BlockType, IsInputBool, IsHumanReadableBool >.

◆ IsInput()

virtual bool Urho3D::Archive::IsInput ( ) const
pure virtual

Whether the archive is in input mode. It is guaranteed that input archive doesn't read from any variable. It is guaranteed that output archive doesn't write to any variable. It is save to cast away const-ness when serializing into output archive.

Implemented in Urho3D::ArchiveBaseT< BlockType, IsInputBool, IsHumanReadableBool >.

◆ IsUnorderedAccessSupportedInCurrentBlock()

virtual bool Urho3D::Archive::IsUnorderedAccessSupportedInCurrentBlock ( ) const
pure virtual

Return whether the unordered element access is supported in currently open block. Always false if current block is not Unordered. Always false for some archive types.

Implemented in Urho3D::ArchiveBaseT< BlockType, IsInputBool, IsHumanReadableBool >.

◆ OpenBlock()

ArchiveBlock Urho3D::Archive::OpenBlock ( const char *  name,
unsigned  sizeHint,
bool  safe,
ArchiveBlockType  type 
)
inline

Do BeginBlock and return the guard that will call EndBlock automatically on destruction. Return null block in case of error.

◆ OpenSequentialBlock()

ArchiveBlock Urho3D::Archive::OpenSequentialBlock ( const char *  name)
inline

Open Sequential block. Will be automatically closed when returned object is destroyed.

Open block helpers


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