OpenClonk
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros
StdArrayDefaultAdapt< T, D, M > Struct Template Reference

#include <StdAdaptors.h>

Public Member Functions

 StdArrayDefaultAdapt (T *pArray, size_t iSize, const D &rDefault, const M &map=M())
 
void CompileFunc (StdCompiler *pComp) const
 
bool operator== (const T *pDefaults) const
 
StdArrayDefaultAdaptoperator= (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 StdArrayDefaultAdapt< T, D, M >

Definition at line 317 of file StdAdaptors.h.

Constructor & Destructor Documentation

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

Definition at line 319 of file StdAdaptors.h.

Member Function Documentation

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

Definition at line 323 of file StdAdaptors.h.

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

324  {
325  size_t i, iWrite = iSize;
326  bool deserializing = pComp->isDeserializer();
327  // Decompiling: Omit defaults
328  if (!deserializing && pComp->hasNaming())
329  while (iWrite > 0 && pArray[iWrite - 1] == rDefault)
330  iWrite--;
331  // Read/write values
332  for (i = 0; i < iWrite; i++)
333  {
334  // Separator?
335  if (i) if (!pComp->Separator(StdCompiler::SEP_SEP)) break;
336  // Expect a value. Default if not found.
337  pComp->Value(mkDefaultAdapt(map(pArray[i]), rDefault));
338  }
339  // Fill rest of array
340  if (deserializing)
341  for (; i < iSize; i++)
342  pArray[i] = rDefault;
343  }
virtual bool Separator(Sep eSep=SEP_SEP)
Definition: StdCompiler.h:129
virtual bool hasNaming()
Definition: StdCompiler.h:68
void Value(const T &rStruct)
Definition: StdCompiler.h:170
virtual bool isDeserializer()
Definition: StdCompiler.h:63
StdDefaultAdapt< T, D > mkDefaultAdapt(T &&rValue, const D &rDefault)
Definition: StdAdaptors.h:65

Here is the call graph for this function:

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

Definition at line 352 of file StdAdaptors.h.

References StdArrayDefaultAdapt< T, D, M >::iSize.

353  {
354  for (size_t i = 0; i < iSize; i++)
355  pArray[i] = pDefaults[i];
356  return *this;
357  }
template<class T, class D, class M = _IdFuncClass<T>>
bool StdArrayDefaultAdapt< T, D, M >::operator== ( const T *  pDefaults) const
inline

Definition at line 345 of file StdAdaptors.h.

References StdArrayDefaultAdapt< T, D, M >::iSize.

346  {
347  for (size_t i = 0; i < iSize; i++)
348  if (pArray[i] != pDefaults[i])
349  return false;
350  return true;
351  }

Member Data Documentation

template<class T, class D, class M = _IdFuncClass<T>>
size_t StdArrayDefaultAdapt< T, D, M >::iSize
template<class T, class D, class M = _IdFuncClass<T>>
const M StdArrayDefaultAdapt< T, D, M >::map

Definition at line 322 of file StdAdaptors.h.

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

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

Definition at line 322 of file StdAdaptors.h.

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

Definition at line 322 of file StdAdaptors.h.


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