Mbed OS Reference
Loading...
Searching...
No Matches

Data Structures

struct  __ac_buffer
 
struct  __ac_buffer_builder
 

Buffer

typedef struct __ac_buffer ac_buffer_t
 
void ac_buffer_init (ac_buffer_t *pBuf, const uint8_t *data, size_t size)
 Initialize ac_buffer using underlying byte array, set ac_buffer's length to 0 (empty) More...
 
void ac_buffer_dup (ac_buffer_t *pBuf, const ac_buffer_t *pBufIn)
 Copy pBufIn to pBuf. More...
 
void ac_buffer_append (ac_buffer_t *pBuf, ac_buffer_t *pAppBuf)
 Append buffer to end of chain. More...
 
void ac_buffer_split (ac_buffer_t *pStartBuf, ac_buffer_t *pEndBuf, ac_buffer_t *pBuf, size_t length)
 Truncate pBuf to length bytes and save the remaining bytes in pEndBuf. More...
 
void ac_buffer_dump (ac_buffer_t *pBuf)
 

Buffer Builder

typedef struct __ac_buffer_builder ac_buffer_builder_t
 
void ac_buffer_builder_write_be (ac_buffer_builder_t *pBuilder, const uint8_t *buf, size_t size)
 Write data to big endian ac_buffer (on a LE architecture, byte order will be swapped) More...
 
void ac_buffer_builder_write_le (ac_buffer_builder_t *pBuilder, const uint8_t *buf, size_t size)
 Write data to little endian ac_buffer (on a LE architecture, byte order will be preserved) More...
 
void ac_buffer_builder_write_be_at (ac_buffer_builder_t *pBuilder, size_t pos, const uint8_t *buf, size_t size)
 Write data to big endian ac_buffer at specific position (on a LE architecture, byte order will be swapped) More...
 
void ac_buffer_builder_write_le_at (ac_buffer_builder_t *pBuilder, size_t pos, const uint8_t *buf, size_t size)
 Write data to little endian ac_buffer at specific position (on a LE architecture, byte order will be preserved) More...
 
void ac_buffer_builder_init (ac_buffer_builder_t *pBuilder, uint8_t *data, size_t size)
 Initialize ac_buffer builder. More...
 
void ac_buffer_builder_from_buffer (ac_buffer_builder_t *pBuilder)
 Initialize ac_buffer builder from underlying ac_buffer. More...
 
void ac_buffer_builder_reset (ac_buffer_builder_t *pBuilder)
 Reset ac_buffer builder. More...
 
void ac_buffer_builder_set_full (ac_buffer_builder_t *pBuilder)
 Set ac_buffer builder's ac_buffer to full size. More...
 
void ac_buffer_builder_write_n_skip (ac_buffer_builder_t *pBuilder, size_t size)
 Skip n-bytes in ac_buffer builder. More...
 
void ac_buffer_builder_copy_n_bytes (ac_buffer_builder_t *pBuilderOut, ac_buffer_t *pBufIn, size_t size)
 Copy n bytes from buffer to builder. More...
 
void ac_buffer_builder_compact (ac_buffer_builder_t *pBuilder)
 Compact builder Will move underlying buffer's byte to start of allocated buffer. More...
 

Buffer Reader

void ac_buffer_read_be (ac_buffer_t *pBuf, uint8_t *buf, size_t size)
 Read n-bytes in big-endian format from buffer reader and advance read posiion. More...
 
void ac_buffer_read_le (ac_buffer_t *pBuf, uint8_t *buf, size_t size)
 Read n-bytes in little-endian format from buffer reader and advance read posiion. More...
 
void ac_buffer_read_n_skip (ac_buffer_t *pBuf, size_t size)
 Skip n bytes from buffer reader and advance read posiion. More...
 
size_t ac_buffer_reader_readable (const ac_buffer_t *pBuf)
 Get number of bytes readable from buffer. More...
 
const uint8_t * ac_buffer_reader_current_buffer_pointer (ac_buffer_t *pBuf)
 Get a pointer to the current position within this buffer's current backing array. More...
 
size_t ac_buffer_reader_current_buffer_length (ac_buffer_t *pBuf)
 Get the number of bytes readable within the current backing array. More...
 
bool ac_buffer_reader_cmp_bytes (const ac_buffer_t *pBuf, const uint8_t *bytes, size_t length)
 Compare buffer with array (does not advance read position) More...
 
bool ac_buffer_reader_cmp (const ac_buffer_t *pBuf1, const ac_buffer_t *pBuf2)
 Compare buffer with array (does not advance read position) More...
 

Detailed Description

Function Documentation

◆ ac_buffer_init()

void ac_buffer_init ( ac_buffer_t pBuf,
const uint8_t *  data,
size_t  size 
)

Initialize ac_buffer using underlying byte array, set ac_buffer's length to 0 (empty)

Parameters
pBufpointer to ac_buffer_t structure to initialize
databyte array to use
sizesize of byte array

◆ ac_buffer_dup()

void ac_buffer_dup ( ac_buffer_t pBuf,
const ac_buffer_t pBufIn 
)

Copy pBufIn to pBuf.

Parameters
pBufpointer to ac_buffer_t structure to initialize
pBufInthe source buffer

◆ ac_buffer_append()

void ac_buffer_append ( ac_buffer_t pBuf,
ac_buffer_t pAppBuf 
)

Append buffer to end of chain.

Parameters
pBufpointer to ac_buffer_t structure
pAppBufpointer to buffer to append to chain

◆ ac_buffer_split()

void ac_buffer_split ( ac_buffer_t pStartBuf,
ac_buffer_t pEndBuf,
ac_buffer_t pBuf,
size_t  length 
)

Truncate pBuf to length bytes and save the remaining bytes in pEndBuf.

Parameters
pBufThe buffer to split (will be set to invalid state)
pStartBufA new buffer at the head of the split
pEndBufA new buffer at the tail of the split
lengthHow long pStartBuf should be (if longer than pBuf, then pStartBuf will be pBuf)

◆ ac_buffer_builder_write_be()

void ac_buffer_builder_write_be ( ac_buffer_builder_t pBuilder,
const uint8_t *  buf,
size_t  size 
)

Write data to big endian ac_buffer (on a LE architecture, byte order will be swapped)

Parameters
pBuilderac_buffer builder to use
bufpointer to data
sizethe data size

◆ ac_buffer_builder_write_le()

void ac_buffer_builder_write_le ( ac_buffer_builder_t pBuilder,
const uint8_t *  buf,
size_t  size 
)

Write data to little endian ac_buffer (on a LE architecture, byte order will be preserved)

Parameters
pBuilderac_buffer builder to use
bufpointer to data
sizethe data size

◆ ac_buffer_builder_write_be_at()

void ac_buffer_builder_write_be_at ( ac_buffer_builder_t pBuilder,
size_t  pos,
const uint8_t *  buf,
size_t  size 
)

Write data to big endian ac_buffer at specific position (on a LE architecture, byte order will be swapped)

Parameters
pBuilderac_buffer builder to use
posposition in ac_buffer to write from
bufpointer to data
sizethe data size

◆ ac_buffer_builder_write_le_at()

void ac_buffer_builder_write_le_at ( ac_buffer_builder_t pBuilder,
size_t  pos,
const uint8_t *  buf,
size_t  size 
)

Write data to little endian ac_buffer at specific position (on a LE architecture, byte order will be preserved)

Parameters
pBuilderac_buffer builder to use
posposition in ac_buffer to write from
bufpointer to data
sizethe data size

◆ ac_buffer_builder_init()

void ac_buffer_builder_init ( ac_buffer_builder_t pBuilder,
uint8_t *  data,
size_t  size 
)

Initialize ac_buffer builder.

Parameters
pBuilderac_buffer builder to init
datapointer to byte array to use
sizeof byte array

◆ ac_buffer_builder_from_buffer()

void ac_buffer_builder_from_buffer ( ac_buffer_builder_t pBuilder)

Initialize ac_buffer builder from underlying ac_buffer.

Parameters
pBuilderac_buffer builder to init

◆ ac_buffer_builder_reset()

void ac_buffer_builder_reset ( ac_buffer_builder_t pBuilder)

Reset ac_buffer builder.

Parameters
pBuilderac_buffer builder to reset

◆ ac_buffer_builder_set_full()

void ac_buffer_builder_set_full ( ac_buffer_builder_t pBuilder)

Set ac_buffer builder's ac_buffer to full size.

Parameters
pBuilderac_buffer builder to set to full size

◆ ac_buffer_builder_write_n_skip()

void ac_buffer_builder_write_n_skip ( ac_buffer_builder_t pBuilder,
size_t  size 
)

Skip n-bytes in ac_buffer builder.

Parameters
pBuilderac_buffer builder
sizenumber of bytes to skip

◆ ac_buffer_builder_copy_n_bytes()

void ac_buffer_builder_copy_n_bytes ( ac_buffer_builder_t pBuilderOut,
ac_buffer_t pBufIn,
size_t  size 
)

Copy n bytes from buffer to builder.

Parameters
pBuilderOutac_buffer builder
pBufInthe input buffer
sizenumber of bytes to copy

◆ ac_buffer_builder_compact()

void ac_buffer_builder_compact ( ac_buffer_builder_t pBuilder)

Compact builder Will move underlying buffer's byte to start of allocated buffer.

Parameters
pBuilderac_buffer builder

◆ ac_buffer_read_be()

void ac_buffer_read_be ( ac_buffer_t pBuf,
uint8_t *  buf,
size_t  size 
)

Read n-bytes in big-endian format from buffer reader and advance read posiion.

Parameters
pBufthe buffer to read from
bufthe array to write to
sizethe number of bytes to read

◆ ac_buffer_read_le()

void ac_buffer_read_le ( ac_buffer_t pBuf,
uint8_t *  buf,
size_t  size 
)

Read n-bytes in little-endian format from buffer reader and advance read posiion.

Parameters
pBufthe buffer to read from
bufthe array to write to
sizethe number of bytes to read

◆ ac_buffer_read_n_skip()

void ac_buffer_read_n_skip ( ac_buffer_t pBuf,
size_t  size 
)

Skip n bytes from buffer reader and advance read posiion.

Parameters
pBufthe buffer to read from
sizethe number of bytes to skip

◆ ac_buffer_reader_readable()

size_t ac_buffer_reader_readable ( const ac_buffer_t pBuf)

Get number of bytes readable from buffer.

Parameters
pBufthe buffer to read from
Returns
The number of bytes which can be read

◆ ac_buffer_reader_current_buffer_pointer()

const uint8_t * ac_buffer_reader_current_buffer_pointer ( ac_buffer_t pBuf)

Get a pointer to the current position within this buffer's current backing array.

Parameters
pBufthe buffer to read from
Returns
A pointer to the current position within the current backing array

◆ ac_buffer_reader_current_buffer_length()

size_t ac_buffer_reader_current_buffer_length ( ac_buffer_t pBuf)

Get the number of bytes readable within the current backing array.

Parameters
pBufthe buffer to read from
Returns
The number of bytes readable within the current backing array

◆ ac_buffer_reader_cmp_bytes()

bool ac_buffer_reader_cmp_bytes ( const ac_buffer_t pBuf,
const uint8_t *  bytes,
size_t  length 
)

Compare buffer with array (does not advance read position)

Parameters
pBufthe buffer to compare from
bytesthe array to compare with
lengththe array length
Returns
Whether the buffer is AT LEAST as long as the array AND the buffer and array have the same content

◆ ac_buffer_reader_cmp()

bool ac_buffer_reader_cmp ( const ac_buffer_t pBuf1,
const ac_buffer_t pBuf2 
)

Compare buffer with array (does not advance read position)

Parameters
pBuf1the buffer to compare from
pBuf2the buffer to compare with
Returns
Whether the buffers have the same length and content