|
OpenTop 1.3 | |||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | Cross-Platform C++ | ||||
SUMMARY: CONSTRUCTOR | METHOD | DETAIL: CONSTRUCTOR | METHOD |
#include "ot/base/AutoBuffer.h"
An efficient buffer that will automatically grow to hold the required data.
AutoBuffer is often used internally within OpenTop when building String objects.In the following example an AutoBuffer is created to hold a string containing all the Unicode characters from U+0000 - U+1000.
AutoBuffer<CharType> charBuffer; for(UCS4Char cp=0; cp<0x1000; ++cp) { // convert the Unicode code-point into a Character Character ch(cp); // append the CharType sequence from ch onto our buffer charBuffer.append(ch.data(), ch.length()); }
Constructor/Destructor Summary | |
AutoBuffer() Default constructor which creates an internal buffer with a default initial size. | |
AutoBuffer(size_t initialSize) Default constructor which creates an internal buffer with an initial size of initialSize. | |
~AutoBuffer() Destructor. |
Method Summary | |
void |
append(T data) Appends a single element of type T to the internal buffer. |
void |
append(const T* pData, size_t length) Appends an array of elements of type T to the internal buffer. |
size_t |
capacity() const Returns the allocated size of the internal buffer. |
void |
clear() Clears the internal buffer for re-use - the memory is not freed. |
const T* |
data() const Returns a const pointer to the start of the internal buffer. |
void |
destroy() Frees the internal buffer. |
size_t |
size() const Returns the number of buffer elements currently in use. |
Typedefs |
typedef T DataType
Constructor/Destructor Detail |
AutoBuffer()
AutoBuffer(size_t initialSize)
initialSize
- ~AutoBuffer()
Method Detail |
void append(T data)
data
- void append(const T* pData, size_t length)
pData
- length
- size_t capacity() const
void clear()
const T* data() const
void destroy()
size_t size() const
|
OpenTop 1.3 | |||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | Cross-Platform C++ | ||||
SUMMARY: CONSTRUCTOR | METHOD | DETAIL: CONSTRUCTOR | METHOD |