API Documentation
Buffer.h
1 // Buffer.h
3 //
5 
6 namespace nkMemory
7 {
12  {
13  unsigned char* _data ;
14  unsigned long long _size ;
15  } ;
16 }
17 
18 namespace nkMemory
19 {
31  class Buffer final
32  {
33  public :
34 
35  // Constructors, destructor
39  Buffer () noexcept ;
46  Buffer (unsigned long long size) noexcept ;
53  Buffer (const unsigned char* data, unsigned long long size) noexcept ;
59  Buffer (std::initializer_list<unsigned char> args) noexcept ;
66  Buffer (const Buffer& other) noexcept ;
73  Buffer (Buffer&& other) noexcept ;
78  ~Buffer () ;
79 
80  // Getters
84  unsigned char* getData () const ;
88  unsigned long long getSize () const ;
92  bool empty () const ;
96  unsigned char& front () ;
100  const unsigned char& front () const ;
104  unsigned char& back () ;
108  const unsigned char& back () const ;
112  unsigned char* begin () ;
116  const unsigned char* begin () const ;
120  unsigned char* end () ;
124  const unsigned char* end () const ;
125 
126  // Management
132  Buffer& clear () ;
140  Buffer& resize (unsigned long long size) ;
148  Buffer& append (unsigned char value) ;
157  Buffer& erase (unsigned long long index, unsigned long long count = 1ull) ;
166 
167  // Operators
174  unsigned char& operator[] (unsigned long long index) ;
181  const unsigned char& operator[] (unsigned long long index) const ;
182 
189  Buffer& operator= (const Buffer& other) noexcept ;
196  Buffer& operator= (Buffer&& other) noexcept ;
197 
198  public :
199 
200  // Constructors templated
206  template <typename T, std::size_t S>
207  Buffer (const std::array<T, S>& array) noexcept ;
208 
214  template <typename T>
215  Buffer (const std::vector<T>& vec) noexcept ;
216 
217  public :
218 
219  // Memory ownership taking constructors
231  static Buffer createAndTakeMemory (unsigned char* data, unsigned long long size) ;
232  } ;
233 }
nkMemory::Buffer::getData
unsigned char * getData() const
nkMemory::Buffer::resize
Buffer & resize(unsigned long long size)
nkMemory::Buffer::end
unsigned char * end()
nkMemory::Buffer::erase
Buffer & erase(unsigned long long index, unsigned long long count=1ull)
nkMemory::Buffer::Buffer
Buffer() noexcept
nkMemory::Buffer::createAndTakeMemory
static Buffer createAndTakeMemory(unsigned char *data, unsigned long long size)
nkMemory::BufferDataDescriptor::_size
unsigned long long _size
The size, in bytes, of the data pointed.
Definition: Buffer.h:14
nkMemory::BufferDataDescriptor::_data
unsigned char * _data
The data pointer.
Definition: Buffer.h:13
nkMemory::Buffer
A buffer holding binary data.
Definition: Buffer.h:32
nkMemory::Buffer::append
Buffer & append(unsigned char value)
nkMemory::Buffer::clear
Buffer & clear()
nkMemory::Buffer::back
unsigned char & back()
nkMemory::BufferDataDescriptor
Describes the data held by a buffer.
Definition: Buffer.h:12
nkMemory::Buffer::getSize
unsigned long long getSize() const
nkMemory::Buffer::front
unsigned char & front()
nkMemory::Buffer::begin
unsigned char * begin()
nkMemory::Buffer::empty
bool empty() const
nkMemory::Buffer::relinquishDataOwnership
BufferDataDescriptor relinquishDataOwnership()
nkMemory
Encompasses all API of component NilkinsMemory.
Definition: Allocator.h:7