libcmutils 0.6.5
Multi-platform C99 utility library
Loading...
Searching...
No Matches

Manipulation of bytes. More...

Data Fields

CMUTIL_ByteBuffer *(* AddByte )(CMUTIL_ByteBuffer *buffer, uint8_t b)
 Append a byte to this buffer.
 
CMUTIL_ByteBuffer *(* AddBytes )(CMUTIL_ByteBuffer *buffer, const uint8_t *bytes, uint32_t length)
 Adds a sequence of bytes to the specified buffer.
 
CMUTIL_ByteBuffer *(* AddBytesPart )(CMUTIL_ByteBuffer *buffer, const uint8_t *bytes, uint32_t offset, uint32_t length)
 Adds a portion of a byte array to the specified buffer.
 
CMUTIL_ByteBuffer *(* InsertByteAt )(CMUTIL_ByteBuffer *buffer, uint32_t index, uint8_t b)
 Inserts a byte at a specified index in the byte buffer.
 
CMUTIL_ByteBuffer *(* InsertBytesAt )(CMUTIL_ByteBuffer *buffer, uint32_t index, const uint8_t *bytes, uint32_t length)
 Inserts a sequence of bytes at a specified index in the byte buffer.
 
int(* GetAt )(const CMUTIL_ByteBuffer *buffer, uint32_t index)
 Retrieves the byte at a specific index in the byte buffer.
 
size_t(* GetSize )(const CMUTIL_ByteBuffer *buffer)
 Retrieves the size of the given byte buffer.
 
uint8_t *(* GetBytes )(CMUTIL_ByteBuffer *buffer)
 Function pointer to retrieve a byte array from a CMUTIL_ByteBuffer.
 
CMBool(* ShrinkTo )(CMUTIL_ByteBuffer *buffer, size_t size)
 Function pointer for resizing a CMUTIL_ByteBuffer to a specified size.
 
size_t(* GetCapacity )(const CMUTIL_ByteBuffer *buffer)
 Retrieves the total capacity of the specified byte buffer.
 
void(* Destroy )(CMUTIL_ByteBuffer *buffer)
 Function pointer for destroying a CMUTIL_ByteBuffer instance.
 
void(* Clear )(CMUTIL_ByteBuffer *buffer)
 Function pointer for clearing the contents of a CMUTIL_ByteBuffer.
 

Detailed Description

Manipulation of bytes.

Field Documentation

◆ AddByte

CMUTIL_ByteBuffer *(* CMUTIL_ByteBuffer::AddByte) (CMUTIL_ByteBuffer *buffer, uint8_t b)

Append a byte to this buffer.

Parameters
bufferThis buffer object.
bA byte to be added.
Returns
This buffer object. NULL if the addition is failed.

◆ AddBytes

CMUTIL_ByteBuffer *(* CMUTIL_ByteBuffer::AddBytes) (CMUTIL_ByteBuffer *buffer, const uint8_t *bytes, uint32_t length)

Adds a sequence of bytes to the specified buffer.

This function appends a provided array of bytes to the end of the given byte buffer. It also updates the buffer's internal state to include the newly added bytes.

Parameters
bufferA pointer to the byte buffer where the bytes will be added.
bytesA pointer to the array of bytes to be appended.
lengthThe number of bytes to be added from the array.
Returns
A pointer to the updated buffer if the operation is successful, or NULL if the addition fails.

◆ AddBytesPart

CMUTIL_ByteBuffer *(* CMUTIL_ByteBuffer::AddBytesPart) (CMUTIL_ByteBuffer *buffer, const uint8_t *bytes, uint32_t offset, uint32_t length)

Adds a portion of a byte array to the specified buffer.

This function appends a subset of the provided byte array to the specified byte buffer. The portion of the array to be appended is determined by the provided offset and length. The function updates the buffer's state to reflect the added bytes.

Parameters
bufferA pointer to the byte buffer where the bytes will be added.
bytesA pointer to the source byte array.
offsetThe starting position within the source array from which bytes will be copied.
lengthThe number of bytes to add from the source array.
Returns
A pointer to the updated buffer if the operation is successful, or NULL if the addition fails.

◆ InsertByteAt

CMUTIL_ByteBuffer *(* CMUTIL_ByteBuffer::InsertByteAt) (CMUTIL_ByteBuffer *buffer, uint32_t index, uint8_t b)

Inserts a byte at a specified index in the byte buffer.

This function allows placing a single byte at any specified position within the given byte buffer. The existing data in the buffer is shifted as needed to make space for the new byte. If the insertion fails, the buffer remains unmodified.

Parameters
bufferA pointer to the byte buffer where the byte will be inserted.
indexThe position in the buffer at which the byte should be inserted.
bThe byte to insert into the buffer.
Returns
A pointer to the updated byte buffer if the operation is successful, or NULL if the insertion fails.

◆ InsertBytesAt

CMUTIL_ByteBuffer *(* CMUTIL_ByteBuffer::InsertBytesAt) (CMUTIL_ByteBuffer *buffer, uint32_t index, const uint8_t *bytes, uint32_t length)

Inserts a sequence of bytes at a specified index in the byte buffer.

This function allows inserting an array of bytes into a specific position within the given byte buffer. The existing data in the buffer is shifted as needed to make space for the new bytes. If the insertion operation fails, the buffer remains unmodified.

Parameters
bufferA pointer to the byte buffer where the bytes will be inserted.
indexThe position in the buffer at which the bytes should be inserted.
bytesA pointer to the array of bytes to insert into the buffer.
lengthThe number of bytes to insert from the array.
Returns
A pointer to the updated byte buffer if the operation is successful, or NULL if the insertion fails.

◆ GetAt

int(* CMUTIL_ByteBuffer::GetAt) (const CMUTIL_ByteBuffer *buffer, uint32_t index)

Retrieves the byte at a specific index in the byte buffer.

This function provides access to the byte located at a given index within the specified byte buffer without modifying the buffer. If the index is out of bounds, it returns a negative value.

Parameters
bufferA pointer to the byte buffer from which the byte should be retrieved.
indexThe position of the byte to retrieve within the buffer.
Returns
The byte located at the specified index in the buffer, a negative value if failed.

◆ GetSize

size_t(* CMUTIL_ByteBuffer::GetSize) (const CMUTIL_ByteBuffer *buffer)

Retrieves the size of the given byte buffer.

This function returns the total number of bytes currently stored in the specified byte buffer. It provides a way to determine the current capacity or length of the buffer's contents.

Parameters
bufferA pointer to the byte buffer whose size will be retrieved.
Returns
The size of the byte buffer, in bytes.

◆ GetBytes

uint8_t *(* CMUTIL_ByteBuffer::GetBytes) (CMUTIL_ByteBuffer *buffer)

Function pointer to retrieve a byte array from a CMUTIL_ByteBuffer.

This variable is a function pointer that, when assigned, points to a function capable of extracting a byte array stored in the specified CMUTIL_ByteBuffer structure.

Parameters
bufferPointer to a CMUTIL_ByteBuffer structure from which the byte array is to be retrieved.
Returns
Pointer to the byte array extracted from the given buffer.

◆ ShrinkTo

CMBool(* CMUTIL_ByteBuffer::ShrinkTo) (CMUTIL_ByteBuffer *buffer, size_t size)

Function pointer for resizing a CMUTIL_ByteBuffer to a specified size.

This function reduces the size of the provided byte buffer to the specified size if possible. Success or failure is indicated through the returned boolean value.

Parameters
bufferA pointer to the CMUTIL_ByteBuffer to be resized.
sizeThe target size to shrink the buffer to.
Returns
A CMBool indicating whether the operation was successful.

◆ GetCapacity

size_t(* CMUTIL_ByteBuffer::GetCapacity) (const CMUTIL_ByteBuffer *buffer)

Retrieves the total capacity of the specified byte buffer.

This function pointer returns the maximum number of bytes the given CMUTIL_ByteBuffer can hold without resize operation.

Parameters
bufferA pointer to the CMUTIL_ByteBuffer instance.
Returns
The capacity of the byte buffer in bytes.

◆ Destroy

void(* CMUTIL_ByteBuffer::Destroy) (CMUTIL_ByteBuffer *buffer)

Function pointer for destroying a CMUTIL_ByteBuffer instance.

This function is responsible for releasing and cleaning up resources associated with a given CMUTIL_ByteBuffer object.

Parameters
bufferA pointer to the CMUTIL_ByteBuffer instance to be destroyed.

◆ Clear

void(* CMUTIL_ByteBuffer::Clear) (CMUTIL_ByteBuffer *buffer)

Function pointer for clearing the contents of a CMUTIL_ByteBuffer.

This function is used to reset or clear the data in a provided byte buffer, ensuring that its contents are erased or set back to an initial state.

Parameters
bufferA pointer to the CMUTIL_ByteBuffer to be cleared.

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