Overview
Examples
Screenshots
Comparisons
Applications
Download
Manual
Status & Roadmap
FAQ
Authors & License
Forums
Wiki
Funding Ultimate++
Search on this site











SourceForge.net Logo



Buffer

template <class T>  class Buffer : private Moveable< Buffer<T> > 

class Buffer

 

T    Type of elements stored in Buffer.

 

Buffer is a simple class used to manage a fixed size plain old C dynamically allocated vector of elements of a specified type. The size of the buffer is specified as a constructor parameter and it can be also reallocated with new size, while loosing all current data.

Buffer is a moveable type with pick (only) transfer semantics. Calling methods of picked Buffer is logic error with the exceptions of

void Alloc(int size);

void Alloc(int size, const T& in);

void Clear();

void operator=(pick_ Buffer& v);

 

Derived from Moveable< Buffer<T> >

 

Buffer()

Constructs an empty buffer.

 

Buffer(int size)

Constructs the Buffer.

T must have default constructor.

size

Number of elements.

 

Buffer(int size, const T& init)

Constructs the Buffer initializing the elements to the specified value.

T must have deep copy constructor.

size

Number of elements.

init

Initialization value.

 

Buffer(pick_ Bufferv)

Pick constructor.

v

Source Buffer.

 

void operator=(pick_ Buffer& v)

Pick operator.

v

Source buffer to be picked.

 

operator T*()

Return value

Returns a pointer to the first element of the Buffer or NULL if the Buffer is empty.

 

operator const T*() const

Return value

Returns a pointer to the first element of the Buffer or NULL if the Buffer is empty.

 

T *operator~()

Return value

Returns a pointer to the first element of the Buffer or NULL if the Buffer is empty.

 

const T *operator~() const

Return value

Returns a pointer to the first element of the Buffer or NULL if the Buffer is empty.

 

void Alloc(int size)

Clears the buffer and allocates it with the new size. All current elements are lost.

T must have default constructor.

size

Number of elements.

 

void Alloc(int size, const T& in)

Clears the buffer and allocates it with the new size, using the initialization value. All current elements are lost.

T must have deep copy constructor.

size

Number of elements.

in

Initialization value.

 

void Clear()

Clears the buffer to the same state as default constructor. All current elements are destroyed.