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

Public Member Functions

 ByteBuffer (uint32_t size=0)
 Create a byte buffer of the given size. More...
 
 ~ByteBuffer ()
 Delete this byte buffer. More...
 
void resize (uint32_t size)
 Set the size of the buffer. More...
 
void push (uint8_t data)
 Add a single byte to this buffer. More...
 
void write (uint8_t *data, uint32_t size)
 Write a block of data to this ByteBuffer. More...
 
uint8_t pop ()
 Remove a byte from this buffer. More...
 
void read (uint8_t *data, uint32_t size)
 Read a block of data from this ByteBuffer into a buffer pointed by 'data'. More...
 
uint32_t size ()
 Return the number bytes in this byte buffer. More...
 
uint32_t free ()
 Return the number of additional bytes this buffer can hold. More...
 
bool full ()
 Check if this byte buffer is full. More...
 
bool empty ()
 Check if this byte buffer is empty. More...
 

Detailed Description

Definition at line 28 of file ByteBuffer.h.

Constructor & Destructor Documentation

◆ ByteBuffer()

ByteBuffer ( uint32_t  size = 0)

Create a byte buffer of the given size.

Parameters
sizeNumber of bytes this buffer can hold

◆ ~ByteBuffer()

~ByteBuffer ( )

Delete this byte buffer.

Member Function Documentation

◆ resize()

void resize ( uint32_t  size)

Set the size of the buffer.

Buffer contents are reset.

Parameters
sizeNew buffer size

◆ push()

void push ( uint8_t  data)

Add a single byte to this buffer.

There must be enough space in the buffer or the behavior is undefined.

Parameters
databyte to add

◆ write()

void write ( uint8_t *  data,
uint32_t  size 
)

Write a block of data to this ByteBuffer.

There must be enough space in the ByteBuffer or the behavior is undefined.

Parameters
dataBlock of data to write
sizeSize of data to write

◆ pop()

uint8_t pop ( )

Remove a byte from this buffer.

Returns
data byte

◆ read()

void read ( uint8_t *  data,
uint32_t  size 
)

Read a block of data from this ByteBuffer into a buffer pointed by 'data'.

There must be enough data in the ByteBuffer or the behavior is undefined.

Parameters
dataBlock of data to read
sizeSize of data to read

◆ size()

uint32_t size ( )

Return the number bytes in this byte buffer.

Returns
Number of used bytes

◆ free()

uint32_t free ( )

Return the number of additional bytes this buffer can hold.

Returns
Number of free bytes

◆ full()

bool full ( )

Check if this byte buffer is full.

Returns
true if full, false otherwise

◆ empty()

bool empty ( )

Check if this byte buffer is empty.

Returns
true if empty, false otherwise