ImFusion C++ SDK 4.4.0
ImFusion::ByteBuffer Class Reference

#include <ImFusion/Core/ByteBuffer.h>

Specialization of the ByteBufferView class that has ownership of the underlying data. More...

Inheritance diagram for ImFusion::ByteBuffer:

Detailed Description

Specialization of the ByteBufferView class that has ownership of the underlying data.

In contrast to the base class, ByteBuffer is movable and move-assignable and copy construction/ copy assignment will deep copy the underlying data.

See also
ByteBufferStream

Public Member Functions

 ByteBuffer ()=default
 Create an empty (invalid) owning buffer.
 ByteBuffer (size_t size)
 Create an uninitialized owning buffer of the given size.
 ByteBuffer (std::unique_ptr< char[]> data, size_t size)
 Creates buffer taking ownership of the passed data.
 ByteBuffer (const std::string &string)
 Create a new buffer copying the content from string.
 ByteBuffer (const ByteBuffer &rhs)
 Copy constructor will always deep copy all data.
ByteBufferoperator= (const ByteBuffer &rhs)
 Copy assignment will always deep copy all data.
 ByteBuffer (ByteBuffer &&rhs) noexcept
 Move constructor will move all data into this instance. rhs will be empty/invalid afterwards.
ByteBufferoperator= (ByteBuffer &&rhs) noexcept
 Move assignment will move all data into this instance. rhs will be empty/invalid afterwards.
char * release ()
 Release any potential ownership and return the raw pointer now owning the underlying data.
Public Member Functions inherited from ImFusion::ByteBufferMutableView
 ByteBufferMutableView ()=default
 Create an empty (invalid) buffer.
 ByteBufferMutableView (char *data, size_t size)
 Create a non-owning buffer of the given size wrapping around the given array.
 ByteBufferMutableView (std::string &string)
 Create a new buffer referencing the content from string.
 ByteBufferMutableView (const ByteBufferMutableView &rhs)=default
 ByteBufferMutableView (ByteBufferMutableView &&rhs) noexcept=default
ByteBufferMutableViewoperator= (const ByteBufferMutableView &rhs)=default
ByteBufferMutableViewoperator= (ByteBufferMutableView &&rhs) noexcept=default
ByteBufferMutableView mutableView ()
 Return a mutable view onto this buffer, same effect as calling the copy constructor.
ByteBufferMutableView mutableSubView (size_t offset, size_t size) const
 Create a mutable view onto a subregion of this buffer.
char & operator[] (size_t which)
const char & operator[] (size_t which) const
char * data ()
 Return the pointer to the buffer data.
const char * data () const
 Return the pointer to the buffer data.
char * begin ()
 Return iterator to the beginning of the buffer.
const char * begin () const
 Return iterator to the beginning of the buffer.
char * end ()
 Return iterator to one past the end of the buffer.
const char * end () const
 Return iterator to one past the end of the buffer.
 ByteBufferMutableView (ByteBuffer &&rhs)=delete
ByteBufferMutableViewoperator= (ByteBuffer &&rhs)=delete
Public Member Functions inherited from ImFusion::ByteBufferView
 ByteBufferView ()=default
 Create an empty (invalid) buffer.
 ByteBufferView (const char *data, size_t size)
 Create a non-owning buffer of the given size wrapping around the given array.
 ByteBufferView (const std::string &string)
 Create a new buffer referencing the content from string.
 ByteBufferView (std::string_view string)
 ByteBufferView (const ByteBufferView &rhs)=default
 ByteBufferView (ByteBufferView &&rhs) noexcept=default
ByteBufferViewoperator= (const ByteBufferView &rhs)=default
ByteBufferViewoperator= (ByteBufferView &&rhs) noexcept=default
const char & operator[] (size_t which) const
const char * data () const
 Return the pointer to the buffer data.
ByteSize size () const
 Return the number of bytes stored in the buffer.
std::string toString () const
 Copy the data to a new std::string.
std::string_view toStringView () const
 Create a std::string_view onto the underlying buffer.
bool isEmpty () const
 Check whether the buffer is empty.
ByteBuffer copy () const
 Create an owning deep copy of this buffer.
ByteBuffer subCopy (size_t offset, size_t size) const
 Create an owning deep copy of a subregion of this buffer.
ByteBufferView view () const
 Return a const view onto this buffer, same effect as calling the copy constructor.
ByteBufferView subView (size_t offset, size_t size) const
 Create a read-only view onto a subregion of this buffer.
const char * begin () const
 Return iterator to the beginning of the buffer.
const char * end () const
 Return iterator to one past the end of the buffer.
 ByteBufferView (ByteBuffer &&rhs)=delete
ByteBufferViewoperator= (ByteBuffer &&rhs)=delete

Static Public Member Functions

static ByteBuffer copyFrom (const char *buffer, size_t size)
 Creates a new ByteBuffer copying the data from the given buffer.

Additional Inherited Members

Protected Attributes inherited from ImFusion::ByteBufferView
char * m_data = nullptr
 Raw pointer to the buffer data.
size_t m_size = 0
 Number of bytes stored in m_data.

The documentation for this class was generated from the following file:
  • ImFusion/Core/ByteBuffer.h
Search Tab / S to search, Esc to close