kiba-engine
buffer.h
1 #pragma once
2 
4 #include <kiba/core/string.h>
5 #include <kiba/defines.h>
6 
7 typedef enum format_buffer_mode {
8  FORMAT_BUFFER_READ = 0,
9  FORMAT_BUFFER_WRITE = 1,
10 } format_buffer_mode;
11 
12 typedef struct format_buffer {
13  char *data;
14  usize length;
15  usize head;
16  allocator *alloc;
17  format_buffer_mode mode;
19 
20 b8 format_buffer_create_static(format_buffer *buf, format_buffer_mode mode, char *buffer, usize length);
21 b8 format_buffer_create_dynamic(format_buffer *buf, usize initial_length, allocator *alloc);
22 void format_buffer_destroy(format_buffer *buf);
23 
24 b8 format_buffer_advance(format_buffer *buf);
25 void format_buffer_reset(format_buffer *buf);
26 
27 b8 format_buffer_add_char(format_buffer *buf, char c);
28 b8 format_buffer_add_char_n(format_buffer *buf, char c, usize n);
29 b8 format_buffer_add_chars(format_buffer *buf, const char *chars, usize length);
30 b8 format_buffer_add_string_view(format_buffer *buf, string_view view);
31 string_view string_view_from_format_buffer(const format_buffer *buf);
32 
33 b8 format_buffer_peak_char(const format_buffer *buf, char *c);
34 b8 format_buffer_read_char(format_buffer *buf, char *c);
35 b8 format_buffer_match_char(format_buffer *buf, char c);
36 b8 format_buffer_match_chars(format_buffer *buf, const char *c, usize length);
37 b8 format_buffer_match_string_view(format_buffer *buf, string_view view);
Central header providing allocator functionality.
Custom library for interactions with strings using string views.
Global typedefs and macros.
Central allocator structure.
Definition: allocator.h:87
Non owning views on actual strings.
Definition: string.h:31