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

Constructor & Destructor Documentation

◆ StdHexAdapt()

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

Definition at line 1002 of file StdAdaptors.h.

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

Member Function Documentation

◆ CompileFunc()

void StdHexAdapt::CompileFunc ( StdCompiler pComp) const
inline

Definition at line 1003 of file StdAdaptors.h.

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

1004  {
1005  if (!pComp->isVerbose())
1006  pComp->Raw(pData, iSize);
1007  char szData[2+1]; bool deserializing = pComp->isDeserializer();
1008  for (size_t i = 0; i < iSize; i++)
1009  {
1010  uint8_t *pByte = reinterpret_cast<uint8_t *>(pData) + i;
1011  if (!deserializing) sprintf(szData, "%02x", *pByte);
1012  pComp->String(szData, 2, StdCompiler::RCT_Idtf);
1013  if (deserializing)
1014  {
1015  unsigned int b;
1016  if (sscanf(szData, "%02x", &b) != 1)
1017  pComp->excNotFound(i ? "hexadecimal data: bytes missing!" : "hexadecimal data missing!");
1018  *pByte = b;
1019  }
1020  }
1021  }
#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: