#include "mem/mem.c"
#include "str/str.c"
#include <stdio.h>
#include <stdlib.h>
typedef struct Book {
} Book;
static void book_free(Book *b) {
}
static bool book_parse(Book *b,
StrView text) {
return false;
return false;
}
}
return true;
}
int main(void) {
FILE *f = fopen("data/pg2554.txt", "rb");
if (f == NULL) return EXIT_FAILURE;
fclose(f);
if (!ok) return EXIT_FAILURE;
Book book = { 0 };
ok = book_parse(&book,
str_view(&text));
if (!ok) {
book_free(&book);
return EXIT_FAILURE;
}
book_free(&book);
return EXIT_SUCCESS;
}
size_t len
Number of bytes in the view.
const char * str_cstr(const Str *s)
NUL-terminated contents of s, for C APIs such as fopen and puts.
#define SV(lit)
View of a string literal, with its length computed at compile time.
void str_clear(Str *s)
Set the length to zero.
StrView str_view(const Str *s)
Borrow the whole of s.
void str_free(Str *s)
Free the buffer and reset s to the zero state.
bool str_append_file(Str *s, FILE *f)
Append everything left to read from f.
StrView sv_trim(StrView v)
v without leading and trailing ASCII whitespace: space, \t, \n, \v, \f and \r.
bool str_append(Str *s, StrView v)
Append v.
bool sv_starts_with(StrView v, StrView prefix)
True when v begins with prefix.
bool sv_split_next(StrView *rest, StrView sep, StrView *piece)
Cut the piece before sep off rest.
StrView sv_slice(StrView v, size_t from, size_t to)
Bytes from up to but not including to.
Owned, growable byte string.
Non-owning view of bytes; handy for passing slices and literals around.