11 #include "RNPlatform/Inc/MemoryTracking.h"
12 #ifndef __MESSAGEHELPER_H__
13 #define __MESSAGEHELPER_H__
16 namespace RNReplicaNet
19 #define MESSAGEHELPER_ADDVARIABLE(x) \
20 AddVariable(&(x),sizeof(x));
22 #define MESSAGEHELPER_GETVARIABLE(x) \
23 GetVariable(&(x),sizeof(x));
25 #define MESSAGEHELPER_ADDVARIABLEp(y,x) \
26 y.AddVariable(&(x),sizeof(x));
28 #define MESSAGEHELPER_GETVARIABLEp(y,x) \
29 y.GetVariable(&(x),sizeof(x));
77 virtual void AddVariable(
const void *variable,
const int size);
79 static void AddVariable(
void *buffer,
const void *variable,
const int size);
86 virtual void AddData(
const void *data,
const int size);
93 void GetVariable(
void *
const variable,
const int size);
95 static void GetVariable(
const void *buffer,
void *
const variable,
const int size);
102 void GetData(
void *
const data,
const int size);
149 static int GetInt(
const void *buffer,
const int offset);
150 static short GetShort(
const void *buffer,
const int offset);
151 static void SetInt(
void *buffer,
const int offset,
const int value);
152 static void SetShort(
void *buffer,
const int offset,
const short value);
157 static std::string
DumpAsHex(
const void *data,
const int size,
const bool csv =
true);
159 std::string
DumpAsHex(
const bool csv =
true)
const
169 void SanityCheckGuardSize(
const int newSize = 0);
179 template <
typename T>
180 void operator<<(
const T& rhs)
182 MESSAGEHELPER_ADDVARIABLE(rhs);
184 template <
typename T>
185 void operator>>(T& rhs)
187 MESSAGEHELPER_GETVARIABLE(rhs);
191 void operator<<(
const char *rhs);
192 void operator<<(
const std::string &rhs);
193 void operator>>(std::string &rhs);
196 void operator<<(
const bool &rhs);
197 void operator>>(
bool &rhs);
200 unsigned char *mFirstPtr;
201 unsigned char *mBufferPtr;
241 void SetBuffer(
void *
const) {}
264 void AddVariable(
const void *variable,
const int size);
266 void AddData(
const void *data,
const int size);
282 bool Write(
const char *filename,
const bool rawData =
false);
288 bool Read(
const char *filename,
const bool rawData =
false);
293 template <
typename T>
294 void operator<<(
const T& rhs)
296 MESSAGEHELPER_ADDVARIABLE(rhs);
298 template <
typename T>
299 void operator>>(T& rhs)
301 MESSAGEHELPER_GETVARIABLE(rhs);
305 void operator<<(
const char *rhs);
306 void operator<<(
const std::string &rhs);
307 void operator>>(std::string &rhs);
317 void operator<<(
const bool &rhs);
318 void operator>>(
bool &rhs);
326 void CheckBufferSize(
const int newSize);
void SetGuardSize(const int size=-1)
Definition: MessageHelper.h:38
virtual void AddData(const void *data, const int size)
void GetData(void *const data, const int size)
void GetVariable(void *const variable, const int size)
void AddVariable(const void *variable, const int size)
int GetLastSizeAdded(void) const
void AddInteger(const int value)
void * GetCurrentPosition(void) const
void SkipData(const int size)
Definition: MessageHelper.h:35
virtual ~DynamicMessageHelper()
void EnsureBufferAllocated(void)
virtual void AddVariable(const void *variable, const int size)
void AddData(const void *data, const int size)
void * GetBuffer(void) const
bool ReadAsHex(const std::string &data)
void SetSize(const int size)
bool Write(const char *filename, const bool rawData=false)
void SetSize(const int size)
static std::string DumpAsHex(const void *data, const int size, const bool csv=true)
bool Read(const char *filename, const bool rawData=false)
void AddFloat(const float value)
void SetBuffer(void *const buffer)
Definition: MessageHelper.h:211
void SetBufferSize(const int size=1024)