|
Banjo API 0.0.1
C99 game development API
|
Macros | |
| #define | bj_stream_read_t(stream, type, buffer) |
| #define | bj_stream_skip_t(stream, type) |
Enumerations | |
| enum | bj_seek_origin { BJ_SEEK_BEGIN = 0x00 , BJ_SEEK_CURRENT = 0x01 , BJ_SEEK_END = 0x02 } |
Functions | |
| struct bj_stream * | bj_allocate_stream (void) |
| struct bj_stream * | bj_open_stream_read (const void *data, size_t length) |
| struct bj_stream * | bj_open_stream_file (const char *path, struct bj_error **error) |
| void | bj_close_stream (struct bj_stream *stream) |
| size_t | bj_read_stream (struct bj_stream *stream, void *dest, size_t count) |
| size_t | bj_get_stream_length (struct bj_stream *stream) |
| size_t | bj_seek_stream (struct bj_stream *stream, ptrdiff_t position, enum bj_seek_origin from) |
| size_t | bj_tell_stream (struct bj_stream *stream) |
| #define bj_stream_read_t | ( | stream, | |
| type, | |||
| buffer ) |
Reads data of a specified type from the stream into a buffer.
| stream | Pointer to the stream instance. |
| type | Data type to read. |
| buffer | Pointer to the buffer to store the read data. |
| #define bj_stream_skip_t | ( | stream, | |
| type ) |
Skips reading data of a specified type from the stream.
| stream | Pointer to the stream instance. |
| type | Data type to skip. |
| enum bj_seek_origin |
Position in a bj_stream to use for origin.
| Enumerator | |
|---|---|
| BJ_SEEK_BEGIN | The beginning of the stream. |
| BJ_SEEK_CURRENT | The current position of the stream. |
| BJ_SEEK_END | The end of the stream. |
| struct bj_stream * bj_allocate_stream | ( | void | ) |
| void bj_close_stream | ( | struct bj_stream * | stream | ) |
| size_t bj_get_stream_length | ( | struct bj_stream * | stream | ) |
Get the size of the stream.
| stream | Pointer to the stream instance. |
Creates a new struct bj_stream for reading from a file.
| path | The file path to open |
| error | Optional error object |
The file memory is entirely copied to internal memory buffer.
| struct bj_stream * bj_open_stream_read | ( | const void * | data, |
| size_t | length ) |
| size_t bj_read_stream | ( | struct bj_stream * | stream, |
| void * | dest, | ||
| size_t | count ) |
Reads data from the stream into a destination buffer.
| stream | Pointer to the stream instance. |
| dest | Pointer to the destination buffer. |
| count | Number of bytes to read. |
The function advances the stream position by count bytes. If fewer bytes than count are read, the end of the stream is reached.
This function does not perform any memory bounds checking. It is the caller's responsibility to ensure dest has enough space to hold count bytes.
| size_t bj_seek_stream | ( | struct bj_stream * | stream, |
| ptrdiff_t | position, | ||
| enum bj_seek_origin | from ) |
Seeks to a new position in the stream relative to a specified origin.
| stream | Pointer to the stream instance. |
| position | Offset for the new position. |
| from | Origin relative to which the position should be calculated. |
The function clamps the new position to stay within the valid range of the stream, from 0 to the length of the stream.
| size_t bj_tell_stream | ( | struct bj_stream * | stream | ) |
Returns the current position of the cursor in the stream.
| stream | Pointer to the stream instance. |