Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Language
English











SourceForge.net Logo



Buffer

 

template <class T>

class Buffer : private Moveable< Buffer<T> > 

 

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);

 

 

Constructor Detail

 

Buffer()

Constructs an empty buffer.

 


 

Buffer(size_t size)

Constructs the Buffer with a size number of elements.

T must have default constructor.

 


 

Buffer(size_t size, const T& init)

Constructs the Buffer initializing the size elements to the specified value init.

T must have default constructor.

 


 

Buffer(pick_ Buffer& v)

Pick constructor. Destroys source container v.

 


 

~Buffer()

Default destructor.

 

 

Public Member List

 

void operator=(pick_ Buffer& v)

Pick operator. Source buffer v is destroyed.

 


 

operator T*()

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

 


 

operator const T*() const

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

 


 

T *operator~()

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

 


 

const T *operator~() const

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

 


 

void Alloc(size_t size)

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

T must have default constructor.

 


 

void Alloc(size_t size, const T& in)

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

T must have deep copy constructor.

 


 

void Clear()

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

 

 

Last edit by cxl on 02/18/2013. Do you want to contribute?. T++