ReactOS  0.4.12-dev-51-ge94618b
tinyxml2::DynArray< T, INITIAL_SIZE > Class Template Reference

#include <tinyxml2.h>

Collaboration diagram for tinyxml2::DynArray< T, INITIAL_SIZE >:

Public Member Functions

 DynArray ()
 
 ~DynArray ()
 
void Clear ()
 
void Push (T t)
 
TPushArr (int count)
 
T Pop ()
 
void PopArr (int count)
 
bool Empty () const
 
Toperator[] (int i)
 
const Toperator[] (int i) const
 
const TPeekTop () const
 
int Size () const
 
int Capacity () const
 
const TMem () const
 
TMem ()
 

Private Member Functions

 DynArray (const DynArray &)
 
void operator= (const DynArray &)
 
void EnsureCapacity (int cap)
 

Private Attributes

T_mem
 
T _pool [INITIAL_SIZE]
 
int _allocated
 
int _size
 

Detailed Description

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

Definition at line 184 of file tinyxml2.h.

Constructor & Destructor Documentation

◆ DynArray() [1/2]

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

Definition at line 187 of file tinyxml2.h.

187  {
188  _mem = _pool;
189  _allocated = INITIAL_SIZE;
190  _size = 0;
191  }
T _pool[INITIAL_SIZE]
Definition: tinyxml2.h:287

◆ ~DynArray()

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

Definition at line 193 of file tinyxml2.h.

193  {
194  if ( _mem != _pool ) {
195  delete [] _mem;
196  }
197  }
T _pool[INITIAL_SIZE]
Definition: tinyxml2.h:287

◆ DynArray() [2/2]

template<class T, int INITIAL_SIZE>
tinyxml2::DynArray< T, INITIAL_SIZE >::DynArray ( const DynArray< T, INITIAL_SIZE > &  )
private

Member Function Documentation

◆ Capacity()

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

Definition at line 252 of file tinyxml2.h.

252  {
253  TIXMLASSERT( _allocated >= INITIAL_SIZE );
254  return _allocated;
255  }
#define TIXMLASSERT(x)
Definition: tinyxml2.h:88

◆ Clear()

template<class T, int INITIAL_SIZE>
void tinyxml2::DynArray< T, INITIAL_SIZE >::Clear ( )
inline

Definition at line 199 of file tinyxml2.h.

199  {
200  _size = 0;
201  }

◆ Empty()

template<class T, int INITIAL_SIZE>
bool tinyxml2::DynArray< T, INITIAL_SIZE >::Empty ( ) const
inline

Definition at line 228 of file tinyxml2.h.

228  {
229  return _size == 0;
230  }

◆ EnsureCapacity()

template<class T, int INITIAL_SIZE>
void tinyxml2::DynArray< T, INITIAL_SIZE >::EnsureCapacity ( int  cap)
inlineprivate

Definition at line 271 of file tinyxml2.h.

271  {
272  TIXMLASSERT( cap > 0 );
273  if ( cap > _allocated ) {
274  TIXMLASSERT( cap <= INT_MAX / 2 );
275  int newAllocated = cap * 2;
276  T* newMem = new T[newAllocated];
277  memcpy( newMem, _mem, sizeof(T)*_size ); // warning: not using constructors, only works for PODs
278  if ( _mem != _pool ) {
279  delete [] _mem;
280  }
281  _mem = newMem;
282  _allocated = newAllocated;
283  }
284  }
#define INT_MAX
Definition: limits.h:40
T _pool[INITIAL_SIZE]
Definition: tinyxml2.h:287
#define T
Definition: mbstring.h:31
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
#define TIXMLASSERT(x)
Definition: tinyxml2.h:88

◆ Mem() [1/2]

template<class T, int INITIAL_SIZE>
const T* tinyxml2::DynArray< T, INITIAL_SIZE >::Mem ( ) const
inline

Definition at line 257 of file tinyxml2.h.

257  {
258  TIXMLASSERT( _mem );
259  return _mem;
260  }
#define TIXMLASSERT(x)
Definition: tinyxml2.h:88

◆ Mem() [2/2]

template<class T, int INITIAL_SIZE>
T* tinyxml2::DynArray< T, INITIAL_SIZE >::Mem ( )
inline

Definition at line 262 of file tinyxml2.h.

262  {
263  TIXMLASSERT( _mem );
264  return _mem;
265  }
#define TIXMLASSERT(x)
Definition: tinyxml2.h:88

◆ operator=()

template<class T, int INITIAL_SIZE>
void tinyxml2::DynArray< T, INITIAL_SIZE >::operator= ( const DynArray< T, INITIAL_SIZE > &  )
private

◆ operator[]() [1/2]

template<class T, int INITIAL_SIZE>
T& tinyxml2::DynArray< T, INITIAL_SIZE >::operator[] ( int  i)
inline

Definition at line 232 of file tinyxml2.h.

232  {
233  TIXMLASSERT( i>= 0 && i < _size );
234  return _mem[i];
235  }
GLenum GLclampf GLint i
Definition: glfuncs.h:14
#define TIXMLASSERT(x)
Definition: tinyxml2.h:88

◆ operator[]() [2/2]

template<class T, int INITIAL_SIZE>
const T& tinyxml2::DynArray< T, INITIAL_SIZE >::operator[] ( int  i) const
inline

Definition at line 237 of file tinyxml2.h.

237  {
238  TIXMLASSERT( i>= 0 && i < _size );
239  return _mem[i];
240  }
GLenum GLclampf GLint i
Definition: glfuncs.h:14
#define TIXMLASSERT(x)
Definition: tinyxml2.h:88

◆ PeekTop()

template<class T, int INITIAL_SIZE>
const T& tinyxml2::DynArray< T, INITIAL_SIZE >::PeekTop ( ) const
inline

Definition at line 242 of file tinyxml2.h.

242  {
243  TIXMLASSERT( _size > 0 );
244  return _mem[ _size - 1];
245  }
#define TIXMLASSERT(x)
Definition: tinyxml2.h:88

◆ Pop()

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

Definition at line 218 of file tinyxml2.h.

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

218  {
219  TIXMLASSERT( _size > 0 );
220  return _mem[--_size];
221  }
#define TIXMLASSERT(x)
Definition: tinyxml2.h:88

◆ PopArr()

template<class T, int INITIAL_SIZE>
void tinyxml2::DynArray< T, INITIAL_SIZE >::PopArr ( int  count)
inline

Definition at line 223 of file tinyxml2.h.

223  {
224  TIXMLASSERT( _size >= count );
225  _size -= count;
226  }
GLuint GLuint GLsizei count
Definition: gl.h:1545
#define TIXMLASSERT(x)
Definition: tinyxml2.h:88

◆ Push()

template<class T, int INITIAL_SIZE>
void tinyxml2::DynArray< T, INITIAL_SIZE >::Push ( T  t)
inline

Definition at line 203 of file tinyxml2.h.

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

203  {
205  EnsureCapacity( _size+1 );
206  _mem[_size++] = t;
207  }
#define INT_MAX
Definition: limits.h:40
GLdouble GLdouble t
Definition: gl.h:2047
void EnsureCapacity(int cap)
Definition: tinyxml2.h:271
#define TIXMLASSERT(x)
Definition: tinyxml2.h:88

◆ PushArr()

template<class T, int INITIAL_SIZE>
T* tinyxml2::DynArray< T, INITIAL_SIZE >::PushArr ( int  count)
inline

Definition at line 209 of file tinyxml2.h.

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

209  {
210  TIXMLASSERT( count >= 0 );
211  TIXMLASSERT( _size <= INT_MAX - count );
213  T* ret = &_mem[_size];
214  _size += count;
215  return ret;
216  }
#define INT_MAX
Definition: limits.h:40
GLuint GLuint GLsizei count
Definition: gl.h:1545
#define T
Definition: mbstring.h:31
void EnsureCapacity(int cap)
Definition: tinyxml2.h:271
int ret
#define TIXMLASSERT(x)
Definition: tinyxml2.h:88

◆ Size()

template<class T, int INITIAL_SIZE>
int tinyxml2::DynArray< T, INITIAL_SIZE >::Size ( ) const
inline

Definition at line 247 of file tinyxml2.h.

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

247  {
248  TIXMLASSERT( _size >= 0 );
249  return _size;
250  }
#define TIXMLASSERT(x)
Definition: tinyxml2.h:88

Member Data Documentation

◆ _allocated

template<class T, int INITIAL_SIZE>
int tinyxml2::DynArray< T, INITIAL_SIZE >::_allocated
private

Definition at line 288 of file tinyxml2.h.

◆ _mem

template<class T, int INITIAL_SIZE>
T* tinyxml2::DynArray< T, INITIAL_SIZE >::_mem
private

Definition at line 286 of file tinyxml2.h.

◆ _pool

template<class T, int INITIAL_SIZE>
T tinyxml2::DynArray< T, INITIAL_SIZE >::_pool[INITIAL_SIZE]
private

Definition at line 287 of file tinyxml2.h.

◆ _size

template<class T, int INITIAL_SIZE>
int tinyxml2::DynArray< T, INITIAL_SIZE >::_size
private

Definition at line 289 of file tinyxml2.h.


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