OpenClonk
StdArrayDefaultArrayAdapt< T, D, M > Struct Template Reference

#include <StdAdaptors.h>

Public Member Functions

 StdArrayDefaultArrayAdapt (T *pArray, size_t iSize, const D &rDefault, const M &map=M())
 
void CompileFunc (StdCompiler *pComp) const
 
bool operator== (const T *pDefaults) const
 
StdArrayDefaultArrayAdaptoperator= (const T *pDefaults)
 

Public Attributes

T * pArray
 
size_t iSize
 
const D & rDefault
 
const M map
 

Detailed Description

template<class T, class D, class M = _IdFuncClass<T>>
struct StdArrayDefaultArrayAdapt< T, D, M >

Definition at line 389 of file StdAdaptors.h.

Constructor & Destructor Documentation

◆ StdArrayDefaultArrayAdapt()

template<class T, class D, class M = _IdFuncClass<T>>
StdArrayDefaultArrayAdapt< T, D, M >::StdArrayDefaultArrayAdapt ( T *  pArray,
size_t  iSize,
const D &  rDefault,
const M &  map = M() 
)
inline

Member Function Documentation

◆ CompileFunc()

template<class T, class D, class M = _IdFuncClass<T>>
void StdArrayDefaultArrayAdapt< T, D, M >::CompileFunc ( StdCompiler pComp) const
inline

Definition at line 395 of file StdAdaptors.h.

References StdCompiler::hasNaming(), StdCompiler::isDeserializer(), iSize, mkDefaultAdapt(), StdCompiler::SEP_SEP, StdCompiler::Separator(), and StdCompiler::Value().

396  {
397  size_t i, iWrite = iSize;
398  bool deserializing = pComp->isDeserializer();
399  // Decompiling: Omit defaults
400  if (!deserializing && pComp->hasNaming())
401  while (iWrite > 0 && pArray[iWrite - 1] == rDefault[iWrite - 1])
402  iWrite--;
403  // Read/write values
404  for (i = 0; i < iWrite; i++)
405  {
406  // Separator?
407  if (i) if (!pComp->Separator(StdCompiler::SEP_SEP)) break;
408  // Expect a value. Default if not found.
409  pComp->Value(mkDefaultAdapt(map(pArray[i]), rDefault[i]));
410  }
411  // Fill rest of array
412  if (deserializing)
413  for (; i < iSize; i++)
414  pArray[i] = rDefault[i];
415  }
virtual bool Separator(Sep eSep=SEP_SEP)
Definition: StdCompiler.h:119
virtual bool hasNaming()
Definition: StdCompiler.h:58
void Value(const T &rStruct)
Definition: StdCompiler.h:161
virtual bool isDeserializer()
Definition: StdCompiler.h:53
StdDefaultAdapt< T, D > mkDefaultAdapt(T &&rValue, const D &rDefault)
Definition: StdAdaptors.h:64
Here is the call graph for this function:

◆ operator=()

template<class T, class D, class M = _IdFuncClass<T>>
StdArrayDefaultArrayAdapt& StdArrayDefaultArrayAdapt< T, D, M >::operator= ( const T *  pDefaults)
inline

Definition at line 424 of file StdAdaptors.h.

References iSize.

425  {
426  for (size_t i = 0; i < iSize; i++)
427  pArray[i] = pDefaults[i];
428  return *this;
429  }

◆ operator==()

template<class T, class D, class M = _IdFuncClass<T>>
bool StdArrayDefaultArrayAdapt< T, D, M >::operator== ( const T *  pDefaults) const
inline

Definition at line 417 of file StdAdaptors.h.

References iSize.

418  {
419  for (size_t i = 0; i < iSize; i++)
420  if (pArray[i] != pDefaults[i])
421  return false;
422  return true;
423  }

Member Data Documentation

◆ iSize

template<class T, class D, class M = _IdFuncClass<T>>
size_t StdArrayDefaultArrayAdapt< T, D, M >::iSize

Definition at line 394 of file StdAdaptors.h.

◆ map

template<class T, class D, class M = _IdFuncClass<T>>
const M StdArrayDefaultArrayAdapt< T, D, M >::map

Definition at line 394 of file StdAdaptors.h.

◆ pArray

template<class T, class D, class M = _IdFuncClass<T>>
T* StdArrayDefaultArrayAdapt< T, D, M >::pArray

Definition at line 394 of file StdAdaptors.h.

◆ rDefault

template<class T, class D, class M = _IdFuncClass<T>>
const D& StdArrayDefaultArrayAdapt< T, D, M >::rDefault

Definition at line 394 of file StdAdaptors.h.


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