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

Constructor & Destructor Documentation

◆ StdHexAdapt()

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

Definition at line 1016 of file StdAdaptors.h.

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

Member Function Documentation

◆ CompileFunc()

void StdHexAdapt::CompileFunc ( StdCompiler pComp) const
inline

Definition at line 1017 of file StdAdaptors.h.

1018  {
1019  if (!pComp->isVerbose())
1020  pComp->Raw(pData, iSize);
1021  char szData[2+1]; bool deserializing = pComp->isDeserializer();
1022  for (size_t i = 0; i < iSize; i++)
1023  {
1024  uint8_t *pByte = reinterpret_cast<uint8_t *>(pData) + i;
1025  if (!deserializing) sprintf(szData, "%02x", *pByte);
1026  pComp->String(szData, 2, StdCompiler::RCT_Idtf);
1027  if (deserializing)
1028  {
1029  unsigned int b;
1030  if (sscanf(szData, "%02x", &b) != 1)
1031  pComp->excNotFound(i ? "hexadecimal data: bytes missing!" : "hexadecimal data missing!");
1032  *pByte = b;
1033  }
1034  }
1035  }
#define b
#define sprintf
Definition: Standard.h:162
virtual void Raw(void *pData, size_t iSize, RawCompileType eType=RCT_Escaped)=0
virtual bool isVerbose()
Definition: StdCompiler.h:62
virtual void String(char *szString, size_t iMaxLength, RawCompileType eType=RCT_Escaped)=0
void excNotFound(const char *szMessage,...)
Definition: StdCompiler.h:233
virtual bool isDeserializer()
Definition: StdCompiler.h:53

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

Here is the call graph for this function:

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