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

623  : rStruct(rStruct), eSep(eSep) { }
const StdCompiler::Sep eSep
Definition: StdAdaptors.h:624

Member Function Documentation

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

Definition at line 625 of file StdAdaptors.h.

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

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

Here is the call graph for this function:

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

Definition at line 679 of file StdAdaptors.h.

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

Definition at line 678 of file StdAdaptors.h.

678 { return rStruct == nValue; }

Member Data Documentation

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

Definition at line 624 of file StdAdaptors.h.

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

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

Definition at line 624 of file StdAdaptors.h.


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