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

dealing with Pointers #56

Open
chaterpaul opened this issue Apr 29, 2019 · 1 comment
Open

dealing with Pointers #56

chaterpaul opened this issue Apr 29, 2019 · 1 comment

Comments

@chaterpaul
Copy link

Hi,

How do you deal with members of classes which are pointers. i.e.

class Bar
{ int a;}

static  spotify::json::codec::object_t<Bar> codec()
{
    auto codec = spotify::json::codec::object<Bar>();
    codec.required("a", &Bar::a);
    return codec;
}

class Foo
{
int b;
Bar *c;
}

static  spotify::json::codec::object_t<Foo> codec()
{
    auto codec = spotify::json::codec::object<Foo>();
    codec.required("b", &Foo::b);

// how to represent Bar *c;
return codec;
}

How do I represent *c in the codec. I cant find any example which deals with a pointer.

Thanks

Paul

@per-gron
Copy link

If you can I would use std::unique_ptr<Bar> instead of Bar. The library supports this. Otherwise you can use transform_t.

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