OpenClonk
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros
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 372 of file StdAdaptors.h.

Constructor & Destructor Documentation

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

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

Definition at line 378 of file StdAdaptors.h.

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

379  {
380  size_t i, iWrite = iSize;
381  bool deserializing = pComp->isDeserializer();
382  // Decompiling: Omit defaults
383  if (!deserializing && pComp->hasNaming())
384  while (iWrite > 0 && pArray[iWrite - 1] == rDefault[iWrite - 1])
385  iWrite--;
386  // Read/write values
387  for (i = 0; i < iWrite; i++)
388  {
389  // Separator?
390  if (i) if (!pComp->Separator(StdCompiler::SEP_SEP)) break;
391  // Expect a value. Default if not found.
392  pComp->Value(mkDefaultAdapt(map(pArray[i]), rDefault[i]));
393  }
394  // Fill rest of array
395  if (deserializing)
396  for (; i < iSize; i++)
397  pArray[i] = rDefault[i];
398  }
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:171
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>>
StdArrayDefaultArrayAdapt& StdArrayDefaultArrayAdapt< T, D, M >::operator= ( const T *  pDefaults)
inline

Definition at line 407 of file StdAdaptors.h.

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

408  {
409  for (size_t i = 0; i < iSize; i++)
410  pArray[i] = pDefaults[i];
411  return *this;
412  }
template<class T, class D, class M = _IdFuncClass<T>>
bool StdArrayDefaultArrayAdapt< T, D, M >::operator== ( const T *  pDefaults) const
inline

Definition at line 400 of file StdAdaptors.h.

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

401  {
402  for (size_t i = 0; i < iSize; i++)
403  if (pArray[i] != pDefaults[i])
404  return false;
405  return true;
406  }

Member Data Documentation

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

Definition at line 377 of file StdAdaptors.h.

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

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

Definition at line 377 of file StdAdaptors.h.

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

Definition at line 377 of file StdAdaptors.h.


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