antioch-0.4.0
List of all members | Public Member Functions | Private Member Functions | Private Attributes
tinyxml2::DynArray< T, INIT > Class Template Reference

#include <tinyxml2.h>

Public Member Functions

 DynArray ()
 
 ~DynArray ()
 
void Push (T t)
 
T * PushArr (int count)
 
Pop ()
 
void PopArr (int count)
 
bool Empty () const
 
T & operator[] (int i)
 
const T & operator[] (int i) const
 
int Size () const
 
int Capacity () const
 
const T * Mem () const
 
T * Mem ()
 

Private Member Functions

void EnsureCapacity (int cap)
 

Private Attributes

T * mem
 
pool [INIT]
 
int allocated
 
int size
 

Detailed Description

template<class T, int INIT>
class tinyxml2::DynArray< T, INIT >

Definition at line 174 of file tinyxml2.h.

Constructor & Destructor Documentation

template<class T, int INIT>
tinyxml2::DynArray< T, INIT >::DynArray ( )
inline

Definition at line 177 of file tinyxml2.h.

178  {
179  mem = pool;
180  allocated = INIT;
181  size = 0;
182  }
template<class T, int INIT>
tinyxml2::DynArray< T, INIT >::~DynArray ( )
inline

Definition at line 183 of file tinyxml2.h.

184  {
185  if ( mem != pool ) {
186  delete [] mem;
187  }
188  }

Member Function Documentation

template<class T, int INIT>
int tinyxml2::DynArray< T, INIT >::Capacity ( ) const
inline

Definition at line 215 of file tinyxml2.h.

215 { return allocated; }
template<class T, int INIT>
bool tinyxml2::DynArray< T, INIT >::Empty ( ) const
inline

Definition at line 211 of file tinyxml2.h.

211 { return size == 0; }
template<class T, int INIT>
void tinyxml2::DynArray< T, INIT >::EnsureCapacity ( int  cap)
inlineprivate

Definition at line 221 of file tinyxml2.h.

Referenced by tinyxml2::DynArray< char, 20 >::Push(), and tinyxml2::DynArray< char, 20 >::PushArr().

221  {
222  if ( cap > allocated ) {
223  int newAllocated = cap * 2;
224  T* newMem = new T[newAllocated];
225  memcpy( newMem, mem, sizeof(T)*size ); // warning: not using constructors, only works for PODs
226  if ( mem != pool ) delete [] mem;
227  mem = newMem;
228  allocated = newAllocated;
229  }
230  }
template<class T, int INIT>
const T* tinyxml2::DynArray< T, INIT >::Mem ( ) const
inline

Definition at line 216 of file tinyxml2.h.

Referenced by tinyxml2::XMLPrinter::CStr().

216 { return mem; }
template<class T, int INIT>
T* tinyxml2::DynArray< T, INIT >::Mem ( )
inline

Definition at line 217 of file tinyxml2.h.

217 { return mem; }
template<class T, int INIT>
T& tinyxml2::DynArray< T, INIT >::operator[] ( int  i)
inline

Definition at line 212 of file tinyxml2.h.

212 { TIXMLASSERT( i>= 0 && i < size ); return mem[i]; }
#define TIXMLASSERT(x)
Definition: tinyxml2.h:68
template<class T, int INIT>
const T& tinyxml2::DynArray< T, INIT >::operator[] ( int  i) const
inline

Definition at line 213 of file tinyxml2.h.

213 { TIXMLASSERT( i>= 0 && i < size ); return mem[i]; }
#define TIXMLASSERT(x)
Definition: tinyxml2.h:68
template<class T, int INIT>
T tinyxml2::DynArray< T, INIT >::Pop ( )
inline

Definition at line 202 of file tinyxml2.h.

Referenced by tinyxml2::XMLPrinter::CloseElement().

202  {
203  return mem[--size];
204  }
template<class T, int INIT>
void tinyxml2::DynArray< T, INIT >::PopArr ( int  count)
inline

Definition at line 205 of file tinyxml2.h.

206  {
207  TIXMLASSERT( size >= count );
208  size -= count;
209  }
#define TIXMLASSERT(x)
Definition: tinyxml2.h:68
template<class T, int INIT>
void tinyxml2::DynArray< T, INIT >::Push ( t)
inline

Definition at line 189 of file tinyxml2.h.

Referenced by tinyxml2::XMLPrinter::OpenElement(), and tinyxml2::XMLPrinter::XMLPrinter().

190  {
191  EnsureCapacity( size+1 );
192  mem[size++] = t;
193  }
void EnsureCapacity(int cap)
Definition: tinyxml2.h:221
template<class T, int INIT>
T* tinyxml2::DynArray< T, INIT >::PushArr ( int  count)
inline

Definition at line 195 of file tinyxml2.h.

Referenced by tinyxml2::XMLPrinter::Print().

196  {
197  EnsureCapacity( size+count );
198  T* ret = &mem[size];
199  size += count;
200  return ret;
201  }
void EnsureCapacity(int cap)
Definition: tinyxml2.h:221
template<class T, int INIT>
int tinyxml2::DynArray< T, INIT >::Size ( ) const
inline

Definition at line 214 of file tinyxml2.h.

Referenced by tinyxml2::XMLPrinter::CStrSize().

214 { return size; }

Member Data Documentation

template<class T, int INIT>
int tinyxml2::DynArray< T, INIT >::allocated
private
template<class T, int INIT>
T* tinyxml2::DynArray< T, INIT >::mem
private
template<class T, int INIT>
T tinyxml2::DynArray< T, INIT >::pool[INIT]
private
template<class T, int INIT>
int tinyxml2::DynArray< T, INIT >::size
private

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

Generated on Thu Jul 7 2016 11:09:52 for antioch-0.4.0 by  doxygen 1.8.8