diff options
Diffstat (limited to 'libraries/eina/src/lib/eina_binbuf_template_c.x')
-rw-r--r-- | libraries/eina/src/lib/eina_binbuf_template_c.x | 144 |
1 files changed, 144 insertions, 0 deletions
diff --git a/libraries/eina/src/lib/eina_binbuf_template_c.x b/libraries/eina/src/lib/eina_binbuf_template_c.x new file mode 100644 index 0000000..613a715 --- /dev/null +++ b/libraries/eina/src/lib/eina_binbuf_template_c.x | |||
@@ -0,0 +1,144 @@ | |||
1 | /* | ||
2 | * vim:ts=8:sw=3:sts=8:noexpandtab:cino=>5n-3f0^-2{2 | ||
3 | */ | ||
4 | |||
5 | /* This file should be included from files implementing binbuf. | ||
6 | * The including file should define the following macros: | ||
7 | * _STRBUF_DATA_TYPE | ||
8 | * _STRBUF_CSIZE | ||
9 | * _STRBUF_STRUCT_NAME | ||
10 | * _STRBUF_MAGIC | ||
11 | * _STRBUF_MAGIC_STR | ||
12 | * _FUNC_EXPAND | ||
13 | * See how it's done in eina_ustrbuf.c and eina_strbuf.c. This just makes things | ||
14 | * a lot easier since those are essentially the same just with different sizes. | ||
15 | */ | ||
16 | |||
17 | /*============================================================================* | ||
18 | * Global * | ||
19 | *============================================================================*/ | ||
20 | |||
21 | /** | ||
22 | * @internal | ||
23 | * @brief Initialize the strbuf module. | ||
24 | * | ||
25 | * @return #EINA_TRUE on success, #EINA_FALSE on failure. | ||
26 | * | ||
27 | * This function sets up the strbuf module of Eina. It is called by | ||
28 | * eina_init(). | ||
29 | * | ||
30 | * @see eina_init() | ||
31 | */ | ||
32 | Eina_Bool | ||
33 | _FUNC_EXPAND(init)(void) | ||
34 | { | ||
35 | eina_magic_string_static_set(_STRBUF_MAGIC, _STRBUF_MAGIC_STR); | ||
36 | return eina_strbuf_common_init(); | ||
37 | } | ||
38 | |||
39 | /** | ||
40 | * @internal | ||
41 | * @brief Shut down the strbuf module. | ||
42 | * | ||
43 | * @return #EINA_TRUE on success, #EINA_FALSE on failure. | ||
44 | * | ||
45 | * This function shuts down the strbuf module set up by | ||
46 | * eina_ustrbuf_init(). It is called by eina_shutdown(). | ||
47 | * | ||
48 | * @see eina_shutdown() | ||
49 | */ | ||
50 | Eina_Bool | ||
51 | _FUNC_EXPAND(shutdown)(void) | ||
52 | { | ||
53 | return eina_strbuf_common_shutdown(); | ||
54 | } | ||
55 | |||
56 | /*============================================================================* | ||
57 | * API * | ||
58 | *============================================================================*/ | ||
59 | |||
60 | EAPI _STRBUF_STRUCT_NAME * | ||
61 | _FUNC_EXPAND(new)(void) | ||
62 | { | ||
63 | _STRBUF_STRUCT_NAME *buf = eina_strbuf_common_new(_STRBUF_CSIZE); | ||
64 | EINA_MAGIC_SET(buf, _STRBUF_MAGIC); | ||
65 | return buf; | ||
66 | } | ||
67 | |||
68 | EAPI void | ||
69 | _FUNC_EXPAND(free)(_STRBUF_STRUCT_NAME *buf) | ||
70 | { | ||
71 | EINA_MAGIC_CHECK_STRBUF(buf); | ||
72 | EINA_MAGIC_SET(buf, EINA_MAGIC_NONE); | ||
73 | eina_strbuf_common_free(buf); | ||
74 | } | ||
75 | |||
76 | EAPI void | ||
77 | _FUNC_EXPAND(reset)(_STRBUF_STRUCT_NAME *buf) | ||
78 | { | ||
79 | EINA_MAGIC_CHECK_STRBUF(buf); | ||
80 | eina_strbuf_common_reset(_STRBUF_CSIZE, buf); | ||
81 | } | ||
82 | |||
83 | EAPI Eina_Bool | ||
84 | _FUNC_EXPAND(append_length)(_STRBUF_STRUCT_NAME *buf, const _STRBUF_DATA_TYPE *str, size_t length) | ||
85 | { | ||
86 | EINA_MAGIC_CHECK_STRBUF(buf, EINA_FALSE); | ||
87 | return eina_strbuf_common_append_length(_STRBUF_CSIZE, buf, (const void *) str, length); | ||
88 | } | ||
89 | |||
90 | EAPI Eina_Bool | ||
91 | _FUNC_EXPAND(insert_length)(_STRBUF_STRUCT_NAME *buf, const _STRBUF_DATA_TYPE *str, size_t length, size_t pos) | ||
92 | { | ||
93 | EINA_MAGIC_CHECK_STRBUF(buf, EINA_FALSE); | ||
94 | return eina_strbuf_common_insert_length(_STRBUF_CSIZE, buf, (const void *) str, length, pos); | ||
95 | } | ||
96 | |||
97 | EAPI Eina_Bool | ||
98 | _FUNC_EXPAND(append_char)(_STRBUF_STRUCT_NAME *buf, _STRBUF_DATA_TYPE c) | ||
99 | { | ||
100 | EINA_MAGIC_CHECK_STRBUF(buf, EINA_FALSE); | ||
101 | return eina_strbuf_common_append_char(_STRBUF_CSIZE, buf, (const void *) &c); | ||
102 | } | ||
103 | |||
104 | EAPI Eina_Bool | ||
105 | _FUNC_EXPAND(insert_char)(_STRBUF_STRUCT_NAME *buf, _STRBUF_DATA_TYPE c, size_t pos) | ||
106 | { | ||
107 | EINA_MAGIC_CHECK_STRBUF(buf, EINA_FALSE); | ||
108 | return eina_strbuf_common_insert_char(_STRBUF_CSIZE, buf, (const void *) &c, pos); | ||
109 | } | ||
110 | |||
111 | EAPI Eina_Bool | ||
112 | _FUNC_EXPAND(remove)(_STRBUF_STRUCT_NAME *buf, size_t start, size_t end) | ||
113 | { | ||
114 | EINA_MAGIC_CHECK_STRBUF(buf, EINA_FALSE); | ||
115 | return eina_strbuf_common_remove(_STRBUF_CSIZE, buf, start, end); | ||
116 | } | ||
117 | |||
118 | EAPI const _STRBUF_DATA_TYPE * | ||
119 | _FUNC_EXPAND(string_get)(const _STRBUF_STRUCT_NAME *buf) | ||
120 | { | ||
121 | EINA_MAGIC_CHECK_STRBUF(buf, NULL); | ||
122 | return (const _STRBUF_DATA_TYPE *) eina_strbuf_common_string_get(buf); | ||
123 | } | ||
124 | |||
125 | EAPI _STRBUF_DATA_TYPE * | ||
126 | _FUNC_EXPAND(string_steal)(_STRBUF_STRUCT_NAME *buf) | ||
127 | { | ||
128 | EINA_MAGIC_CHECK_STRBUF(buf, NULL); | ||
129 | return (_STRBUF_DATA_TYPE *) eina_strbuf_common_string_steal(_STRBUF_CSIZE, buf); | ||
130 | } | ||
131 | |||
132 | EAPI void | ||
133 | _FUNC_EXPAND(string_free)(_STRBUF_STRUCT_NAME *buf) | ||
134 | { | ||
135 | EINA_MAGIC_CHECK_STRBUF(buf); | ||
136 | eina_strbuf_common_string_free(_STRBUF_CSIZE, buf); | ||
137 | } | ||
138 | |||
139 | EAPI size_t | ||
140 | _FUNC_EXPAND(length_get)(const _STRBUF_STRUCT_NAME *buf) | ||
141 | { | ||
142 | EINA_MAGIC_CHECK_STRBUF(buf, 0); | ||
143 | return eina_strbuf_common_length_get(buf); | ||
144 | } | ||