summaryrefslogtreecommitdiff
path: root/src/runtime/c/gu/string.h
blob: e4729239cafb35cb51d7def1cb4499fadfc82017 (plain)
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
#ifndef GU_STRING_H_
#define GU_STRING_H_

#include <gu/bits.h>
#include <gu/in.h>
#include <gu/out.h>

typedef const char* GuString;

GuString
gu_string_copy(GuString string, GuPool* pool);

void
gu_string_write(GuString string, GuOut* out, GuExn* err);

GuString
gu_string_read(size_t len, GuPool* pool, GuIn* in, GuExn* err);

GuString
gu_string_read_latin1(size_t len, GuPool* pool, GuIn* in, GuExn* err);

GuIn*
gu_string_in(GuString string, GuPool* pool);

typedef struct GuStringBuf GuStringBuf;

GuStringBuf*
gu_string_buf(GuPool* pool);

GuOut*
gu_string_buf_out(GuStringBuf* sb);

GuString
gu_string_buf_freeze(GuStringBuf* sb, GuPool* pool);

void
gu_string_buf_flush(GuStringBuf* sb);

GuString
gu_format_string_v(const char* fmt, va_list args, GuPool* pool);

GuString
gu_format_string(GuPool* pool, const char* fmt, ...);

bool
gu_string_to_int(GuString s, int *res);

bool
gu_string_to_double(GuString s, double *res);

bool
gu_string_is_prefix(GuString s1, GuString s2);

#endif // GU_STRING_H_

#if defined(GU_FUN_H_) && !defined(GU_STRING_H_FUN_)
#define GU_STRING_H_FUN_
extern GuEquality gu_string_equality[1];

extern GuOrder gu_string_order[1];
#endif

#if defined(GU_HASH_H_) && !defined(GU_STRING_H_HASH_)
#define GU_STRING_H_HASH_

GuHash
gu_string_hash(GuHash h, GuString s);

extern GuHasher gu_string_hasher[1];
#endif

#if defined(GU_SEQ_H_) && !defined(GU_STRING_H_SEQ_)
#define GU_STRING_H_SEQ_

typedef GuSeq GuStrings;
#endif


#if defined(GU_MAP_H_) && !defined(GU_STRING_H_MAP_)
#define GU_STRING_H_MAP_

typedef GuMap GuStringMap;

#define gu_new_string_map(VAL_T, DEFAULT, POOL)				\
	gu_new_map(GuString, gu_string_hasher, VAL_T, (DEFAULT), (POOL))

#endif