Add peek buffer to io, hide file/buffer private functions
Implements peek buffer on top of the raw io read (with small storage optimization). Hides implementation details of the file/buffer.
This commit is contained in:
@@ -5,6 +5,7 @@
|
||||
|
||||
#define BH_IO_ERROR 0x0001
|
||||
#define BH_IO_EOF 0x0002
|
||||
#define BH_IO_UNIFIED 0x0004
|
||||
|
||||
#define BH_IO_NONE 0x0000
|
||||
#define BH_IO_READ 0x0001
|
||||
@@ -63,13 +64,30 @@ typedef struct bh_io_s
|
||||
{
|
||||
const bh_io_table_t *table;
|
||||
int flags;
|
||||
struct
|
||||
{
|
||||
char *data;
|
||||
size_t head;
|
||||
size_t tail;
|
||||
size_t size;
|
||||
size_t capacity;
|
||||
} buffer;
|
||||
} bh_io_t;
|
||||
|
||||
bh_io_t *bh_io_new(bh_io_table_t *table,
|
||||
size_t size);
|
||||
void bh_io_destroy_base(bh_io_t *io);
|
||||
|
||||
bh_io_t *bh_io_new(const bh_io_table_t *table,
|
||||
size_t size,
|
||||
int unified);
|
||||
|
||||
void bh_io_free(bh_io_t *io);
|
||||
|
||||
void bh_io_init(bh_io_t *io,
|
||||
const bh_io_table_t *table,
|
||||
int unified);
|
||||
|
||||
void bh_io_destroy(bh_io_t *io);
|
||||
|
||||
int bh_io_open(bh_io_t *io,
|
||||
int mode);
|
||||
|
||||
@@ -81,6 +99,9 @@ size_t bh_io_read(bh_io_t *io,
|
||||
char *data,
|
||||
size_t size);
|
||||
|
||||
size_t bh_io_peek(bh_io_t *io,
|
||||
char *data,
|
||||
size_t size);
|
||||
|
||||
size_t bh_io_write(bh_io_t *io,
|
||||
const char* data,
|
||||
@@ -97,7 +118,6 @@ bh_off_t bh_io_size(bh_io_t *io);
|
||||
|
||||
bh_off_t bh_io_tell(bh_io_t *io);
|
||||
|
||||
|
||||
bh_off_t bh_io_available(bh_io_t *io);
|
||||
|
||||
int bh_io_error(bh_io_t *io);
|
||||
|
||||
Reference in New Issue
Block a user