Template Struct Archivable

Struct Documentation

template<typename T>
struct Archivable

Non-intrusive archiving customization point.

Specialize this template to enable archiving for types you don’t control. The specialization must provide static archive() and dearchive() functions.

Example:

// For a third-party type you can't modify:
template <>
struct Archivable<ThirdPartyConfig> {
    static void archive(const ThirdPartyConfig& obj, ArchiveObject& ar) {
        ar.add_property("name", obj.getName());
        ar.add_property("value", obj.getValue());
    }
    static ThirdPartyConfig dearchive(ArchiveObject& ar) {
        std::string name;
        int value;
        ar.get_property("name", name);
        ar.get_property("value", value);
        return ThirdPartyConfig(name, value);
    }
};

Template Parameters:

T – The type to provide archiving support for