00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011 #ifndef __MESSAGEHELPER_H__
00012 #define __MESSAGEHELPER_H__
00013 #include "RNPlatform/Inc/DLLExportAPI.h"
00014 #include <string>
00015
00016 namespace RNReplicaNet
00017 {
00018
00019 #define MESSAGEHELPER_ADDVARIABLE(x) \
00020 AddVariable(&(x),sizeof(x));
00021
00022 #define MESSAGEHELPER_GETVARIABLE(x) \
00023 GetVariable(&(x),sizeof(x));
00024
00025 #define MESSAGEHELPER_ADDVARIABLEp(y,x) \
00026 y.AddVariable(&(x),sizeof(x));
00027
00028 #define MESSAGEHELPER_GETVARIABLEp(y,x) \
00029 y.GetVariable(&(x),sizeof(x));
00030
00035 class REPNETEXPORTAPI MessageHelper
00036 {
00037 public:
00041 MessageHelper();
00042
00046 virtual ~MessageHelper();
00047
00052 void SetBuffer(void *const buffer);
00053
00059 void AddVariable(const void *variable,const int size);
00060
00066 void AddData(const void *data,const int size);
00067
00073 void GetVariable(void *const variable,const int size);
00074
00080 void GetData(void *const data,const int size);
00081
00086 int GetSize(void);
00087
00092 void SetSize(const int size);
00093
00098 void AddInteger(const int value);
00099
00104 void AddFloat(const float value);
00105
00110 int GetInteger(void);
00111
00117 float GetFloat(void);
00118
00122 static std::string DumpAsHex(const void *data,const int size);
00123
00124 private:
00125 unsigned char *mFirstPtr;
00126 unsigned char *mBufferPtr;
00127 };
00128
00129 }
00130
00131 #endif