libGimbal 0.1.0
C17-Based Extended Standard Library and Cross-Language Runtime Framework
Loading...
Searching...
No Matches
GblByteArray Struct Reference

#include <gimbal_byte_array.h>

Inheritance diagram for GblByteArray:
gimbal::ByteArray

Data Fields

size_t size
 
uint8_t * pData
 

Related Symbols

(Note that these are not member symbols.)

Lifetime Management

Methods for creation and reference management

GblByteArrayGblByteArray_create (size_t size, const void *pData, GblContext *pCtx)
 
GblByteArrayGblByteArray_ref (GblByteArray *pSelf)
 
GblRefCount GblByteArray_unref (GblByteArray *pSelf)
 
Type Operators

Assignment and comparison methods

GBL_RESULT GblByteArray_copy (GblByteArray *pSelf, const GblByteArray *pOther)
 
GBL_RESULT GblByteArray_move (GblByteArray *pSelf, GblByteArray *pOther)
 
GBL_RESULT GblByteArray_acquire (GblByteArray *pSelf, size_t bytes, void *pData)
 
GBL_RESULT GblByteArray_release (GblByteArray *pSelf, size_t *pSize, void **ppData)
 
int GblByteArray_compare (const GblByteArray *pSelf, const GblByteArray *pRhs)
 
GblBool GblByteArray_equals (const GblByteArray *pSelf, const GblByteArray *pRhs)
 
Properties

Methods for getting values

GblRefCount GblByteArray_refCount (const GblByteArray *pSelf)
 
GblContextGblByteArray_context (const GblByteArray *pSelf)
 
size_t GblByteArray_size (const GblByteArray *pSelf)
 
void * GblByteArray_data (const GblByteArray *pSelf)
 
GblBool GblByteArray_empty (const GblByteArray *pSelf)
 
GblHash GblByteArray_hash (const GblByteArray *pSelf)
 
const char * GblByteArray_cString (const GblByteArray *pSelf)
 
GblStringView GblByteArray_stringView (const GblByteArray *pSelf)
 
Reading and Writing

Methods for fetching and storing data

uint8_t GblByteArray_at (const GblByteArray *pSelf, size_t index)
 
GBL_RESULT GblByteArray_read (const GblByteArray *pSelf, size_t offset, size_t bytes, void *pOut)
 
GBL_RESULT GblByteArray_write (GblByteArray *pSelf, size_t offset, size_t bytes, const void *pIn)
 
GBL_RESULT GblByteArray_set (GblByteArray *pSelf, size_t bytes, const void *pData)
 
List API

Methods providing a standard list-style interface

GBL_RESULT GblByteArray_append (GblByteArray *pSelf, size_t bytes, const void *pData)
 
GBL_RESULT GblByteArray_prepend (GblByteArray *pSelf, size_t bytes, const void *pData)
 
GBL_RESULT GblByteArray_insert (GblByteArray *pSelf, size_t offset, size_t bytes, const void *pData)
 
GBL_RESULT GblByteArray_erase (GblByteArray *pSelf, size_t offset, size_t bytes)
 
GBL_RESULT GblByteArray_clear (GblByteArray *pSelf)
 
GBL_RESULT GblByteArray_resize (GblByteArray *pSelf, size_t bytes)
 
GBL_RESULT GblByteArray_grow (GblByteArray *pSelf, size_t bytes)
 
GBL_RESULT GblByteArray_shrink (GblByteArray *pSelf, size_t bytes)
 

Detailed Description

Reference-counted resizable array of bytes.

GblByteArray is a reference-counted dynamic array of bytes with a list-style API as well as various methods for manipulating and extracting subarrays.

See also
GblBitView

Definition at line 36 of file gimbal_byte_array.h.

Friends And Related Symbol Documentation

◆ GblByteArray_create()

GblByteArray * GblByteArray_create ( size_t  size,
const void *  pData,
GblContext pCtx 
)
related

Creates and returns a new GblByteArray, with the given size and optional initial data and context.

◆ GblByteArray_ref()

GblByteArray * GblByteArray_ref ( GblByteArray pSelf)
related

Increments the reference counter of the given GblByteArray by 1, returning back a pointer to it.

◆ GblByteArray_unref()

GblRefCount GblByteArray_unref ( GblByteArray pSelf)
related

Decrements the reference counter of the given GblByteArray by 1, destroying it upon hitting 0.

◆ GblByteArray_copy()

GBL_RESULT GblByteArray_copy ( GblByteArray pSelf,
const GblByteArray pOther 
)
related

Frees the existing allocation and copies over the allocation and size from pOther.

◆ GblByteArray_move()

GBL_RESULT GblByteArray_move ( GblByteArray pSelf,
GblByteArray pOther 
)
related

Frees the existing allocation and takes the allocation from pOther, clearing it.

◆ GblByteArray_acquire()

GBL_RESULT GblByteArray_acquire ( GblByteArray pSelf,
size_t  bytes,
void *  pData 
)
related

Frees the existing allocation and takes the allocation given by pData with the given size.

◆ GblByteArray_release()

GBL_RESULT GblByteArray_release ( GblByteArray pSelf,
size_t *  pSize,
void **  ppData 
)
related

Releases the internal allocation resource, copying it and its size out, clearing them from pSelf.

◆ GblByteArray_compare()

int GblByteArray_compare ( const GblByteArray pSelf,
const GblByteArray pRhs 
)
related

Compares the two byte arrays with semantics similar to memcmp(), returning the result.

◆ GblByteArray_equals()

GblBool GblByteArray_equals ( const GblByteArray pSelf,
const GblByteArray pRhs 
)
related

Returns GBL_TRUE if the values stored within the two byte arrays are all equal.

◆ GblByteArray_refCount()

GblRefCount GblByteArray_refCount ( const GblByteArray pSelf)
related

Returns the current number of active references to the given GblByteArray.

◆ GblByteArray_context()

GblContext * GblByteArray_context ( const GblByteArray pSelf)
related

Returns the GblContext pointer the GblByteArray was constructed with.

◆ GblByteArray_size()

size_t GblByteArray_size ( const GblByteArray pSelf)
related

Returns the size of the GblByteArray (GblByteArray::size)

◆ GblByteArray_data()

void * GblByteArray_data ( const GblByteArray pSelf)
related

Returns the data pointer of the GblByteArray (GblByteArray::pData)

◆ GblByteArray_empty()

GblBool GblByteArray_empty ( const GblByteArray pSelf)
related

Return GBL_TRUE if the given GblByteArray is empty (0 bytes)

◆ GblByteArray_hash()

GblHash GblByteArray_hash ( const GblByteArray pSelf)
related

Computes a hash over the GblByteArray, returning its value.

◆ GblByteArray_cString()

const char * GblByteArray_cString ( const GblByteArray pSelf)
related

Returns the GblByteArray as a C string, or NULL if it's not NULL-terminated.

◆ GblByteArray_stringView()

GblStringView GblByteArray_stringView ( const GblByteArray pSelf)
related

Returns a GblStringView spanning the bytes of the GblByteArray.

◆ GblByteArray_at()

uint8_t GblByteArray_at ( const GblByteArray pSelf,
size_t  index 
)
related

Returns the value of the byte located at the given index, raising an error upon out-of-range access.

◆ GblByteArray_read()

GBL_RESULT GblByteArray_read ( const GblByteArray pSelf,
size_t  offset,
size_t  bytes,
void *  pOut 
)
related

Attempts to read a range of bytes starting at offset, copying them to pOut, returning a result code.

◆ GblByteArray_write()

GBL_RESULT GblByteArray_write ( GblByteArray pSelf,
size_t  offset,
size_t  bytes,
const void *  pIn 
)
related

Attempts to write a range of bytes starting at offset, copying from pIn, returning a result code.

◆ GblByteArray_set()

GBL_RESULT GblByteArray_set ( GblByteArray pSelf,
size_t  bytes,
const void *  pData 
)
related

Resizes the GblByteArray to bytes, copying pData over into its internal array.

◆ GblByteArray_append()

GBL_RESULT GblByteArray_append ( GblByteArray pSelf,
size_t  bytes,
const void *  pData 
)
related

Appends bytes from pData to the end of the given GblByteArray, returning a status code.

◆ GblByteArray_prepend()

GBL_RESULT GblByteArray_prepend ( GblByteArray pSelf,
size_t  bytes,
const void *  pData 
)
related

Prepends bytes from pData to the beginning of the given GblByteArray, returning a status code.

◆ GblByteArray_insert()

GBL_RESULT GblByteArray_insert ( GblByteArray pSelf,
size_t  offset,
size_t  bytes,
const void *  pData 
)
related

Inserts bytes into the given GblByteArray at offset, copying from pData, returning a status code and resizing as needed.

◆ GblByteArray_erase()

GBL_RESULT GblByteArray_erase ( GblByteArray pSelf,
size_t  offset,
size_t  bytes 
)
related

Erases bytes from the given GblByteArray starting at offset, returning a status code.

◆ GblByteArray_clear()

GBL_RESULT GblByteArray_clear ( GblByteArray pSelf)
related

Clears all bytes from the given GblByteArray, freeing its allocation and resetting its size to 0.

◆ GblByteArray_resize()

GBL_RESULT GblByteArray_resize ( GblByteArray pSelf,
size_t  bytes 
)
related

Resizes the given GblByteArray to a size of bytes, appending byte values of 0 when growing, returning a status code.

◆ GblByteArray_grow()

GBL_RESULT GblByteArray_grow ( GblByteArray pSelf,
size_t  bytes 
)
related

Grows the given GblByteArray by the given number of bytes, filling the new ones with 0s, returning a status code.

◆ GblByteArray_shrink()

GBL_RESULT GblByteArray_shrink ( GblByteArray pSelf,
size_t  bytes 
)
related

Shrinks the given GblByteArray by the given number of bytes, returning a status code.

Field Documentation

◆ size

size_t GblByteArray::size

Size of the pData structure.

Definition at line 37 of file gimbal_byte_array.h.

◆ pData

uint8_t* GblByteArray::pData

Actual data payload, contiguously-allocated array of bytes.

Definition at line 38 of file gimbal_byte_array.h.


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