Changed DemHandlers file read/write types to typedefs

This commit is contained in:
Jordan Cristiano 2015-06-18 20:18:55 -04:00
parent 0d7c67aef8
commit b67f448d18
10 changed files with 28 additions and 26 deletions

View File

@ -4,7 +4,7 @@
namespace DemHandlers namespace DemHandlers
{ {
bool Dem_ConsoleCmd_FileRead_Internal(DemoFileReader& demofile, DemMsg::Dem_ConsoleCmd* data) bool Dem_ConsoleCmd_FileRead_Internal(FileRead& demofile, DemMsg::Dem_ConsoleCmd* data)
{ {
char command[DemMsg::Dem_ConsoleCmd::COMMAND_MAX_LENGTH]; char command[DemMsg::Dem_ConsoleCmd::COMMAND_MAX_LENGTH];
demofile.ReadRawData(reinterpret_cast<uint8_t*>(command), sizeof(command)); demofile.ReadRawData(reinterpret_cast<uint8_t*>(command), sizeof(command));
@ -12,7 +12,7 @@ namespace DemHandlers
return demofile.IsOk(); return demofile.IsOk();
} }
bool Dem_ConsoleCmd_FileWrite_Internal(DemoFileWriter& demofile, DemMsg::Dem_ConsoleCmd* data) bool Dem_ConsoleCmd_FileWrite_Internal(FileWrite& demofile, DemMsg::Dem_ConsoleCmd* data)
{ {
const uint8_t* command = reinterpret_cast<const uint8_t*>(data->command.data()); const uint8_t* command = reinterpret_cast<const uint8_t*>(data->command.data());
demofile.WriteRawData(command, data->command.length() + 1); demofile.WriteRawData(command, data->command.length() + 1);

View File

@ -4,13 +4,13 @@
namespace DemHandlers namespace DemHandlers
{ {
bool Dem_DataTables_FileRead_Internal(DemoFileReader& demofile, DemMsg::Dem_DataTables* data) bool Dem_DataTables_FileRead_Internal(FileRead& demofile, DemMsg::Dem_DataTables* data)
{ {
data->data = demofile.ReadRawData(DemMsg::Dem_DataTables::DATA_MAX_LENGTH); data->data = demofile.ReadRawData(DemMsg::Dem_DataTables::DATA_MAX_LENGTH);
return demofile.IsOk(); return demofile.IsOk();
} }
bool Dem_DataTables_FileWrite_Internal(DemoFileWriter& demofile, DemMsg::Dem_DataTables* data) bool Dem_DataTables_FileWrite_Internal(FileWrite& demofile, DemMsg::Dem_DataTables* data)
{ {
demofile.WriteRawData(data->data.begin(), data->data.length()); demofile.WriteRawData(data->data.begin(), data->data.length());
return demofile.IsOk(); return demofile.IsOk();

View File

@ -4,7 +4,7 @@
namespace DemHandlers namespace DemHandlers
{ {
bool Dem_Packet_FileRead_Internal(DemoFileReader& demofile, DemMsg::Dem_Packet* data) bool Dem_Packet_FileRead_Internal(FileRead& demofile, DemMsg::Dem_Packet* data)
{ {
demofile.ReadCmdInfo(data->cmdInfo); demofile.ReadCmdInfo(data->cmdInfo);
demofile.ReadSequenceInfo(data->sequenceNum1, data->sequenceNum2); demofile.ReadSequenceInfo(data->sequenceNum1, data->sequenceNum2);
@ -12,7 +12,7 @@ namespace DemHandlers
return demofile.IsOk(); return demofile.IsOk();
} }
bool Dem_Packet_FileWrite_Internal(DemoFileWriter& demofile, DemMsg::Dem_Packet* data) bool Dem_Packet_FileWrite_Internal(FileWrite& demofile, DemMsg::Dem_Packet* data)
{ {
demofile.WriteCmdInfo(data->cmdInfo); demofile.WriteCmdInfo(data->cmdInfo);
demofile.WriteSequenceInfo(data->sequenceNum1, data->sequenceNum2); demofile.WriteSequenceInfo(data->sequenceNum1, data->sequenceNum2);

View File

@ -3,12 +3,12 @@
namespace DemHandlers namespace DemHandlers
{ {
bool Dem_Stop_FileRead_Internal(DemoFileReader& demofile, DemMsg::Dem_Stop* data) bool Dem_Stop_FileRead_Internal(FileRead& demofile, DemMsg::Dem_Stop* data)
{ {
return true; return true;
} }
bool Dem_Stop_FileWrite_Internal(DemoFileWriter& demofile, DemMsg::Dem_Stop* data) bool Dem_Stop_FileWrite_Internal(FileWrite& demofile, DemMsg::Dem_Stop* data)
{ {
return true; return true;
} }

View File

@ -93,7 +93,7 @@ static void StringTable_BitWrite(bf_write& bitbuf, DemMsg::Dem_StringTables::Str
namespace DemHandlers namespace DemHandlers
{ {
bool Dem_StringTables_FileRead_Internal(DemoFileReader& demofile, DemMsg::Dem_StringTables* data) bool Dem_StringTables_FileRead_Internal(FileRead& demofile, DemMsg::Dem_StringTables* data)
{ {
using StringTable = DemMsg::Dem_StringTables::StringTable; using StringTable = DemMsg::Dem_StringTables::StringTable;
@ -108,7 +108,7 @@ namespace DemHandlers
return !bitbuf.IsOverflowed(); return !bitbuf.IsOverflowed();
} }
bool Dem_StringTables_FileWrite_Internal(DemoFileWriter& demofile, DemMsg::Dem_StringTables* data) bool Dem_StringTables_FileWrite_Internal(FileWrite& demofile, DemMsg::Dem_StringTables* data)
{ {
using StringTable = DemMsg::Dem_StringTables::StringTable; using StringTable = DemMsg::Dem_StringTables::StringTable;

View File

@ -3,12 +3,12 @@
namespace DemHandlers namespace DemHandlers
{ {
bool Dem_SyncTick_FileRead_Internal(DemoFileReader& demofile, DemMsg::Dem_SyncTick* data) bool Dem_SyncTick_FileRead_Internal(FileRead& demofile, DemMsg::Dem_SyncTick* data)
{ {
return true; return true;
} }
bool Dem_SyncTick_FileWrite_Internal(DemoFileWriter& demofile, DemMsg::Dem_SyncTick* data) bool Dem_SyncTick_FileWrite_Internal(FileWrite& demofile, DemMsg::Dem_SyncTick* data)
{ {
return true; return true;
} }

View File

@ -3,12 +3,12 @@
namespace DemHandlers namespace DemHandlers
{ {
bool Dem_Unknown_FileRead_Internal(DemoFileReader& demofile, DemMsg::Dem_Unknown* data) bool Dem_Unknown_FileRead_Internal(FileRead& demofile, DemMsg::Dem_Unknown* data)
{ {
return true; return true;
} }
bool Dem_Unknown_FileWrite_Internal(DemoFileWriter& demofile, DemMsg::Dem_Unknown* data) bool Dem_Unknown_FileWrite_Internal(FileWrite& demofile, DemMsg::Dem_Unknown* data)
{ {
return true; return true;
} }

View File

@ -4,13 +4,13 @@
namespace DemHandlers namespace DemHandlers
{ {
bool Dem_UserCmd_FileRead_Internal(DemoFileReader& demofile, DemMsg::Dem_UserCmd* data) bool Dem_UserCmd_FileRead_Internal(FileRead& demofile, DemMsg::Dem_UserCmd* data)
{ {
data->commandData = demofile.ReadUserCmd(data->commandNum, DemMsg::Dem_UserCmd::COMMANDDATA_MAX_LENGTH); data->commandData = demofile.ReadUserCmd(data->commandNum, DemMsg::Dem_UserCmd::COMMANDDATA_MAX_LENGTH);
return demofile.IsOk(); return demofile.IsOk();
} }
bool Dem_UserCmd_FileWrite_Internal(DemoFileWriter& demofile, DemMsg::Dem_UserCmd* data) bool Dem_UserCmd_FileWrite_Internal(FileWrite& demofile, DemMsg::Dem_UserCmd* data)
{ {
demofile.WriteUserCmd(data->commandNum, data->commandData.begin(), data->commandData.length()); demofile.WriteUserCmd(data->commandNum, data->commandData.begin(), data->commandData.length());
return demofile.IsOk(); return demofile.IsOk();

View File

@ -15,18 +15,18 @@
&DemHandlers::Dem_StringTables_##funcname \ &DemHandlers::Dem_StringTables_##funcname \
} }
typedef bool (*DemMsgFileReadFn)(DemoFileReader& demofile, void* data); typedef bool (*DemMsgFileReadFn)(FileRead& demofile, void* data);
typedef bool (*DemMsgFileWriteFn)(DemoFileWriter& demofile, void* data); typedef bool (*DemMsgFileWriteFn)(FileWrite& demofile, void* data);
typedef bool (*DemMsgJsonReadFn)(JsonRead& jsonbuf, void* data); typedef bool (*DemMsgJsonReadFn)(JsonRead& jsonbuf, void* data);
typedef bool (*DemMsgJsonWriteFn)(JsonWrite& jsonbuf, void* data); typedef bool (*DemMsgJsonWriteFn)(JsonWrite& jsonbuf, void* data);
bool DemHandlers::DemMsg_FileRead(uint32_t type, DemoFileReader& demofile, void* data) bool DemHandlers::DemMsg_FileRead(uint32_t type, FileRead& demofile, void* data)
{ {
static const DemMsgFileReadFn demHandlers[] = DECLARE_DEM_HANDLER_ARRAY(FileRead); static const DemMsgFileReadFn demHandlers[] = DECLARE_DEM_HANDLER_ARRAY(FileRead);
return demHandlers[type](demofile, data); return demHandlers[type](demofile, data);
} }
bool DemHandlers::DemMsg_FileWrite(uint32_t type, DemoFileWriter& demofile, void* data) bool DemHandlers::DemMsg_FileWrite(uint32_t type, FileWrite& demofile, void* data)
{ {
static const DemMsgFileWriteFn demHandlers[] = DECLARE_DEM_HANDLER_ARRAY(FileWrite); static const DemMsgFileWriteFn demHandlers[] = DECLARE_DEM_HANDLER_ARRAY(FileWrite);
return demHandlers[type](demofile, data); return demHandlers[type](demofile, data);

View File

@ -5,21 +5,23 @@
class DemoFileReader; class DemoFileReader;
class DemoFileWriter; class DemoFileWriter;
using FileRead = DemoFileReader;
using FileWrite = DemoFileWriter;
class JsonRead; class JsonRead;
class JsonWrite; class JsonWrite;
#define DECLARE_DEM_HANDLERS(msgname) \ #define DECLARE_DEM_HANDLERS(msgname) \
namespace DemHandlers \ namespace DemHandlers \
{ \ { \
bool msgname##_FileRead_Internal(DemoFileReader& demofile, DemMsg::msgname* data); \ bool msgname##_FileRead_Internal(FileRead& demofile, DemMsg::msgname* data); \
bool msgname##_FileWrite_Internal(DemoFileWriter& demofile, DemMsg::msgname* data); \ bool msgname##_FileWrite_Internal(FileWrite& demofile, DemMsg::msgname* data); \
bool msgname##_JsonRead_Internal(JsonRead& jsonbuf, DemMsg::msgname* data); \ bool msgname##_JsonRead_Internal(JsonRead& jsonbuf, DemMsg::msgname* data); \
bool msgname##_JsonWrite_Internal(JsonWrite& jsonbuf, DemMsg::msgname* data); \ bool msgname##_JsonWrite_Internal(JsonWrite& jsonbuf, DemMsg::msgname* data); \
inline bool msgname##_FileRead(DemoFileReader& demofile, void* data) \ inline bool msgname##_FileRead(FileRead& demofile, void* data) \
{ \ { \
return msgname##_FileRead_Internal(demofile, reinterpret_cast<DemMsg::msgname*>(data)); \ return msgname##_FileRead_Internal(demofile, reinterpret_cast<DemMsg::msgname*>(data)); \
} \ } \
inline bool msgname##_FileWrite(DemoFileWriter& demofile, void* data) \ inline bool msgname##_FileWrite(FileWrite& demofile, void* data) \
{ \ { \
return msgname##_FileWrite_Internal(demofile, reinterpret_cast<DemMsg::msgname*>(data)); \ return msgname##_FileWrite_Internal(demofile, reinterpret_cast<DemMsg::msgname*>(data)); \
} \ } \
@ -35,8 +37,8 @@ class JsonWrite;
namespace DemHandlers namespace DemHandlers
{ {
bool DemMsg_FileRead(uint32_t type, DemoFileReader& demofile, void* data); bool DemMsg_FileRead(uint32_t type, FileRead& demofile, void* data);
bool DemMsg_FileWrite(uint32_t type, DemoFileWriter& demofile, void* data); bool DemMsg_FileWrite(uint32_t type, FileWrite& demofile, void* data);
bool DemMsg_JsonRead(uint32_t type, JsonRead& jsonbuf, void* data); bool DemMsg_JsonRead(uint32_t type, JsonRead& jsonbuf, void* data);
bool DemMsg_JsonWrite(uint32_t type, JsonWrite& jsonbuf, void* data); bool DemMsg_JsonWrite(uint32_t type, JsonWrite& jsonbuf, void* data);
} }