Skip to content

Instantly share code, notes, and snippets.

@cjameshuff
Created February 12, 2015 00:16
Show Gist options
  • Save cjameshuff/32bc668f4ad0aa1f263f to your computer and use it in GitHub Desktop.
Save cjameshuff/32bc668f4ad0aa1f263f to your computer and use it in GitHub Desktop.
#ifndef TEST_DEFS_H
#define TEST_DEFS_H
#include "flexproto.h"
using namespace flexproto;
struct Point {
int32_t x;
int32_t y;
};
inline auto encode_other(uint8_t *& data, const Point & value) -> void
{
encode(data, value.x);
encode(data, value.y);
}
inline auto decode_other(const uint8_t *& data, Point & value) -> void
{
value.x = decode<int32_t>(data);
value.y = decode<int32_t>(data);
}
struct Thing {
std::string name;
std::vector<uint8_t> data;
Point location;
};
inline auto encode_other(uint8_t *& data, const Thing & value) -> void
{
encode_other(data, value.name);
encode_other(data, value.data);
encode_other(data, value.location);
}
inline auto decode_other(const uint8_t *& data, Thing & value) -> void
{
decode_other(data, value.name);
decode_other(data, value.data);
decode_other(data, value.location);
}
#endif // TEST_DEFS_H
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment