Skip to content

Instantly share code, notes, and snippets.

@Rapptz
Created February 9, 2016 04:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Rapptz/0ebcb6dfdff14fd85ebb to your computer and use it in GitHub Desktop.
Save Rapptz/0ebcb6dfdff14fd85ebb to your computer and use it in GitHub Desktop.
/*
Given a JSON object:
{
"id": "144843276418023424",
"position": -1,
"colour": 0,
"name": "test",
"managed": false
}
*/
struct rgb_colour {
unsigned char r, g, b;
rgb_colour(int x) {
// unpack x into r g b bytes
}
};
struct cool {
rgb_colour colour;
std::string name;
std::string id;
int position;
bool managed;
};
// deserialisation begins here
struct cool_schema {
template<typename Algo>
void operator()(Algo& algo, cool& c) const {
algo.member("name", c.name);
algo.member("id", c.id);
algo.member("position", c.position);
algo.member("managed", c.managed);
// how2do for rgb_colour?
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment