openMSX
Public Member Functions | Protected Member Functions | List of all members
openmsx::ArchiveBase< Derived > Class Template Reference

#include <serialize.hh>

Inheritance diagram for openmsx::ArchiveBase< Derived >:
Inheritance graph
[legend]

Public Member Functions

template<typename Base , typename T >
void serializeBase (T &t)
 Is this archive a loader or a saver. More...
 
template<typename Base , typename T >
void serializeInlinedBase (T &t, unsigned version)
 Serialize the base class of this classtype. More...
 
bool needVersion () const
 Does this archive store version information. More...
 
bool isReverseSnapshot () const
 Is this a reverse-snapshot? More...
 
bool translateEnumToString () const
 Does this archive store enums as strings. More...
 
template<typename T >
void attribute (const char *name, T &t)
 Load/store an attribute from/in the archive. More...
 
void attribute (const char *name, const char *value)
 
bool canHaveOptionalAttributes () const
 Some archives (like XML archives) can store optional attributes. More...
 
bool hasAttribute (const char *)
 Check the presence of a (optional) attribute. More...
 
bool findAttribute (const char *, unsigned &)
 Optimization: combination of hasAttribute() and getAttribute(). More...
 
bool canCountChildren () const
 Some archives (like XML archives) can count the number of subtags that belong to the current tag. More...
 
int countChildren () const
 Count the number of child tags. More...
 
void beginTag (const char *)
 Indicate begin of a tag. More...
 
void endTag (const char *)
 Indicate begin of a tag. More...
 

Protected Member Functions

Derived & self ()
 Returns a reference to the most derived class. More...
 

Detailed Description

template<typename Derived>
class openmsx::ArchiveBase< Derived >

Definition at line 75 of file serialize.hh.

Member Function Documentation

◆ attribute() [1/2]

template<typename Derived>
template<typename T >
void openmsx::ArchiveBase< Derived >::attribute ( const char *  name,
T &  t 
)
inline

Load/store an attribute from/in the archive.

Depending on the underlying concrete stream, attributes are either stored like XML attributes or as regular values. Because of this (and thus unlike XML attributes) the order of attributes matter. It also matters whether an attribute is present or not.

Definition at line 231 of file serialize.hh.

◆ attribute() [2/2]

template<typename Derived >
void openmsx::ArchiveBase< Derived >::attribute ( const char *  name,
const char *  value 
)

Definition at line 24 of file serialize.cc.

◆ beginTag()

template<typename Derived>
void openmsx::ArchiveBase< Derived >::beginTag ( const char *  )
inline

Indicate begin of a tag.

Only XML archives use this, other archives ignore it. XML saver uses it as a name for the current tag, it doesn't interpret the name in any way. XML loader uses it only as a check: it checks whether the current tag name matches the given name. So we will NOT search the tag with the given name, the tags have to be in the correct order.

Definition at line 288 of file serialize.hh.

◆ canCountChildren()

template<typename Derived>
bool openmsx::ArchiveBase< Derived >::canCountChildren ( ) const
inline

Some archives (like XML archives) can count the number of subtags that belong to the current tag.

This method indicates whether that's the case for this archive or not. This can for example be used to make the XML files look prettier in case of serialization of collections: in that case we don't need to explictly store the size of the collection, it can be derived from the number of subtags.

Definition at line 269 of file serialize.hh.

◆ canHaveOptionalAttributes()

template<typename Derived>
bool openmsx::ArchiveBase< Derived >::canHaveOptionalAttributes ( ) const
inline

Some archives (like XML archives) can store optional attributes.

This method indicates whether that's the case or not. This can be used to for example in XML files don't store attributes with default values (thus to make the XML look prettier).

Definition at line 242 of file serialize.hh.

◆ countChildren()

template<typename Derived>
int openmsx::ArchiveBase< Derived >::countChildren ( ) const
inline

Count the number of child tags.

It's only allowed to call this method on archives that have support for this operation.

Definition at line 275 of file serialize.hh.

◆ endTag()

template<typename Derived>
void openmsx::ArchiveBase< Derived >::endTag ( const char *  )
inline

Indicate begin of a tag.

Only XML archives use this, other archives ignore it. Both XML loader and saver only use the given tag name to do some internal checks (with checks disabled, the tag parameter has no influence at all on loading or saving of the stream).

Definition at line 298 of file serialize.hh.

◆ findAttribute()

template<typename Derived>
bool openmsx::ArchiveBase< Derived >::findAttribute ( const char *  ,
unsigned &   
)
inline

Optimization: combination of hasAttribute() and getAttribute().

Returns true if hasAttribute() and (if so) also fills in the value.

Definition at line 256 of file serialize.hh.

◆ hasAttribute()

template<typename Derived>
bool openmsx::ArchiveBase< Derived >::hasAttribute ( const char *  )
inline

Check the presence of a (optional) attribute.

It's only allowed to call this method on archives that can have optional attributes.

Definition at line 248 of file serialize.hh.

◆ isReverseSnapshot()

template<typename Derived>
bool openmsx::ArchiveBase< Derived >::isReverseSnapshot ( ) const
inline

Is this a reverse-snapshot?

Definition at line 218 of file serialize.hh.

◆ needVersion()

template<typename Derived>
bool openmsx::ArchiveBase< Derived >::needVersion ( ) const
inline

Does this archive store version information.

Definition at line 215 of file serialize.hh.

◆ self()

template<typename Derived>
Derived& openmsx::ArchiveBase< Derived >::self ( )
inlineprotected

Returns a reference to the most derived class.

Helper function to implement static polymorphism.

Definition at line 341 of file serialize.hh.

◆ serializeBase()

template<typename Derived>
template<typename Base , typename T >
void openmsx::ArchiveBase< Derived >::serializeBase ( T &  t)
inline

Is this archive a loader or a saver.

bool isLoader() const; Serialize the base class of this classtype. Should preferably be called as the first statement in the implementation of a serialize() method of a class type. See also serializeInlinedBase() below.

Definition at line 87 of file serialize.hh.

◆ serializeInlinedBase()

template<typename Derived>
template<typename Base , typename T >
void openmsx::ArchiveBase< Derived >::serializeInlinedBase ( T &  t,
unsigned  version 
)
inline

Serialize the base class of this classtype.

Should preferably be called as the first statement in the implementation of a serialize() method of a class type. See also serializeBase() above.

The differece between serializeBase() and serializeInlinedBase() is only relevant for versioned archives (see needVersion(), e.g. XML archives). In XML archives serializeBase() will put the base class in a new subtag, serializeInlinedBase() puts the members of the base class (inline) in the current tag. The advantage of serializeBase() is that the base class can be versioned seperatly from the subclass. The disadvantage is that it exposes an internal implementation detail in the XML file, and thus makes it harder to for example change the class hierarchy or move members from base to subclass or vice-versa.

Definition at line 110 of file serialize.hh.

◆ translateEnumToString()

template<typename Derived>
bool openmsx::ArchiveBase< Derived >::translateEnumToString ( ) const
inline

Does this archive store enums as strings.

See also struct serialize_as_enum.

Definition at line 223 of file serialize.hh.


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