vendredi 8 janvier 2021

Cereal - How to specify not to serialize a member variable

I currently have something like this. Is there a way for me to specify not to serialize foo ?

    struct MyStruct
    {
        std::string Response;
        std::string Name;
        std::string id;
        Foo foo;

        template<class Archive>
        void serialize(Archive& ar)
        {
               ar(CEREAL_NVP(Response),
                CEREAL_NVP(Name),
                CEREAL_NVP(id),
                CEREAL_NVP(foo)
            );
        }
    };

I currently serialize this way

MyStruct struct
std::stringstream os;
{
    cereal::JSONOutputArchive ar(os);
    struct.serialize(ar);
}

Is there a way for me to specify not to serialize member variable foo ?

Aucun commentaire:

Enregistrer un commentaire