73# define BJ_STR(literal) (bj_str{ "" literal "", sizeof(literal) - 1 })
75# define BJ_STR(literal) ((struct bj_str){ "" literal "", sizeof(literal) - 1 })
234#define bj_strlen strlen
252#define bj_strcmp strcmp
General-purpose definitions for Banjo API.
uint32_t bj_bool
Boolean type used throughout the Banjo API.
size_t len
Number of bytes in the view.
const char * data
Pointer to the first byte, or NULL for an empty view.
const char * bj_string_cstr(const struct bj_string *string)
Get a NUL-terminated pointer to an owning string.
bj_bool bj_str_eq(struct bj_str left, struct bj_str right)
Compare two views byte by byte.
struct bj_string * bj_create_string(struct bj_str initial)
Create an owning string from a byte view.
struct bj_str bj_string_view(const struct bj_string *string)
Get a borrowed view of an owning string.
struct bj_str bj_str_slice(struct bj_str view, size_t from, size_t to)
Create a view of a byte range within another view.
struct bj_str bj_str_from_cstr(const char *c_string)
Create a view from a NUL-terminated C string.
void bj_destroy_string(struct bj_string *string)
Destroy an owning string and release its memory.
void bj_append_string(struct bj_string *string, struct bj_str tail)
Append bytes to an owning string.
A borrowed view of a sequence of bytes.
An owning string containing valid UTF-8.
UTF-8 string views and owning strings.