OpenClonk
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros
StdSTLContainerAdapt< C > Struct Template Reference

#include <StdAdaptors.h>

Public Member Functions

 StdSTLContainerAdapt (C &rStruct, StdCompiler::Sep eSep=StdCompiler::SEP_SEP)
 
void CompileFunc (StdCompiler *pComp) const
 
bool operator== (const C &nValue) const
 
StdSTLContainerAdaptoperator= (const C &nValue)
 

Public Attributes

C & rStruct
 
const StdCompiler::Sep eSep
 

Detailed Description

template<class C>
struct StdSTLContainerAdapt< C >

Definition at line 637 of file StdAdaptors.h.

Constructor & Destructor Documentation

template<class C>
StdSTLContainerAdapt< C >::StdSTLContainerAdapt ( C &  rStruct,
StdCompiler::Sep  eSep = StdCompiler::SEP_SEP 
)
inline

Definition at line 639 of file StdAdaptors.h.

640  : rStruct(rStruct), eSep(eSep) { }
const StdCompiler::Sep eSep
Definition: StdAdaptors.h:641

Member Function Documentation

template<class C>
void StdSTLContainerAdapt< C >::CompileFunc ( StdCompiler pComp) const
inline

Definition at line 642 of file StdAdaptors.h.

References StdSTLContainerAdapt< C >::eSep, StdCompiler::hasNaming(), StdCompiler::isDeserializer(), iSize, StdCompiler::Separator(), and StdCompiler::Value().

643  {
644  typedef typename C::value_type T;
645  // Get compiler specs
646  bool deserializing = pComp->isDeserializer();
647  bool fNaming = pComp->hasNaming();
648  // Decompiling?
649  if (!deserializing)
650  {
651  // Write size (binary only)
652  if (!fNaming)
653  {
654  int32_t iSize = rStruct.size();
655  pComp->Value(iSize);
656  }
657  // Write all entries
658  for (typename C::const_iterator i = rStruct.begin(); i != rStruct.end(); ++i)
659  {
660  if (i != rStruct.begin() && eSep) pComp->Separator(eSep);
661  pComp->Value(const_cast<T &>(*i));
662  }
663  }
664  else
665  {
666  // Compiling: Empty previous
667  rStruct.clear();
668  // Read size (binary only)
669  uint32_t iSize;
670  if (!fNaming) pComp->Value(iSize);
671  // Read new
672  do
673  {
674  // No entries left to read?
675  if (!fNaming && !iSize--)
676  break;
677  // Read entries
678  try
679  {
680  T val;
681  pComp->Value(val);
682  rStruct.push_back(val);
683  }
684  catch (StdCompiler::NotFoundException *pEx)
685  {
686  // No value found: Stop reading loop
687  delete pEx;
688  break;
689  }
690  }
691  while (!eSep || pComp->Separator(eSep));
692  }
693  }
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
int iSize
Definition: TstC4NetIO.cpp:32
const StdCompiler::Sep eSep
Definition: StdAdaptors.h:641

Here is the call graph for this function:

template<class C>
StdSTLContainerAdapt& StdSTLContainerAdapt< C >::operator= ( const C &  nValue)
inline

Definition at line 696 of file StdAdaptors.h.

696 { rStruct = nValue; return *this; }
template<class C>
bool StdSTLContainerAdapt< C >::operator== ( const C &  nValue) const
inline

Definition at line 695 of file StdAdaptors.h.

695 { return rStruct == nValue; }

Member Data Documentation

template<class C>
const StdCompiler::Sep StdSTLContainerAdapt< C >::eSep

Definition at line 641 of file StdAdaptors.h.

Referenced by StdSTLContainerAdapt< C >::CompileFunc().

template<class C>
C& StdSTLContainerAdapt< C >::rStruct

Definition at line 641 of file StdAdaptors.h.


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