You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
BitStream already has the good bits — operator overloads at BitStream.h:1914-1928:
template <classT> BitStream& operator<<(BitStream& out, const T& c) { out.Write(c); return out; }
template <classT> BitStream& operator>>(BitStream& in, T& c) { in.Read(c); return in; }
and a bidirectional Serialize(bool writeToBitstream, T& inOut) at BitStream.h:89. But message code still (de)serializes field-by-field and manually skips the header with IgnoreBytes(sizeof(MessageID)) (BitStream.h:513).
Goal
A single serialize convention so a user type describes its wire format once and works in both directions:
structChatMessage {
std::string text;
int channel;
template <classAr> voidserialize(Ar& ar) { ar & text & channel; }
};
Context
BitStreamalready has the good bits — operator overloads atBitStream.h:1914-1928:and a bidirectional
Serialize(bool writeToBitstream, T& inOut)atBitStream.h:89. But message code still (de)serializes field-by-field and manually skips the header withIgnoreBytes(sizeof(MessageID))(BitStream.h:513).Goal
A single serialize convention so a user type describes its wire format once and works in both directions:
with an
Archiveadapter:Where
New header
Source/include/mafianet/Archive.h, built onBitStream.h. Export from umbrella (#12).Notes
operator<</operator>>andBitStream's type specializations (it already handlesstd::string,SystemAddress,RakNetGUID, etc.) — don't reimplement primitives.serialize()should round-trip; consider also accepting types that already haveoperator<</>>.Acceptance criteria
template<class Ar> serialize(Ar&)round-trips through aBitStream(write then read yields equal value).std::string.Dependencies
BitStream.