|
piojo_stream_t * | piojo_stream_alloc (void) |
|
piojo_stream_t * | piojo_stream_alloc_cb (piojo_alloc_if allocator) |
|
piojo_stream_t * | piojo_stream_copy (const piojo_stream_t *stream) |
|
void | piojo_stream_free (const piojo_stream_t *stream) |
|
void | piojo_stream_clear (piojo_stream_t *stream) |
|
void | piojo_stream_resize (size_t bytecnt, piojo_stream_t *stream) |
|
size_t | piojo_stream_size (const piojo_stream_t *stream) |
|
void | piojo_stream_concat (const piojo_stream_t *stream, piojo_stream_t *to) |
|
uint64_t | piojo_stream_readu64 (piojo_stream_t *stream) |
|
void | piojo_stream_writeu64 (uint64_t val, piojo_stream_t *stream) |
|
int64_t | piojo_stream_readi64 (piojo_stream_t *stream) |
|
void | piojo_stream_writei64 (int64_t val, piojo_stream_t *stream) |
|
uint32_t | piojo_stream_readu32 (piojo_stream_t *stream) |
|
void | piojo_stream_writeu32 (uint32_t val, piojo_stream_t *stream) |
|
int32_t | piojo_stream_readi32 (piojo_stream_t *stream) |
|
void | piojo_stream_writei32 (int32_t val, piojo_stream_t *stream) |
|
uint16_t | piojo_stream_readu16 (piojo_stream_t *stream) |
|
void | piojo_stream_writeu16 (uint16_t val, piojo_stream_t *stream) |
|
int16_t | piojo_stream_readi16 (piojo_stream_t *stream) |
|
void | piojo_stream_writei16 (int16_t val, piojo_stream_t *stream) |
|
uint8_t | piojo_stream_readu8 (piojo_stream_t *stream) |
|
void | piojo_stream_writeu8 (uint8_t val, piojo_stream_t *stream) |
|
int8_t | piojo_stream_readi8 (piojo_stream_t *stream) |
|
void | piojo_stream_writei8 (int8_t val, piojo_stream_t *stream) |
|
uint32_t | piojo_stream_readstr (uint8_t **str, piojo_stream_t *stream) |
|
void | piojo_stream_writestr (const uint8_t *str, uint32_t len, piojo_stream_t *stream) |
|
bool | piojo_stream_readbool (piojo_stream_t *stream) |
|
void | piojo_stream_writebool (bool val, piojo_stream_t *stream) |
|
const uint8_t * | piojo_stream_data (const piojo_stream_t *stream) |
|
Piojo Stream implementation for binary data. Assumes two's complement representation for signed numbers.
- Warning
- Reads and writes shouldn't be mixed (unless stream is new/clear).
piojo_stream_t* piojo_stream_alloc |
( |
void |
| ) |
|
Allocates a new stream. Uses default allocator.
- Returns
- New stream.
Allocates a new stream.
- Parameters
-
[in] | allocator | Allocator to be used. |
- Returns
- New stream.
void piojo_stream_clear |
( |
piojo_stream_t * |
stream | ) |
|
Clears stream write/read indices.
- Parameters
-
[out] | stream | Stream being cleared. |
void piojo_stream_concat |
( |
const piojo_stream_t * |
stream, |
|
|
piojo_stream_t * |
to |
|
) |
| |
Concatenates two streams.
- Parameters
-
[in] | stream | Source stream. |
[out] | to | Destination stream. |
piojo_stream_t* piojo_stream_copy |
( |
const piojo_stream_t * |
stream | ) |
|
Copies stream.
- Parameters
-
[in] | stream | Stream being copied. |
- Returns
- New stream.
const uint8_t* piojo_stream_data |
( |
const piojo_stream_t * |
stream | ) |
|
Returns pointer to stream data.
- Parameters
-
- Returns
- Pointer to stream data.
void piojo_stream_free |
( |
const piojo_stream_t * |
stream | ) |
|
Frees stream.
- Parameters
-
[in] | stream | Stream being freed. |
bool piojo_stream_readbool |
( |
piojo_stream_t * |
stream | ) |
|
Reads a bool.
- Parameters
-
[in] | stream | Stream being read. |
- Returns
- Value read.
int16_t piojo_stream_readi16 |
( |
piojo_stream_t * |
stream | ) |
|
Reads a int16_t.
- Parameters
-
[in] | stream | Stream being read. |
- Returns
- Value read.
int32_t piojo_stream_readi32 |
( |
piojo_stream_t * |
stream | ) |
|
Reads a int32_t.
- Parameters
-
[in] | stream | Stream being read. |
- Returns
- Value read.
int64_t piojo_stream_readi64 |
( |
piojo_stream_t * |
stream | ) |
|
Reads a int64_t.
- Parameters
-
[in] | stream | Stream being read. |
- Returns
- Value read.
int8_t piojo_stream_readi8 |
( |
piojo_stream_t * |
stream | ) |
|
Reads a int8_t.
- Parameters
-
[in] | stream | Stream being read. |
- Returns
- Value read.
uint32_t piojo_stream_readstr |
( |
uint8_t ** |
str, |
|
|
piojo_stream_t * |
stream |
|
) |
| |
Reads a string of bytes.
- Parameters
-
[out] | str | Pointer to string stream. |
[out] | stream | Stream being read. |
- Returns
- Number of bytes read.
uint16_t piojo_stream_readu16 |
( |
piojo_stream_t * |
stream | ) |
|
Reads a uint16_t.
- Parameters
-
[in] | stream | Stream being read. |
- Returns
- Value read.
uint32_t piojo_stream_readu32 |
( |
piojo_stream_t * |
stream | ) |
|
Reads a uint32_t.
- Parameters
-
[in] | stream | Stream being read. |
- Returns
- Value read.
uint64_t piojo_stream_readu64 |
( |
piojo_stream_t * |
stream | ) |
|
Reads a uint64_t.
- Parameters
-
[in] | stream | Stream being read. |
- Returns
- Value read.
uint8_t piojo_stream_readu8 |
( |
piojo_stream_t * |
stream | ) |
|
Reads a uint8_t.
- Parameters
-
[in] | stream | Stream being read. |
- Returns
- Value read.
void piojo_stream_resize |
( |
size_t |
bytecnt, |
|
|
piojo_stream_t * |
stream |
|
) |
| |
Expands or shrinks allocated memory for bytecnt bytes.
- Parameters
-
[in] | bytecnt | Must be equal or greater than the current size. |
[out] | stream | Stream being modified. |
size_t piojo_stream_size |
( |
const piojo_stream_t * |
stream | ) |
|
Returns number of bytes written in stream.
- Parameters
-
- Returns
- Number of bytes written in stream.
void piojo_stream_writebool |
( |
bool |
val, |
|
|
piojo_stream_t * |
stream |
|
) |
| |
Writes a bool.
- Parameters
-
[in] | val | Value. |
[out] | stream | Stream being written. |
void piojo_stream_writei16 |
( |
int16_t |
val, |
|
|
piojo_stream_t * |
stream |
|
) |
| |
Writes a int16_t.
- Parameters
-
[in] | val | Value. |
[out] | stream | Stream being written. |
void piojo_stream_writei32 |
( |
int32_t |
val, |
|
|
piojo_stream_t * |
stream |
|
) |
| |
Writes a int32_t.
- Parameters
-
[in] | val | Value. |
[out] | stream | Stream being written. |
void piojo_stream_writei64 |
( |
int64_t |
val, |
|
|
piojo_stream_t * |
stream |
|
) |
| |
Writes a int64_t.
- Parameters
-
[in] | val | Value. |
[out] | stream | Stream being written. |
void piojo_stream_writei8 |
( |
int8_t |
val, |
|
|
piojo_stream_t * |
stream |
|
) |
| |
Writes a int8_t.
- Parameters
-
[in] | val | Value. |
[out] | stream | Stream being written. |
void piojo_stream_writestr |
( |
const uint8_t * |
str, |
|
|
uint32_t |
len, |
|
|
piojo_stream_t * |
stream |
|
) |
| |
Writes a string of bytes.
- Parameters
-
[in] | str | String of bytes. |
[in] | len | Number of bytes. |
[out] | stream | Stream being written. |
void piojo_stream_writeu16 |
( |
uint16_t |
val, |
|
|
piojo_stream_t * |
stream |
|
) |
| |
Writes a uint16_t.
- Parameters
-
[in] | val | Value. |
[out] | stream | Stream being written. |
void piojo_stream_writeu32 |
( |
uint32_t |
val, |
|
|
piojo_stream_t * |
stream |
|
) |
| |
Writes a uint32_t.
- Parameters
-
[in] | val | Value. |
[out] | stream | Stream being written. |
void piojo_stream_writeu64 |
( |
uint64_t |
val, |
|
|
piojo_stream_t * |
stream |
|
) |
| |
Writes a uint64_t.
- Parameters
-
[in] | val | Value. |
[out] | stream | Stream being written. |
void piojo_stream_writeu8 |
( |
uint8_t |
val, |
|
|
piojo_stream_t * |
stream |
|
) |
| |
Writes a uint8_t.
- Parameters
-
[in] | val | Value. |
[out] | stream | Stream being written. |
const size_t piojo_stream_sizeof |