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 319 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 321 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 325 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().

326  {
327  size_t i, iWrite = iSize;
328  bool deserializing = pComp->isDeserializer();
329  // Decompiling: Omit defaults
330  if (!deserializing && pComp->hasNaming())
331  while (iWrite > 0 && pArray[iWrite - 1] == rDefault)
332  iWrite--;
333  // Read/write values
334  for (i = 0; i < iWrite; i++)
335  {
336  // Separator?
337  if (i) if (!pComp->Separator(StdCompiler::SEP_SEP)) break;
338  // Expect a value. Default if not found.
339  pComp->Value(mkDefaultAdapt(map(pArray[i]), rDefault));
340  }
341  // Fill rest of array
342  if (deserializing)
343  for (; i < iSize; i++)
344  pArray[i] = rDefault;
345  }
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:

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

Definition at line 354 of file StdAdaptors.h.

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

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

Definition at line 347 of file StdAdaptors.h.

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

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

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

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

Definition at line 324 of file StdAdaptors.h.


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