OpenClonk
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros
StdHexAdapt Class Reference

#include <StdAdaptors.h>

Public Member Functions

 StdHexAdapt (void *pData, size_t iSize)
 
void CompileFunc (StdCompiler *pComp) const
 

Detailed Description

Definition at line 978 of file StdAdaptors.h.

Constructor & Destructor Documentation

StdHexAdapt::StdHexAdapt ( void *  pData,
size_t  iSize 
)
inline

Definition at line 982 of file StdAdaptors.h.

982 : pData(pData), iSize(iSize) { }

Member Function Documentation

void StdHexAdapt::CompileFunc ( StdCompiler pComp) const
inline

Definition at line 983 of file StdAdaptors.h.

References b, StdCompiler::excNotFound(), StdCompiler::isDeserializer(), iSize, StdCompiler::isVerbose(), StdCompiler::Raw(), StdCompiler::RCT_Idtf, sprintf, and StdCompiler::String().

984  {
985  if (!pComp->isVerbose())
986  pComp->Raw(pData, iSize);
987  char szData[2+1]; bool deserializing = pComp->isDeserializer();
988  for (size_t i = 0; i < iSize; i++)
989  {
990  uint8_t *pByte = reinterpret_cast<uint8_t *>(pData) + i;
991  if (!deserializing) sprintf(szData, "%02x", *pByte);
992  pComp->String(szData, 2, StdCompiler::RCT_Idtf);
993  if (deserializing)
994  {
995  unsigned int b;
996  if (sscanf(szData, "%02x", &b) != 1)
997  pComp->excNotFound(i ? "hexadecimal data: bytes missing!" : "hexadecimal data missing!");
998  *pByte = b;
999  }
1000  }
1001  }
#define b
#define sprintf
Definition: Standard.h:171
virtual void Raw(void *pData, size_t iSize, RawCompileType eType=RCT_Escaped)=0
virtual void String(char *szString, size_t iMaxLength, RawCompileType eType=RCT_Escaped)=0
virtual bool isVerbose()
Definition: StdCompiler.h:72
void excNotFound(const char *szMessage,...)
Definition: StdCompiler.h:242
virtual bool isDeserializer()
Definition: StdCompiler.h:63

Here is the call graph for this function:


The documentation for this class was generated from the following file: