Banjo API 0.0.1
Multi-purpose C99 API
Loading...
Searching...
No Matches
stream.h
Go to the documentation of this file.
1
9#pragma once
10
11#include <banjo/api.h>
12#include <banjo/error.h>
13
17typedef struct bj_stream_t bj_stream;
18
22typedef enum {
25 BJ_SEEK_END = 0x02,
27
28
39 void
40);
41
50 const void* p_data,
51 size_t length
52);
53
64 const char* p_path,
65 bj_error** p_error
66);
67
73BANJO_EXPORT void bj_stream_del(
74 bj_stream* p_stream
75);
76
94BANJO_EXPORT size_t bj_stream_read(
95 bj_stream* p_stream,
96 void* p_dest,
97 size_t count
98);
99
106BANJO_EXPORT size_t bj_stream_len(
107 bj_stream* p_stream
108);
109
121BANJO_EXPORT size_t bj_stream_seek(
122 bj_stream* p_stream,
123 ptrdiff_t position,
124 bj_seek_origin from
125);
126
133BANJO_EXPORT size_t bj_stream_tell(
134 bj_stream* p_stream
135);
136
144#define bj_stream_read_t(stream, type, buffer) bj_stream_read(stream, buffer, sizeof(type))
145
152#define bj_stream_skip_t(stream, type) bj_stream_read(stream, 0, sizeof(type))
153
General-purpose definitions for Banjo API.
Recoverable error handling.
Error structure.
Definition error.h:131
size_t bj_stream_len(bj_stream *p_stream)
Get the size of the stream.
bj_seek_origin
Position in a bj_stream to use for origin.
Definition stream.h:22
size_t bj_stream_tell(bj_stream *p_stream)
Returns the current position of the cursor in the stream.
bj_stream * bj_stream_new_read_from_file(const char *p_path, bj_error **p_error)
Creates a new bj_stream for reading from a file.
size_t bj_stream_seek(bj_stream *p_stream, ptrdiff_t position, bj_seek_origin from)
Seeks to a new position in the stream relative to a specified origin.
void bj_stream_del(bj_stream *p_stream)
Deletes a bj_stream object and releases associated memory.
size_t bj_stream_read(bj_stream *p_stream, void *p_dest, size_t count)
Reads data from the stream into a destination buffer.
struct bj_stream_t bj_stream
Structure representing a stream of data.
Definition stream.h:17
bj_stream * bj_stream_new_read(const void *p_data, size_t length)
Creates a new bj_stream for reading from a memory buffer.
bj_stream * bj_stream_alloc(void)
Allocate a new bj_stream object.
@ BJ_SEEK_CURRENT
The current position of the stream.
Definition stream.h:24
@ BJ_SEEK_END
The end of the stream.
Definition stream.h:25
@ BJ_SEEK_BEGIN
The beginning of the stream.
Definition stream.h:23