aboutsummaryrefslogtreecommitdiff
path: root/vendor/librune/include/builder.h
blob: b711f977097c5b0b4d80ade0bac4062efb657de5 (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
30
31
#ifndef RUNE_BUILDER_H
#define RUNE_BUILDER_H

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

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

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

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

#if __STDC_VERSION__ >= 201112L
#	define u8strpush(b, x) \
		_Generic((x), \
		    char: u8strpushr, \
		    int: u8strpushr, \
		    rune: u8strpushr, \
		    char *: u8strpushstr, \
		    struct u8view: u8strpushu8)((b), (x))
#endif

#endif /* !RUNE_BUILDER_H */