I've been looking for a way to effectively extract variables from data stored in a byte array. I looked at std:stream but the only examples I see used are with the cout object. There seems to be no way to set the underlying source to an array of bytes.
Right now my code looks like this, and I can imagine it looks rather ugly:
Code:
char *p = data+9; // start at byte 10
char str31[31];
user->SetName(std::memmove(str31, p, 31)); p += 31;
char i = *(p++);
user->SetPassword(std::memmove(str31, p, 31), i); p += 31;
user->SetAux(*(std::uint32_t*)p); p += 24; // skip 24 bytes of unused junk
user->SetRoom(*(std::uint32_t*)p); // skip rest