Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compatibility with cereal #10

Open
mdimura opened this issue Mar 30, 2018 · 2 comments
Open

Compatibility with cereal #10

mdimura opened this issue Mar 30, 2018 · 2 comments

Comments

@mdimura
Copy link

mdimura commented Mar 30, 2018

Would it be possible to implement a compatibility layer for cereal similar to fusion/hana?

@cbeck88
Copy link
Owner

cbeck88 commented Mar 30, 2018

Hi,

I've looked at Cereal in the past, but not too recently. IIRC it's like, you add the visitation function to your struct, so,

struct my_struct {
    int a;
    float b;
    double c;

    template <typename A>
    void archive(A & archiver) {
        archiver(a);
        archiver(b);
        archiver(c);
    }
};

and then Cereal picks up on the existence of the archive template member function and uses it to visit the struct.

I think that visit_struct cannot create a compatibility layer like with Fusion and Hana to this API, because it gives me no way to determine the struct member names.

However, maybe we can make a patch in Cereal, so that if your struct does not have an ::archive function, then it checks if it is a visitable structure and tries to use the visit_struct api instead? Cereal would then also get the benefit of the hana and fusion compat layers I think.

@mdimura
Copy link
Author

mdimura commented Mar 30, 2018

It seems, you are right. I think, a patch for Cereal would be great. Thank you for the response!

no way to determine the struct member names.

Yep, apparantly, Cereal uses default names like value0 if no other name is provided:

archive( CEREAL_NVP(m1), // Names the output the same as the variable name
        someInt,        // No NVP - cereal will automatically generate an enumerated name
        cereal::make_nvp("this_name_is_way_better", d) ); // specify a name of your choosing

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants