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 980 of file StdAdaptors.h.

Constructor & Destructor Documentation

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

Definition at line 984 of file StdAdaptors.h.

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

Member Function Documentation

void StdHexAdapt::CompileFunc ( StdCompiler pComp) const
inline

Definition at line 985 of file StdAdaptors.h.

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

986  {
987  if (!pComp->isVerbose())
988  pComp->Raw(pData, iSize);
989  char szData[2+1]; bool deserializing = pComp->isDeserializer();
990  for (size_t i = 0; i < iSize; i++)
991  {
992  uint8_t *pByte = reinterpret_cast<uint8_t *>(pData) + i;
993  if (!deserializing) sprintf(szData, "%02x", *pByte);
994  pComp->String(szData, 2, StdCompiler::RCT_Idtf);
995  if (deserializing)
996  {
997  unsigned int b;
998  if (sscanf(szData, "%02x", &b) != 1)
999  pComp->excNotFound(i ? "hexadecimal data: bytes missing!" : "hexadecimal data missing!");
1000  *pByte = b;
1001  }
1002  }
1003  }
#define b
#define sprintf
Definition: Standard.h:164
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:62
void excNotFound(const char *szMessage,...)
Definition: StdCompiler.h:233
virtual bool isDeserializer()
Definition: StdCompiler.h:53

Here is the call graph for this function:


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