29#include <sptk5/Exception.h>
30#include <sptk5/sptk.h>
100 allocate((
const uint8_t*) data, sz);
108 return m_buffer.data();
116 return m_buffer.data();
124 return (
const char*) m_buffer.data();
143 if (sz + 1 >= m_buffer.size())
157 void set(
const T* data,
size_t sz)
159 _set((
const uint8_t*) data, sz);
170 if (data.m_bytes == 0)
176 _set(data.m_buffer.data(), data.m_bytes);
188 _set((
const uint8_t*) data.c_str(), data.length());
197 return m_buffer.size() - 1;
230 if (b + 1 <= m_buffer.size())
236 throw Exception(
"Attempt to set buffer size outside storage");
254 virtual void append(
const char* data,
size_t sz = 0);
263 virtual void append(
const uint8_t* data,
size_t sz);
278 void fill(
char ch,
size_t count);
285 void erase(
size_t offset,
size_t length);
300 m_buffer.resize(size + 1);
311 m_buffer.resize(size + 1);
313 if (data !=
nullptr && size != 0)
315 memcpy(m_buffer.data(), data, size);
326 m_buffer.resize(size + 1);
344 void init(
const uint8_t* data,
size_t size,
size_t bytes)
346 allocate(data, size);
351 std::vector<uint8_t> m_buffer;
362 void _set(
const uint8_t* data,
size_t sz);
Definition: BufferStorage.h:44
size_t length() const
Definition: BufferStorage.h:204
void fill(char ch, size_t count)
void erase(size_t offset, size_t length)
void adjustSize(size_t sz)
void bytes(size_t b)
Definition: BufferStorage.h:224
void reallocate(size_t size)
Definition: BufferStorage.h:324
BufferStorage(size_t sz)
Definition: BufferStorage.h:63
BufferStorage()
Definition: BufferStorage.h:51
void set(const T *data, size_t sz)
Definition: BufferStorage.h:157
size_t bytes() const
Definition: BufferStorage.h:213
void allocate(const uint8_t *data, size_t size)
Definition: BufferStorage.h:309
virtual void append(const uint8_t *data, size_t sz)
BufferStorage(const T *data, size_t sz)
Definition: BufferStorage.h:98
virtual void checkSize(size_t sz)
Definition: BufferStorage.h:141
void set(const String &data)
Definition: BufferStorage.h:186
void deallocate() noexcept
Definition: BufferStorage.h:337
virtual void append(char ch)
const char * c_str() const
Definition: BufferStorage.h:122
virtual ~BufferStorage()=default
void allocate(size_t size)
Definition: BufferStorage.h:298
virtual void append(const char *data, size_t sz=0)
const uint8_t * data() const
Definition: BufferStorage.h:114
BufferStorage(BufferStorage &&bufferStorage) noexcept=default
void set(const BufferStorage &data)
Definition: BufferStorage.h:168
BufferStorage(const BufferStorage &bufferStorage)=default
uint8_t * data()
Definition: BufferStorage.h:106
size_t capacity() const
Definition: BufferStorage.h:195
bool empty() const
Definition: BufferStorage.h:130
SPTK generic exception class.
Definition: Exception.h:56