1
0
forked from 0ad/0ad

String conversion fix/extension

This was SVN commit r1285.
This commit is contained in:
Simon Brenner 2004-11-07 21:57:46 +00:00
parent 3136791492
commit c32e6d5215
2 changed files with 27 additions and 2 deletions

View File

@ -94,6 +94,8 @@ struct _nm: public CNetMessage \
#ifdef NMT_CREATOR_IMPLEMENT #ifdef NMT_CREATOR_IMPLEMENT
#include "StringConverters.h"
/*************************************************************************/ /*************************************************************************/
// Pass 2, GetSerializedLength // Pass 2, GetSerializedLength
#define NMT_CREATOR_PASS_GETLENGTH #define NMT_CREATOR_PASS_GETLENGTH
@ -270,12 +272,12 @@ CStr _nm::GetString() const \
#define NMT_FIELD_INT(_nm, _hosttp, _netsz) \ #define NMT_FIELD_INT(_nm, _hosttp, _netsz) \
ret += #_nm _T(": "); \ ret += #_nm _T(": "); \
ret += CStr(thiz->_nm); \ ret += NetMessageStringConvert(thiz->_nm); \
ret += _T(", "); ret += _T(", ");
#define NMT_FIELD(_tp, _nm) \ #define NMT_FIELD(_tp, _nm) \
ret += #_nm _T(": "); \ ret += #_nm _T(": "); \
ret += CStr(thiz->_nm); \ ret += NetMessageStringConvert(thiz->_nm); \
ret += _T(", "); ret += _T(", ");
#define END_NMT_CLASS() \ #define END_NMT_CLASS() \

View File

@ -0,0 +1,23 @@
#ifndef _StringConverters_H
#define _StringConverters_H
#include "CStr.h"
#include "simulation/EntityHandles.h"
template <typename _T>
CStr NetMessageStringConvert(const _T &arg);
// String Converters
template <typename _T>
inline CStr NetMessageStringConvert(const _T &arg)
{
return CStr(arg);
}
template <>
inline CStr NetMessageStringConvert(const HEntity &arg)
{
return arg.operator CStr8();
}
#endif