OpenClonk
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 651 of file StdAdaptors.h.

Constructor & Destructor Documentation

◆ StdSTLContainerAdapt()

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

Definition at line 653 of file StdAdaptors.h.

654  : rStruct(rStruct), eSep(eSep) { }
const StdCompiler::Sep eSep
Definition: StdAdaptors.h:655

Member Function Documentation

◆ CompileFunc()

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

Definition at line 656 of file StdAdaptors.h.

657  {
658  typedef typename C::value_type T;
659  // Get compiler specs
660  bool deserializing = pComp->isDeserializer();
661  bool fNaming = pComp->hasNaming();
662  // Decompiling?
663  if (!deserializing)
664  {
665  // Write size (binary only)
666  if (!fNaming)
667  {
668  int32_t iSize = rStruct.size();
669  pComp->Value(iSize);
670  }
671  // Write all entries
672  for (typename C::const_iterator i = rStruct.begin(); i != rStruct.end(); ++i)
673  {
674  if (i != rStruct.begin() && eSep) pComp->Separator(eSep);
675  pComp->Value(const_cast<T &>(*i));
676  }
677  }
678  else
679  {
680  // Compiling: Empty previous
681  rStruct.clear();
682  // Read size (binary only)
683  uint32_t iSize;
684  if (!fNaming) pComp->Value(iSize);
685  // Read new
686  do
687  {
688  // No entries left to read?
689  if (!fNaming && !iSize--)
690  break;
691  // Read entries
692  try
693  {
694  T val;
695  pComp->Value(val);
696  rStruct.push_back(val);
697  }
698  catch (StdCompiler::NotFoundException *pEx)
699  {
700  // No value found: Stop reading loop
701  delete pEx;
702  break;
703  }
704  }
705  while (!eSep || pComp->Separator(eSep));
706  }
707  }
int iSize
Definition: TstC4NetIO.cpp:32
virtual bool Separator(Sep eSep=SEP_SEP)
Definition: StdCompiler.h:119
void Value(const T &rStruct)
Definition: StdCompiler.h:161
virtual bool isDeserializer()
Definition: StdCompiler.h:53
virtual bool hasNaming()
Definition: StdCompiler.h:58

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

Here is the call graph for this function:

◆ operator=()

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

Definition at line 710 of file StdAdaptors.h.

710 { rStruct = nValue; return *this; }

References StdSTLContainerAdapt< C >::rStruct.

◆ operator==()

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

Definition at line 709 of file StdAdaptors.h.

709 { return rStruct == nValue; }

References StdSTLContainerAdapt< C >::rStruct.

Member Data Documentation

◆ eSep

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

Definition at line 655 of file StdAdaptors.h.

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

◆ rStruct


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