15 #ifndef _A_UTILS_UTIL_MEMORY_MEMORYBUFFER_INCLUDED_
16 #define _A_UTILS_UTIL_MEMORY_MEMORYBUFFER_INCLUDED_
86 void attach(
void* buffer, std::size_t size);
95 struct Implementation;
96 std::unique_ptr<Implementation> _impl;
Memory buffer class to encapsulate and manage raw contiguously memory.
MemoryBuffer()
Default CTOR, not allocating any memory.
MemoryBuffer(void *buffer, std::size_t size)
CTOR attaching to memory from a an already existing buffer (non-owning!)
MemoryBuffer(std::size_t initial_size)
CTOR with initial size of the buffer (first allocates, then zero-initializes the buffer)
std::size_t getSize() const
Get the size of the currently managed memory.
void * getPtr() const
Get raw pointer to the current buffer.
void attach(void *buffer, std::size_t size)
Attach a pre-allocated buffer to the instance (non-owning!)
bool allocate(std::size_t new_size)
Allocate and zero-initialize a new memory buffer, freeing or detaching any managed memory.
MemoryBuffer & operator=(const MemoryBuffer &other)
Assignment operator, always allocating new memory and performing a deep copy.
void swap(MemoryBuffer &other)
Swap content of this object with other.
~MemoryBuffer()
DTOR, either detaching any referenced buffer or deleting allocated memory.
void reset()
Reset the memory (freeing or detaching any managed memory)
MemoryBuffer(const MemoryBuffer &other)
Copy constructor, always allocating new memory and performing a deep copy.
bool operator==(const MemoryBuffer &lhs, const MemoryBuffer &rhs)
Compare content of the managed memory of two memory buffer objects for equality.
bool operator!=(const StackPtr< T, StackSize, Alignment > &lhs, const StackPtr< T, StackSize, Alignment > &rhs)
Compare for inequality.
Serves as the root component, with common functionality documented in core functionality.