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

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

Member Function Documentation

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

Definition at line 624 of file StdAdaptors.h.

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

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

Here is the call graph for this function:

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

Definition at line 678 of file StdAdaptors.h.

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

Definition at line 677 of file StdAdaptors.h.

677 { return rStruct == nValue; }

Member Data Documentation

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

Definition at line 623 of file StdAdaptors.h.

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

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

Definition at line 623 of file StdAdaptors.h.


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