openMSX
|
#include <serialize.hh>
Public Member Functions | |
template<typename Base , typename T > | |
void | serializeBase (T &t) |
Is this archive a loader or a saver. | |
template<typename Base , typename T > | |
void | serializeInlinedBase (T &t, unsigned version) |
Serialize the base class of this classtype. | |
template<typename T > | |
void | serialize_blob (const char *tag, std::span< T > data, bool diff=true) |
template<typename T > | |
void | serialize_blob (const char *tag, std::span< const T > data, bool diff=true) |
bool | isReverseSnapshot () const |
Is this a reverse-snapshot? | |
template<typename T > | |
void | attribute (const char *name, T &t) |
Load/store an attribute from/in the archive. | |
void | attribute (const char *name, const char *value) |
bool | hasAttribute (const char *) const |
Check the presence of a (optional) attribute. | |
template<typename T > | |
std::optional< T > | findAttributeAs (const char *) |
Optimization: combination of hasAttribute() and getAttribute(). | |
int | countChildren () const |
Count the number of child tags. | |
void | beginTag (const char *) const |
Indicate begin of a tag. | |
void | endTag (const char *) const |
Indicate begin of a tag. | |
Static Public Attributes | |
static constexpr bool | NEED_VERSION = true |
Does this archive store version information. | |
static constexpr bool | TRANSLATE_ENUM_TO_STRING = false |
Does this archive store enums as strings. | |
static constexpr bool | CAN_HAVE_OPTIONAL_ATTRIBUTES = false |
Some archives (like XML archives) can store optional attributes. | |
static constexpr bool | CAN_COUNT_CHILDREN = false |
Some archives (like XML archives) can count the number of subtags that belong to the current tag. | |
Protected Member Functions | |
Derived & | self () |
Returns a reference to the most derived class. | |
Definition at line 81 of file serialize.hh.
void openmsx::ArchiveBase< Derived >::attribute | ( | const char * | name, |
const char * | value | ||
) |
Definition at line 30 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 248 of file serialize.hh.
References openmsx::ArchiveBase< Derived >::self(), 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 306 of file serialize.hh.
|
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 293 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 316 of file serialize.hh.
|
inline |
Optimization: combination of hasAttribute() and getAttribute().
Returns true if hasAttribute() and (if so) also fills in the value.
Definition at line 274 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 265 of file serialize.hh.
References UNREACHABLE.
|
inline |
Is this a reverse-snapshot?
Definition at line 235 of file serialize.hh.
|
inlineprotected |
Returns a reference to the most derived class.
Helper function to implement static polymorphism.
Definition at line 359 of file serialize.hh.
Referenced by openmsx::ArchiveBase< Derived >::attribute(), openmsx::InputArchiveBase< Derived >::doSerialize(), openmsx::OutputArchiveBase< Derived >::serialize(), openmsx::XmlOutputArchive::serialize(), openmsx::InputArchiveBase< Derived >::serialize(), openmsx::XmlInputArchive::serialize(), openmsx::ArchiveBase< Derived >::serialize_blob(), openmsx::ArchiveBase< Derived >::serialize_blob(), openmsx::ArchiveBase< Derived >::serializeBase(), openmsx::InputArchiveBase< Derived >::serializeChar(), openmsx::OutputArchiveBase< Derived >::serializeChar(), openmsx::ArchiveBase< Derived >::serializeInlinedBase(), openmsx::OutputArchiveBase< Derived >::serializePointerID(), openmsx::InputArchiveBase< Derived >::serializePointerID(), openmsx::OutputArchiveBase< Derived >::serializePolymorphic(), openmsx::InputArchiveBase< Derived >::serializePolymorphic(), and openmsx::OutputArchiveBase< Derived >::serializeWithID().
|
inline |
Definition at line 158 of file serialize.hh.
References openmsx::ArchiveBase< Derived >::self().
|
inline |
Definition at line 153 of file serialize.hh.
References openmsx::ArchiveBase< Derived >::self().
|
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 93 of file serialize.hh.
References openmsx::ArchiveBase< Derived >::self(), 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 difference 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 116 of file serialize.hh.
References openmsx::ArchiveBase< Derived >::self(), 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 287 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 259 of file serialize.hh.
|
staticconstexpr |
Does this archive store version information.
Definition at line 232 of file serialize.hh.
|
staticconstexpr |
Does this archive store enums as strings.
See also struct serialize_as_enum.
Definition at line 240 of file serialize.hh.