53#ifndef BJ_TEXT_WRAPPER_H
54#define BJ_TEXT_WRAPPER_H
General-purpose definitions for Banjo API.
struct bj_stream bj_stream
uint32_t bj_bool
Boolean type used throughout the Banjo API.
struct bj_text_wrapper bj_text_wrapper
bj_stream_status
Why the last read or write of a stream fell short.
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.
void bj_clear_text_wrapper_status(struct bj_text_wrapper *wrapper)
Sets the wrapper's status back to BJ_STREAM_STATUS_OK.
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(struct bj_text_wrapper *wrapper, struct bj_str text)
Writes text, sanitizing malformed bytes.
bj_text_line_ending
The line ending a wrapper's line writes append.
enum bj_text_line_ending bj_text_wrapper_line_ending(const struct bj_text_wrapper *wrapper)
The line ending the wrapper's line writes append.
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_NATIVE
The platform's convention, resolved when set.
@ BJ_TEXT_LINE_ENDING_CR
A carriage return.
@ BJ_TEXT_LINE_ENDING_LF
A line feed.
Header file for struct bj_stream struct and related functions.
UTF-8 string views and owning strings.