openMSX
|
#include <serialize.hh>
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 | isReverseSnapshot () const |
Is this a reverse-snapshot? 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 | hasAttribute (const char *) |
Check the presence of a (optional) attribute. More... | |
template<typename T > | |
std::optional< T > | findAttributeAs (const char *) |
Optimization: combination of hasAttribute() and getAttribute(). 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... | |
Static Public Attributes | |
static constexpr bool | NEED_VERSION = true |
Does this archive store version information. More... | |
static constexpr bool | TRANSLATE_ENUM_TO_STRING = false |
Does this archive store enums as strings. More... | |
static constexpr bool | CAN_HAVE_OPTIONAL_ATTRIBUTES = false |
Some archives (like XML archives) can store optional attributes. More... | |
static constexpr bool | CAN_COUNT_CHILDREN = false |
Some archives (like XML archives) can count the number of subtags that belong to the current tag. More... | |
Protected Member Functions | |
Derived & | self () |
Returns a reference to the most derived class. More... | |
Definition at line 80 of file serialize.hh.
void openmsx::ArchiveBase< Derived >::attribute | ( | const char * | name, |
const char * | value | ||
) |
Definition at line 27 of file serialize.cc.
|
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 236 of file serialize.hh.
References openmsx::serialize(), and t.
|
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 294 of file serialize.hh.
Referenced by openmsx::InputArchiveBase< Derived >::doSerialize(), openmsx::OutputArchiveBase< Derived >::serialize(), openmsx::InputArchiveBase< Derived >::serialize(), openmsx::InputArchiveBase< Derived >::serializeChar(), openmsx::OutputArchiveBase< Derived >::serializeChar(), openmsx::OutputArchiveBase< Derived >::serializePointerID(), openmsx::InputArchiveBase< Derived >::serializePointerID(), and openmsx::OutputArchiveBase< Derived >::serializeWithID().
|
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 281 of file serialize.hh.
References UNREACHABLE.
|
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 304 of file serialize.hh.
Referenced by openmsx::InputArchiveBase< Derived >::doSerialize(), openmsx::OutputArchiveBase< Derived >::serialize(), openmsx::InputArchiveBase< Derived >::serialize(), openmsx::InputArchiveBase< Derived >::serializeChar(), openmsx::OutputArchiveBase< Derived >::serializeChar(), openmsx::OutputArchiveBase< Derived >::serializePointerID(), openmsx::InputArchiveBase< Derived >::serializePointerID(), and openmsx::OutputArchiveBase< Derived >::serializeWithID().
|
inline |
Optimization: combination of hasAttribute() and getAttribute().
Returns true if hasAttribute() and (if so) also fills in the value.
Definition at line 262 of file serialize.hh.
References UNREACHABLE.
|
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 253 of file serialize.hh.
References UNREACHABLE.
|
inline |
Is this a reverse-snapshot?
Definition at line 223 of file serialize.hh.
|
inlineprotected |
Returns a reference to the most derived class.
Helper function to implement static polymorphism.
Definition at line 347 of file serialize.hh.
|
inline |
Is this archive a loader or a saver.
static constexpr bool IS_LOADER = ...; 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 92 of file serialize.hh.
References openmsx::Keys::getName(), openmsx::serialize(), and t.
|
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 NEED_VERSION, 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 separately 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 115 of file serialize.hh.
References openmsx::serialize(), and t.
|
staticconstexpr |
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 explicitly store the size of the collection, it can be derived from the number of subtags.
Definition at line 275 of file serialize.hh.
|
staticconstexpr |
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 247 of file serialize.hh.
|
staticconstexpr |
Does this archive store version information.
Definition at line 220 of file serialize.hh.
|
staticconstexpr |
Does this archive store enums as strings.
See also struct serialize_as_enum.
Definition at line 228 of file serialize.hh.