openMSX
openmsx::serialize_as_enum< T > Struct Template Reference

serialize_as_enum<T> More...

#include <serialize_core.hh>

Inheritance diagram for openmsx::serialize_as_enum< T >:
Inheritance graph
[legend]
Collaboration diagram for openmsx::serialize_as_enum< T >:
Collaboration graph
[legend]

Detailed Description

template<typename T>
struct openmsx::serialize_as_enum< T >

serialize_as_enum<T>

For serialization of enums to work you have to specialize the serialize_as_enum struct for that specific enum. This has a double purpose:

The serialize_as_enum class has the following members:

If the enum has all consecutive values, starting from zero (as is the case if you don't explicitly mention the numeric values in the enum definition), you can use the SERIALIZE_ENUM macro as a convenient way to define a specialization of serialize_as_enum:

example: enum MyEnum { FOO, BAR }; std::initializer_list<enum_string<MyEnum>> myEnumInfo = { { "FOO", FOO }, { "BAR", BAR }, }; SERIALIZE_ENUM(MyEnum, myEnumInfo);

Note: when an enum definition evolves it has impact on the serialization, more specific on de-serialization of older version of the enum: adding values or changing the numerical value is no problem. But be careful with removing a value or changing the string representation.

Definition at line 107 of file serialize_core.hh.


The documentation for this struct was generated from the following file: