aboutsummaryrefslogtreecommitdiff
path: root/vendor/librune/include/builder.h
blob: 271fcbf5c33361dcec118919169b6c60d68fefde (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#ifndef RUNE_BUILDER_H
#define RUNE_BUILDER_H

#define _RUNE_NEEDS_U8VIEW 1
#include "internal/types.h" /* IWYU pragma: export */

struct u8str {
	char8_t *p;
	size_t len, cap;
};

struct u8str *u8strinit(struct u8str *, size_t);
struct u8str *u8strgrow(struct u8str *, size_t);
struct u8str *u8strfit(struct u8str *);
void u8strfree(struct u8str);

struct u8str *u8strpushr(struct u8str *, rune);
struct u8str *u8strpushstr(struct u8str *, const char *);
struct u8str *u8strpushu8(struct u8str *, struct u8view);

#define u8strpush(b, x) \
	_Generic((x), \
	    char: u8strpushr, \
	    int: u8strpushr, \
	    rune: u8strpushr, \
	    char *: u8strpushstr, \
	    struct u8view: u8strpushu8)((b), (x))

#endif /* !RUNE_BUILDER_H */