Created
October 4, 2018 19:31
-
-
Save galik/c3b075560fad9ea4bae9d9d06da4caa0 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
It seems to me you should at least be able to avoid figuring out all the different buffer offsets and field types. | |
maybe something like this? | |
struct stuff_t | |
{ | |
std::uint16_t a; | |
float b; | |
std::uint64_t c; | |
// ... | |
}; | |
template<typename Field> | |
char const* copy_fild(Field& field, char const* pos) | |
{ | |
std::copy(pos, pos + sizeof(field), (char*)&field); | |
return pos + sizeof(field); | |
} | |
char const* copy_stuff(stuff_t& st, char const* const buffer) | |
{ | |
auto pos = buffer; | |
pos = copy_fild(st.a, pos); | |
pos = copy_fild(st.b, pos); | |
pos = copy_fild(st.c, pos); | |
// ... | |
return pos; | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment