libGimbal 0.1.0
C17-Based Extended Standard Library and Cross-Language Runtime Framework
Loading...
Searching...
No Matches
gimbal::ByteArray Class Reference
Inheritance diagram for gimbal::ByteArray:
GblByteArray

Public Member Functions

 ByteArray (Size bytes=0, const void *pData=nullptr)
 
 ByteArray (const ByteArray &other)
 
 ByteArray (ByteArray &&other)
 
ByteArrayoperator= (const ByteArray &other)
 
ByteArrayoperator= (ByteArray &&other)
 
bool operator== (const ByteArray &rhs) const
 
bool operator!= (const ByteArray &rhs) const
 
Size getSize (void) const
 
template<typename T = void*>
getData (void) const
 
bool isEmpty (void) const
 
ContextgetContext (void) const
 
void clear (void)
 
void acquire (std::pair< Size, void * > data)
 
auto release (void) -> std::pair< Size, void * >
 
template<typename T >
void readData (T *pOutData, Size offset=0, Size bytes=sizeof(T)) const
 
template<typename T >
void writeData (const T &pInData, Size offset=0, Size bytes=sizeof(T))
 
void resize (Size bytes)
 
void grow (Size bytes)
 
void shrink (Size bytes)
 
void erase (Size offset, Size bytes)
 
template<typename T >
void insert (const T &dataIn, Size offset=0, Size bytes=sizeof(T))
 
template<typename T >
void append (const T &dataIn, Size bytes=sizeof(T))
 
template<typename T >
void prepend (const T &dataIn, Size bytes=sizeof(T))
 

Additional Inherited Members

- Data Fields inherited from GblByteArray
size_t size
 
uint8_t * pData
 

Detailed Description

Definition at line 11 of file gimbal_byte_array.hpp.

Constructor & Destructor Documentation

◆ ByteArray() [1/3]

gimbal::ByteArray::ByteArray ( Size  bytes = 0,
const void *  pData = nullptr 
)
inline

Definition at line 58 of file gimbal_byte_array.hpp.

58 {
59 Exception::checkThrow(GblByteArray_construct(this, bytes, pData));
60}
uint8_t * pData
Actual data payload, contiguously-allocated array of bytes.

◆ ByteArray() [2/3]

gimbal::ByteArray::ByteArray ( const ByteArray other)
inline

Definition at line 63 of file gimbal_byte_array.hpp.

63 {
64 Exception::checkThrow(GblByteArray_copy(this, &other));
65}
GBL_RESULT GblByteArray_copy(GblByteArray *pSelf, const GblByteArray *pOther)
Frees the existing allocation and copies over the allocation and size from pOther.

◆ ByteArray() [3/3]

gimbal::ByteArray::ByteArray ( ByteArray &&  other)
inline

Definition at line 67 of file gimbal_byte_array.hpp.

67 {
68 Exception::checkThrow(GblByteArray_move(this, &other));
69}
GBL_RESULT GblByteArray_move(GblByteArray *pSelf, GblByteArray *pOther)
Frees the existing allocation and takes the allocation from pOther, clearing it.

◆ ~ByteArray()

gimbal::ByteArray::~ByteArray ( void  )
inline

Definition at line 71 of file gimbal_byte_array.hpp.

71 {
72 Exception::checkThrow(GblByteArray_destruct(this));
73}

Member Function Documentation

◆ operator=() [1/2]

ByteArray & gimbal::ByteArray::operator= ( const ByteArray other)
inline

Definition at line 85 of file gimbal_byte_array.hpp.

85 {
86 Exception::checkThrow(GblByteArray_copy(this, &other));
87 return *this;
88}

◆ operator=() [2/2]

ByteArray & gimbal::ByteArray::operator= ( ByteArray &&  other)
inline

Definition at line 90 of file gimbal_byte_array.hpp.

90 {
91 Exception::checkThrow(GblByteArray_move(this, &other));
92 return *this;
93}

◆ operator==()

bool gimbal::ByteArray::operator== ( const ByteArray rhs) const
inline

Definition at line 75 of file gimbal_byte_array.hpp.

75 {
76 GblCmpResult result = GblByteArray_compare(this, &rhs);
77 return !result;
78}
int GblByteArray_compare(const GblByteArray *pSelf, const GblByteArray *pRhs)
Compares the two byte arrays with semantics similar to memcmp(), returning the result.

◆ operator!=()

bool gimbal::ByteArray::operator!= ( const ByteArray rhs) const
inline

Definition at line 80 of file gimbal_byte_array.hpp.

80 {
81 return !(*this == rhs);
82}

◆ getSize()

Size gimbal::ByteArray::getSize ( void  ) const
inline

Definition at line 95 of file gimbal_byte_array.hpp.

95 {
96 return GblByteArray_size(this);
97}
size_t GblByteArray_size(const GblByteArray *pSelf)
Returns the size of the GblByteArray (GblByteArray::size)

◆ getData()

template<typename T >
T gimbal::ByteArray::getData ( void  ) const
inline

Definition at line 100 of file gimbal_byte_array.hpp.

100 {
101 return reinterpret_cast<T>(GblByteArray_data(this));
102}
void * GblByteArray_data(const GblByteArray *pSelf)
Returns the data pointer of the GblByteArray (GblByteArray::pData)

◆ isEmpty()

bool gimbal::ByteArray::isEmpty ( void  ) const
inline

Definition at line 104 of file gimbal_byte_array.hpp.

104 {
105 return GblByteArray_isEmpty(this);
106}

◆ clear()

void gimbal::ByteArray::clear ( void  )
inline

Definition at line 108 of file gimbal_byte_array.hpp.

108 {
109 Exception::checkThrow(GblByteArray_clear(this));
110}
GBL_RESULT GblByteArray_clear(GblByteArray *pSelf)
Clears all bytes from the given GblByteArray, freeing its allocation and resetting its size to 0.

◆ acquire()

void gimbal::ByteArray::acquire ( std::pair< Size, void * >  data)
inline

Definition at line 112 of file gimbal_byte_array.hpp.

112 {
113 Exception::checkThrow(GblByteArray_acquire(this, data.first, data.second));
114}
GBL_RESULT GblByteArray_acquire(GblByteArray *pSelf, size_t bytes, void *pData)
Frees the existing allocation and takes the allocation given by pData with the given size.

◆ release()

auto gimbal::ByteArray::release ( void  ) -> std::pair<Size, void*>
inline

Definition at line 116 of file gimbal_byte_array.hpp.

116 {
117 std::pair<Size, void*> retVal;
118 Exception::checkThrow(GblByteArray_release(this, &retVal.first, &retVal.second));
119 return retVal;
120}
GBL_RESULT GblByteArray_release(GblByteArray *pSelf, size_t *pSize, void **ppData)
Releases the internal allocation resource, copying it and its size out, clearing them from pSelf.

◆ readData()

template<typename T >
void gimbal::ByteArray::readData ( T *  pOutData,
Size  offset = 0,
Size  bytes = sizeof(T) 
) const
inline

Definition at line 153 of file gimbal_byte_array.hpp.

153 {
154 Exception::checkThrow(GblByteArray_dataRead(this, offset, bytes, pOutData));
155}

◆ writeData()

template<typename T >
void gimbal::ByteArray::writeData ( const T &  pInData,
Size  offset = 0,
Size  bytes = sizeof(T) 
)
inline

Definition at line 158 of file gimbal_byte_array.hpp.

158 {
159 Exception::checkThrow(GblByteArray_dataWrite(this, offset, bytes, &pInData));
160}

◆ resize()

void gimbal::ByteArray::resize ( Size  bytes)
inline

Definition at line 122 of file gimbal_byte_array.hpp.

122 {
123 Exception::checkThrow(GblByteArray_resize(this, bytes));
124}
GBL_RESULT GblByteArray_resize(GblByteArray *pSelf, size_t bytes)
Resizes the given GblByteArray to a size of bytes, appending byte values of 0 when growing,...

◆ grow()

void gimbal::ByteArray::grow ( Size  bytes)
inline

Definition at line 126 of file gimbal_byte_array.hpp.

126 {
127 Exception::checkThrow(GblByteArray_grow(this, bytes));
128}
GBL_RESULT GblByteArray_grow(GblByteArray *pSelf, size_t bytes)
Grows the given GblByteArray by the given number of bytes, filling the new ones with 0s,...

◆ shrink()

void gimbal::ByteArray::shrink ( Size  bytes)
inline

Definition at line 130 of file gimbal_byte_array.hpp.

130 {
131 Exception::checkThrow(GblByteArray_shrink(this, bytes));
132}
GBL_RESULT GblByteArray_shrink(GblByteArray *pSelf, size_t bytes)
Shrinks the given GblByteArray by the given number of bytes, returning a status code.

◆ erase()

void gimbal::ByteArray::erase ( Size  offset,
Size  bytes 
)
inline

Definition at line 134 of file gimbal_byte_array.hpp.

134 {
135 Exception::checkThrow(GblByteArray_erase(this, offset, bytes));
136}
GBL_RESULT GblByteArray_erase(GblByteArray *pSelf, size_t offset, size_t bytes)
Erases bytes from the given GblByteArray starting at offset, returning a status code.

◆ insert()

template<typename T >
void gimbal::ByteArray::insert ( const T &  dataIn,
Size  offset = 0,
Size  bytes = sizeof(T) 
)
inline

Definition at line 139 of file gimbal_byte_array.hpp.

139 {
140 Exception::checkThrow(GblByteArray_insert(this, offset, bytes, &dataIn));
141}
GBL_RESULT GblByteArray_insert(GblByteArray *pSelf, size_t offset, size_t bytes, const void *pData)
Inserts bytes into the given GblByteArray at offset, copying from pData, returning a status code and ...

◆ append()

template<typename T >
void gimbal::ByteArray::append ( const T &  dataIn,
Size  bytes = sizeof(T) 
)
inline

Definition at line 144 of file gimbal_byte_array.hpp.

144 {
145 Exception::checkThrow(GblByteArray_append(this, bytes, &dataIn));
146}
GBL_RESULT GblByteArray_append(GblByteArray *pSelf, size_t bytes, const void *pData)
Appends bytes from pData to the end of the given GblByteArray, returning a status code.

◆ prepend()

template<typename T >
void gimbal::ByteArray::prepend ( const T &  dataIn,
Size  bytes = sizeof(T) 
)
inline

Definition at line 149 of file gimbal_byte_array.hpp.

149 {
150 Exception::checkThrow(GblByteArray_prepend(this, bytes, &dataIn));
151}
GBL_RESULT GblByteArray_prepend(GblByteArray *pSelf, size_t bytes, const void *pData)
Prepends bytes from pData to the beginning of the given GblByteArray, returning a status code.

The documentation for this class was generated from the following file: