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

408  {
409  size_t i, iWrite = iSize;
410  bool deserializing = pComp->isDeserializer();
411  // Decompiling: Omit defaults
412  if (!deserializing && pComp->hasNaming())
413  while (iWrite > 0 && pArray[iWrite - 1] == rDefault[iWrite - 1])
414  iWrite--;
415  // Read/write values
416  for (i = 0; i < iWrite; i++)
417  {
418  // Separator?
419  if (i) if (!pComp->Separator(StdCompiler::SEP_SEP)) break;
420  // Expect a value. Default if not found.
421  pComp->Value(mkDefaultAdapt(map(pArray[i]), rDefault[i]));
422  }
423  // Fill rest of array
424  if (deserializing)
425  for (; i < iSize; i++)
426  pArray[i] = rDefault[i];
427  }
StdDefaultAdapt< T, D > mkDefaultAdapt(T &&rValue, const D &rDefault)
Definition: StdAdaptors.h:64
virtual bool Separator(Sep eSep=SEP_SEP)
Definition: StdCompiler.h:119
void Value(const T &rStruct)
Definition: StdCompiler.h:161
virtual bool isDeserializer()
Definition: StdCompiler.h:53
virtual bool hasNaming()
Definition: StdCompiler.h:58

References StdCompiler::hasNaming(), StdCompiler::isDeserializer(), StdArrayDefaultArrayAdapt< T, D, M >::iSize, StdArrayDefaultArrayAdapt< T, D, M >::map, mkDefaultAdapt(), StdArrayDefaultArrayAdapt< T, D, M >::pArray, StdArrayDefaultArrayAdapt< T, D, M >::rDefault, StdCompiler::SEP_SEP, StdCompiler::Separator(), and StdCompiler::Value().

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

437  {
438  for (size_t i = 0; i < iSize; i++)
439  pArray[i] = pDefaults[i];
440  return *this;
441  }

References StdArrayDefaultArrayAdapt< T, D, M >::iSize, and StdArrayDefaultArrayAdapt< T, D, M >::pArray.

◆ operator==()

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

Definition at line 429 of file StdAdaptors.h.

430  {
431  for (size_t i = 0; i < iSize; i++)
432  if (pArray[i] != pDefaults[i])
433  return false;
434  return true;
435  }

References StdArrayDefaultArrayAdapt< T, D, M >::iSize, and StdArrayDefaultArrayAdapt< T, D, M >::pArray.

Member Data Documentation

◆ iSize

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

◆ map

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

Definition at line 406 of file StdAdaptors.h.

Referenced by StdArrayDefaultArrayAdapt< T, D, M >::CompileFunc().

◆ pArray

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

◆ rDefault

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

Definition at line 406 of file StdAdaptors.h.

Referenced by StdArrayDefaultArrayAdapt< T, D, M >::CompileFunc().


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