24 #define toC4CStr(szString) mkStringAdaptMA(szString)
25 #define toC4CStrBuf(rBuf) mkParAdapt(rBuf, StdCompiler::RCT_All)
28 #define toC4CArr(rArr) mkArrayAdaptDM(rArr, 0)
29 #define toC4CArrU(rArr) mkArrayAdaptDM(rArr, 0u)
40 template <
class T,
class D>
49 #ifdef STDCOMPILER_EXCEPTION_WORKAROUND
50 if (!pComp->ValueSafe(
rValue))
63 template <
class T,
class D>
88 template <
class D>
inline bool operator == (
const D &nValue)
const {
return rValue == nValue; }
96 template <
class T,
class D>
128 template <
class T,
class D>
129 inline StdNamingDefaultAdapt<T,D> mkNamingAdapt(T &&rValue,
const char *szName,
const D &rDefault,
bool fPrefillDefault=
false,
bool fStoreDefault=
false) {
return StdNamingDefaultAdapt<T,D>(rValue, szName, rDefault, fPrefillDefault, fStoreDefault); }
145 template<
typename ... P>
204 inline bool operator == (
const char *szDefault)
const {
return string == szDefault; }
227 template <
typename T>
231 #if !defined(__GNUC__) || __GNUC__ > 4
232 static_assert(std::is_trivially_copyable<T>::value,
"StdRawAdapt: type must be trivially copyable");
239 template <
class T,
class int_t =
int32_t>
247 int_t iVal = int_t(
rValue);
260 template <
class T,
class to_t>
268 static_assert(
sizeof(to_t) ==
sizeof(T),
"CastAdapt sanity: sizes match");
269 static_assert(std::is_pod<to_t>::value,
"CastAdapt sanity: to-type is POD");
270 static_assert(std::is_pod<T>::value,
"CastAdapt sanity: from-type is POD");
272 std::memcpy(&vVal, &
rValue,
sizeof(to_t));
274 std::memcpy(&
rValue, &vVal,
sizeof(T));
292 template <
class T,
class M = _IdFuncClass<T> >
301 for (
int i = 0; i <
iSize; i++)
310 for (
int i = 0; i <
iSize; i++)
311 if (
pArray[i] != rDefault)
317 for (
int i = 0; i <
iSize; i++)
323 for (
int i = 0; i <
iSize; i++)
324 if (
pArray[i] != pDefaults[i])
330 for (
int i = 0; i <
iSize; i++)
337 template <
class T,
size_t size>
339 template <
class T,
class M>
341 template <
class T,
class M,
size_t size>
346 template <
class T,
class D,
class M = _IdFuncClass<T> >
355 size_t i, iWrite =
iSize;
358 if (!deserializing && pComp->
hasNaming())
362 for (i = 0; i < iWrite; i++)
371 for (; i <
iSize; i++)
377 for (
size_t i = 0; i <
iSize; i++)
378 if (
pArray[i] != pDefaults[i])
384 for (
size_t i = 0; i <
iSize; i++)
389 template <
class T,
class D>
391 template <
class T,
class D,
size_t size>
393 template <
class T,
class D,
class M>
394 inline StdArrayDefaultAdapt<T, D, M> mkArrayAdaptMap(T *pArray,
size_t iSize,
const D &rDefault, M map) {
return StdArrayDefaultAdapt<T, D, M>(pArray,
iSize, rDefault, map); }
395 template <
class T,
class D,
class M,
size_t size>
400 template <
class T,
class D,
class M = _IdFuncClass<T> >
409 size_t i, iWrite =
iSize;
412 if (!deserializing && pComp->
hasNaming())
416 for (i = 0; i < iWrite; i++)
425 for (; i <
iSize; i++)
431 for (
size_t i = 0; i <
iSize; i++)
432 if (
pArray[i] != pDefaults[i])
438 for (
size_t i = 0; i <
iSize; i++)
443 template <
class T,
class D>
445 template <
class T,
class D,
size_t size>
447 template <
class T,
class D,
class M>
448 inline StdArrayDefaultArrayAdapt<T, D, M> mkArrayAdaptDefArrMap(T *pArray,
size_t iSize,
const D &rDefault,
const M &map) {
return StdArrayDefaultArrayAdapt<T, D, M>(pArray,
iSize, rDefault, map); }
449 template <
class T,
class D,
class M,
size_t size>
454 template <
class T,
class I>
468 template <
class T,
class I>
473 template <
class T,
class P>
480 std::forward<T>(
rObj).CompileFunc(pComp, std::forward<P>(
Par));
483 template <
class D>
inline bool operator == (
const D &nValue)
const {
return rObj == nValue; }
489 template <
class T,
class P>
507 template <
class T,
class P1,
class P2>
515 std::forward<T>(
rObj).CompileFunc(pComp, std::forward<P1>(
rPar1), std::forward<P2>(
rPar2));
518 template <
class D>
inline bool operator == (
const D &nValue)
const {
return rObj == nValue; }
521 template <
class T,
class P1,
class P2>
554 template<
typename ... P>
561 template <
class T,
class ContextT>
583 template <
class T,
typename ... P>
589 if(deserializing) {
delete adapt.rpObj; adapt.rpObj =
nullptr; }
595 if(!deserializing && !adapt.rpObj)
return;
597 if(!pComp->
Name(adapt.szNaming)) { assert(deserializing); pComp->
NameEnd();
return; }
601 bool fNull = !! adapt.rpObj;
606 else if(!deserializing)
615 if(adapt.fAllowNull && fNaming) pComp->
NameEnd();
619 template <
class T,
typename ... P>
621 template <
class T,
class ContextT,
typename ... P>
626 template <
class T,
class ContextT>
628 template <
class T,
typename ... P>
630 template <
class T,
class ContextT,
typename ... P>
640 template <
class T,
class ContextT>
642 template <
class T,
class ContextT>
644 template <
class T,
class ContextT>
658 typedef typename C::value_type T;
672 for (
typename C::const_iterator i =
rStruct.begin(); i !=
rStruct.end(); ++i)
675 pComp->
Value(
const_cast<T &
>(*i));
689 if (!fNaming && !
iSize--)
734 const int CLEARBITS = 8 *
sizeof(T) - 7;
735 return (x << CLEARBITS) >> CLEARBITS;
758 tmp ^= 0x80; pComp->
Value(tmp);
772 int i = 7; T data = val;
773 while ( uint8_t(data) != tmp )
779 val = (data << i) | (val & ((1 << i) - 1));
787 template <
class D>
inline bool operator == (
const D &nValue)
const {
return rVal == nValue; }
802 template <
class T,
class int_t =
int32_t>
823 for (; pName->
Name; pName++)
839 #ifdef STDCOMPILER_EXCEPTION_WORKAROUND
841 if (!pComp->ValueSafe(val))
860 for (; pName->
Name; pName++)
861 if (Name == pName->
Name)
868 pComp->
Warn(
"Unknown bit name: %s", Name.
getData());
873 template <
class D>
inline bool operator == (
const D &nValue)
const {
return rVal == nValue; }
876 template <
class T,
class int_t>
878 template <
class int_t,
class T>
912 if ((pName->Val & val) == pName->Val)
915 if (orig_val && !pName->Val)
continue;
940 #ifdef STDCOMPILER_EXCEPTION_WORKAROUND
943 if (pComp->ValueSafe(tmp))
964 for (; pName->
Name; pName++)
965 if (Name == pName->
Name)
972 pComp->
Warn(
"Unknown bit name: %s", Name.
getData());
981 template <
class D>
inline bool operator == (
const D &nValue)
const {
return rVal == nValue; }
991 template <
class int_t>
1007 template <
class int_t>
1014 void *pData;
size_t iSize;
1022 for (
size_t i = 0; i <
iSize; i++)
1024 uint8_t *pByte =
reinterpret_cast<uint8_t *
>(pData) + i;
1025 if (!deserializing)
sprintf(szData,
"%02x", *pByte);
1030 if (sscanf(szData,
"%02x", &
b) != 1)
1031 pComp->
excNotFound(i ?
"hexadecimal data: bytes missing!" :
"hexadecimal data missing!");
void SCopy(const char *szSource, char *sTarget, size_t iMaxL)
bool SEqual(const char *szStr1, const char *szStr2)
StdStringAdapt mkStringAdaptM(char(&szString)[size])
StdStringAdapt mkStringAdaptMI(char(&szString)[size])
StdIntAdapt< T, int_t > mkIntAdaptT(T &rValue)
StdContextPtrAdapt< T, ContextT > mkNamingContextPtrAdapt(T *&rpObj, const ContextT &ctx, const char *szNaming)
StdInsertAdapt< T, I > mkInsertAdapt(T &&rObj, I &&rIns, bool fBefore=true)
StdArrayDefaultAdapt< T, D > mkArrayAdaptDM(T(&array)[size], const D &rDefault)
StdArrayDefaultArrayAdapt< T, D > mkArrayAdaptDMA(T(&array)[size], const D &rDefault)
StdPtrAdapt< T > mkPtrAdapt(T *&rpObj, bool fAllowNull=true)
StdArrayDefaultArrayAdapt< T, D, M > mkArrayAdaptDMAM(T(&array)[size], const D &rDefault, const M &map)
StdSTLContainerAdapt< C > mkSTLContainerAdapt(C &rTarget, StdCompiler::Sep eSep=StdCompiler::SEP_SEP)
StdStdStringAdapt mkStringAdaptA(std::string &string)
StdBitfieldAdapt< T > mkBitfieldAdapt(T &rVal, const StdBitfieldEntry< T > *pNames)
StdStringAdapt mkStringAdapt(char *szString, int iMaxLength, StdCompiler::RawCompileType eRawType=StdCompiler::RCT_Escaped)
StdArrayDefaultArrayAdapt< T, D > mkArrayAdaptDefArr(T *pArray, size_t iSize, const D &rDefault)
StdDefaultAdapt< T, D > mkDefaultAdapt(T &&rValue, const D &rDefault)
StdDecompileAdapt< T > mkDecompileAdapt(const T &rValue)
StdContextPtrAdapt< T, ContextT > mkContextPtrAdaptNoNull(T *&rpObj, const ContextT &ctx)
StdArrayAdapt< T, M > mkArrayAdaptMapM(T(&array)[size], M &&map)
StdArrayAdapt< T > mkArrayAdapt(T *pArray, int iSize)
StdPtrAdapt< T > mkPtrAdaptNoNull(T *&rpObj)
StdCastAdapt< T, to_t > mkCastAdapt(T &rValue)
StdRawAdapt mkRawAdaptM(T &val)
StdArrayAdapt< T, M > mkArrayAdaptMap(T *pArray, int iSize, M &&map)
StdParameterAdaptMaker< P > mkParAdaptMaker(P &&rPar)
StdRawAdapt mkRawAdapt(void *pData, size_t iSize, StdCompiler::RawCompileType eRawType=StdCompiler::RCT_Escaped)
StdEnumAdapt< T, int_t > mkEnumAdapt(T &rVal, const StdEnumEntry< T > *pNames)
void StdPtrAdaptDecompileNewFunc(const StdPtrAdapt< T > &adapt, StdCompiler *pComp)
StdContextPtrAdapt< T, ContextT > mkContextPtrAdapt(T *&rpObj, const ContextT &ctx, bool fAllowNull=true)
StdPtrAdapt< T > mkNamingPtrAdapt(T *&rpObj, const char *szNaming)
StdIntPackAdapt< T > mkIntPackAdapt(T &rVal)
StdEnumAdapt< T, int_t > mkEnumAdaptT(T &rVal, const StdEnumEntry< T > *pNames)
StdCastAdapt< T, int32_t > mkCastIntAdapt(T &rValue)
void StdPtrAdaptCompileNewFunc(const StdPtrAdapt< T > &adapt, StdCompiler *pComp, P &&...pars)
StdParameterAdapt< T, P > mkParAdapt(T &&rObj, P &&rPar)
StdStringAdapt mkStringAdaptMA(char(&szString)[size])
StdNamingCountAdapt< int_t > mkNamingCountAdapt(int_t &iCount, const char *szName)
StdIntAdapt< T > mkIntAdapt(T &rValue)
StdHexAdapt mkHexAdapt(void *pData, size_t iSize)
void StdPtrAdaptCompileFunc(StdCompiler *pComp, const T &adapt, P &&...pars)
StdArrayDefaultArrayAdapt< T, D, M > mkArrayAdaptDefArrMap(T *pArray, size_t iSize, const D &rDefault, const M &map)
StdArrayAdapt< T > mkArrayAdaptM(T(&array)[size])
StdRuntimeValueAdapt< T > mkRuntimeValueAdapt(T &&rValue)
StdNamingAdapt< T > mkNamingAdapt(T &&rValue, const char *szName)
StdArrayDefaultAdapt< T, D, M > mkArrayAdaptMapDM(T(&array)[size], const D &rDefault, M map)
StdStringAdapt mkStringAdaptMIE(char(&szString)[size])
void CompileNewFuncCtx(T *&pStruct, StdCompiler *pComp, const ContextT &rCtx)
void CompileNewFunc(T *&pStruct, StdCompiler *pComp)
virtual void Raw(void *pData, size_t iSize, RawCompileType eType=RCT_Escaped)=0
virtual bool Separator(Sep eSep=SEP_SEP)
virtual bool Default(const char *szName)
void Value(const T &rStruct)
virtual void NameEnd(bool fBreak=false)
virtual void String(char *szString, size_t iMaxLength, RawCompileType eType=RCT_Escaped)=0
void excNotFound(const char *szMessage,...)
void Warn(const char *szWarning,...)
virtual bool isDeserializer()
virtual int NameCount(const char *szName=nullptr)
virtual void setRuntimeWritesAllowed(int32_t iChange)
virtual bool Name(const char *szName)
StdHexAdapt(void *pData, size_t iSize)
void CompileFunc(StdCompiler *pComp) const
const char * getData() const
T & operator()(T &rValue) const
bool operator==(const T &rDefault) const
StdArrayAdapt & operator=(const T &rDefault)
void CompileFunc(StdCompiler *pComp) const
StdArrayAdapt(T *pArray, int iSize, M &&map=M())
StdArrayDefaultAdapt(T *pArray, size_t iSize, const D &rDefault, const M &map=M())
bool operator==(const T *pDefaults) const
StdArrayDefaultAdapt & operator=(const T *pDefaults)
void CompileFunc(StdCompiler *pComp) const
bool operator==(const T *pDefaults) const
void CompileFunc(StdCompiler *pComp) const
StdArrayDefaultArrayAdapt & operator=(const T *pDefaults)
StdArrayDefaultArrayAdapt(T *pArray, size_t iSize, const D &rDefault, const M &map=M())
StdBasicPtrAdapt(T *&rpObj, bool fAllowNull=true, const char *szNaming="Data")
StdBasicPtrAdapt & operator=(const T &nValue)
bool operator==(const T &nValue) const
StdBitfieldAdapt(T &rVal, const Entry *pNames)
void CompileFunc(StdCompiler *pComp) const
StdBitfieldEntry< T > Entry
bool operator==(const D &nValue) const
StdCastAdapt & operator=(const D &nValue)
void CompileFunc(StdCompiler *pComp) const
StdContextPtrAdapt(T *&rpObj, const ContextT &rCtx, bool fAllowNull=true, const char *szNaming="Data")
void CompileFunc(StdCompiler *pComp) const
void CompileFunc(StdCompiler *pComp, const P &p)
StdDecompileAdapt(const T &rValue)
void CompileFunc(StdCompiler *pComp, P &&... pars) const
void CompileFunc(StdCompiler *pComp) const
void CompileFunc(StdCompiler *pComp) const
StdDefaultAdapt(T &rValue, const D &rDefault)
void CompileFunc(StdCompiler *pComp) const
StdEnumAdapt(T &rVal, const Entry *pNames)
bool operator==(const D &nValue) const
StdEnumAdapt< T, int_t > & operator=(const D &nValue)
void CompileFunc(StdCompiler *pComp) const
StdInsertAdapt(T &rObj, I &rIns, bool fBefore=true)
void CompileFunc(StdCompiler *pComp) const
StdIntAdapt & operator=(const D &nValue)
bool operator==(const D &nValue) const
bool operator==(const D &nValue) const
StdIntPackAdapt & operator=(const D &nValue)
void CompileFunc(StdCompiler *pComp) const
void CompileFunc(StdCompiler *pComp) const
bool operator==(const D &nValue) const
StdNamingAdapt & operator=(const D &nValue)
StdNamingAdapt(T &rValue, const char *szName)
void CompileFunc(StdCompiler *pComp) const
StdNamingCountAdapt(int_t &iCount, const char *szName)
void CompileFunc(StdCompiler *pComp) const
StdNamingDefaultAdapt(T &rValue, const char *szName, const D &rDefault, bool fPrefillDefault, bool fStoreDefault)
void CompileFunc(StdCompiler *pComp) const
StdParameter2Adapt(T &&rObj, P1 &&rPar1, P2 &&rPar2)
StdParameter2Adapt & operator=(const D &nValue)
bool operator==(const D &nValue) const
void CompileFunc(StdCompiler *pComp) const
StdParameterAdapt & operator=(const D &nValue)
void CompileFunc(StdCompiler *pComp) const
StdParameterAdapt(T &&rObj, P &&rPar)
bool operator==(const D &nValue) const
StdParameterAdaptMaker(P &&rPar)
StdParameterAdapt< T, P > operator()(T &&rObj) const
void CompileFunc(StdCompiler *pComp, P &&...pars)
StdPtrAdapt(T *&rpObj, bool fAllowNull=true, const char *szNaming="Data")
void CompileFunc(StdCompiler *pComp) const
bool operator==(const void *pDefault) const
void CompileFunc(StdCompiler *pComp) const
StdRawAdapt & operator=(const void *pDefault)
StdCompiler::RawCompileType eRawType
StdRawAdapt(void *pData, size_t iSize, StdCompiler::RawCompileType eRawType=StdCompiler::RCT_Escaped)
bool operator==(const D &nValue) const
StdRuntimeValueAdapt< T > & operator=(const D &nValue)
StdRuntimeValueAdapt(T &rValue)
void CompileFunc(StdCompiler *pComp) const
const StdCompiler::Sep eSep
StdSTLContainerAdapt(C &rStruct, StdCompiler::Sep eSep=StdCompiler::SEP_SEP)
void CompileFunc(StdCompiler *pComp) const
bool operator==(const C &nValue) const
StdSTLContainerAdapt & operator=(const C &nValue)
StdStdStringAdapt & operator=(const char *szDefault)
bool operator==(const char *szDefault) const
void CompileFunc(StdCompiler *pComp) const
StdCompiler::RawCompileType eRawType
StdStdStringAdapt(std::string &string, StdCompiler::RawCompileType eRawType=StdCompiler::RCT_Escaped)
bool operator==(const char *szDefault) const
StdCompiler::RawCompileType eRawType
StdStringAdapt & operator=(const char *szDefault)
void CompileFunc(StdCompiler *pComp) const
StdStringAdapt(char *szString, int iMaxLength, StdCompiler::RawCompileType eRawType=StdCompiler::RCT_Escaped)