19 #ifndef LUNCHBOX_BUFFER_H 20 #define LUNCHBOX_BUFFER_H 22 #include <lunchbox/debug.h> 23 #include <lunchbox/os.h> 98 LBASSERT(_size > position);
99 return _data[position];
105 LBASSERT(_size > position);
106 return _data[position];
116 T*
resize(
const uint64_t newSize);
124 void grow(
const uint64_t newSize);
133 T*
reserve(
const uint64_t newSize);
142 T*
reset(
const uint64_t newSize);
145 void setZero() { ::lunchbox::setZero(_data, _size); }
147 void append(
const T* data,
const uint64_t size);
150 void append(
const T& element);
153 void replace(
const void* data,
const uint64_t size);
172 bool setSize(
const uint64_t size);
194 #include "buffer.ipp" 196 #endif // LUNCHBOX_BUFFER_H
Buffer(const uint64_t size)
Construct a new buffer of the given size.
Basic type definitions not provided by the operating system.
T * reserve(const uint64_t newSize)
Ensure that the buffer contains at least newSize elements.
Buffer & operator=(const Buffer &from)
Assignment operator, copies data from Buffer.
void append(const T *data, const uint64_t size)
Append elements to the buffer, increasing the size.
uint64_t getMaxSize() const
bool setSize(const uint64_t size)
Set the size of the buffer without changing its allocation.
uint64_t getNumBytes() const
~Buffer()
Destruct the buffer.
const T & operator[](const uint64_t position) const
Direct const access to an element.
void swap(Buffer &buffer)
Swap the buffer contents with another Buffer.
const T * getData() const
void clear()
Flush the buffer, deleting all data.
void grow(const uint64_t newSize)
Ensure that the buffer contains at least newSize elements.
Abstraction layer and common utilities for multi-threaded programming.
void replace(const Buffer &from)
Replace the existing data.
T * resize(const uint64_t newSize)
Ensure that the buffer contains at least newSize elements.
void replace(const void *data, const uint64_t size)
Replace the existing data with new data.
T * reset(const uint64_t newSize)
Set the buffer size and malloc enough memory.
Buffer()
Construct a new, empty buffer.
T & operator[](const uint64_t position)
Direct access to the element at the given index.
void setZero()
Set the buffer content to 0.
A simple memory buffer with some helper functions.
T * pack()
Tighten the allocated memory to the size of the buffer.