32 bj_err(
"cannot create the stream");
37 bj_err(
"cannot create the text wrapper");
66 bj_info(
"text remains after the lines: %s", more ?
"yes" :
"no");
72 bj_info(
"a character to peek: %s", seen ?
"yes" :
"no");
struct bj_stream bj_stream
uint32_t bj_bool
Boolean type used throughout the Banjo API.
struct bj_text_wrapper bj_text_wrapper
#define bj_info(...)
Log a message using the BJ_LOG_INFO level.
#define bj_err(...)
Log a message using the BJ_LOG_ERROR level.
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.
size_t bj_stream_length(struct bj_stream *stream)
Return the total size of the stream, in bytes.
void bj_destroy_stream(struct bj_stream *stream)
Destroy a stream and release its memory.
struct bj_stream * bj_create_stream(void)
Create an empty stream in memory, which reads and writes, and grows as it is written.
@ BJ_SEEK_BEGIN
The beginning of the stream.
size_t len
Number of bytes in the view.
const char * data
Pointer to the first byte, or NULL for an empty view.
#define BJ_STR(literal)
Create a view of a string literal.
A borrowed view of a sequence of bytes.
bj_bool bj_read_text_wrapper_line(struct bj_text_wrapper *wrapper, struct bj_str *line, size_t max_bytes)
Reads one line, without its terminator.
struct bj_text_wrapper * bj_create_text_wrapper(struct bj_stream *stream)
Create a text wrapper over a stream.
enum bj_stream_status bj_text_wrapper_status(const struct bj_text_wrapper *wrapper)
Why the last read or write of the wrapper fell short.
void bj_set_text_wrapper_line_ending(struct bj_text_wrapper *wrapper, enum bj_text_line_ending ending)
Sets the line ending the wrapper's line writes append.
bj_bool bj_flush_text_wrapper(struct bj_text_wrapper *wrapper)
Pushes the wrapper's text into the stream, then relays the stream's own flush.
bj_bool bj_read_text_wrapper(struct bj_text_wrapper *wrapper, struct bj_str *chunk, size_t max_bytes)
Reads a chunk of text of up to max_bytes bytes.
bj_bool bj_write_text_wrapper_line(struct bj_text_wrapper *wrapper, struct bj_str text)
Writes text, then the wrapper's line ending.
void bj_destroy_text_wrapper(struct bj_text_wrapper *wrapper)
Destroy a text wrapper and release its memory.
bj_bool bj_peek_text_wrapper(struct bj_text_wrapper *wrapper, struct bj_str *character)
Previews the next character without consuming it.
@ BJ_TEXT_LINE_ENDING_CRLF
A carriage return, then a line feed.
@ BJ_TEXT_LINE_ENDING_LF
A line feed.
Logging utility functions.
All memory-related functions, including custom allocators.
Header file for struct bj_stream struct and related functions.
UTF-8 string views and owning strings.
Header file for struct bj_text_wrapper and related functions.