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

620  : rStruct(rStruct), eSep(eSep) { }
const StdCompiler::Sep eSep
Definition: StdAdaptors.h:621

Member Function Documentation

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

Definition at line 622 of file StdAdaptors.h.

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

623  {
624  typedef typename C::value_type T;
625  // Get compiler specs
626  bool deserializing = pComp->isDeserializer();
627  bool fNaming = pComp->hasNaming();
628  // Decompiling?
629  if (!deserializing)
630  {
631  // Write size (binary only)
632  if (!fNaming)
633  {
634  int32_t iSize = rStruct.size();
635  pComp->Value(iSize);
636  }
637  // Write all entries
638  for (typename C::const_iterator i = rStruct.begin(); i != rStruct.end(); ++i)
639  {
640  if (i != rStruct.begin() && eSep) pComp->Separator(eSep);
641  pComp->Value(const_cast<T &>(*i));
642  }
643  }
644  else
645  {
646  // Compiling: Empty previous
647  rStruct.clear();
648  // Read size (binary only)
649  uint32_t iSize;
650  if (!fNaming) pComp->Value(iSize);
651  // Read new
652  do
653  {
654  // No entries left to read?
655  if (!fNaming && !iSize--)
656  break;
657  // Read entries
658  try
659  {
660  T val;
661  pComp->Value(val);
662  rStruct.push_back(val);
663  }
664  catch (StdCompiler::NotFoundException *pEx)
665  {
666  // No value found: Stop reading loop
667  delete pEx;
668  break;
669  }
670  }
671  while (!eSep || pComp->Separator(eSep));
672  }
673  }
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
int iSize
Definition: TstC4NetIO.cpp:35
const StdCompiler::Sep eSep
Definition: StdAdaptors.h:621

Here is the call graph for this function:

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

Definition at line 676 of file StdAdaptors.h.

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

Definition at line 675 of file StdAdaptors.h.

675 { return rStruct == nValue; }

Member Data Documentation

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

Definition at line 621 of file StdAdaptors.h.

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

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

Definition at line 621 of file StdAdaptors.h.


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