2 * vim:ts=8:sw=3:sts=8:noexpandtab:cino=>5n-3f0^-2{2
5 /* This file should be included from files implementing strbuf.
6 The including file should define the following macros:
10 * _STRBUF_STRLEN_FUNC(x)
11 * _STRBUF_STRESCAPE_FUNC(x)
12 * _STRBUF_STRSTR_FUNC(x, y)
15 * See how it's done in eina_ustrbuf.c and eina_strbuf.c. This just makes things
16 * a lot easier since those are essentially the same just with different sizes.
19 #include "eina_binbuf_template_c.x"
21 /*============================================================================*
23 *============================================================================*/
25 EAPI _STRBUF_STRUCT_NAME *
26 _FUNC_EXPAND(manage_new)(_STRBUF_DATA_TYPE *str)
28 _STRBUF_STRUCT_NAME *buf = eina_strbuf_common_manage_new(_STRBUF_CSIZE,
29 (void *) str, _STRBUF_STRLEN_FUNC(str));
30 EINA_MAGIC_SET(buf, _STRBUF_MAGIC);
35 _FUNC_EXPAND(append)(_STRBUF_STRUCT_NAME *buf, const _STRBUF_DATA_TYPE *str)
37 EINA_MAGIC_CHECK_STRBUF(buf, EINA_FALSE);
38 return eina_strbuf_common_append(_STRBUF_CSIZE, buf, (const void *) str, _STRBUF_STRLEN_FUNC(str));
42 _FUNC_EXPAND(append_escaped)(_STRBUF_STRUCT_NAME *buf, const _STRBUF_DATA_TYPE *str)
44 _STRBUF_DATA_TYPE *esc;
47 EINA_MAGIC_CHECK_STRBUF(buf, EINA_FALSE);
48 esc = _STRBUF_STRESCAPE_FUNC(str);
50 return _FUNC_EXPAND(append)(buf, str);
52 ret = _FUNC_EXPAND(append)(buf, esc);
60 _FUNC_EXPAND(append_n)(_STRBUF_STRUCT_NAME *buf, const _STRBUF_DATA_TYPE *str, size_t maxlen)
62 EINA_MAGIC_CHECK_STRBUF(buf, EINA_FALSE);
63 return eina_strbuf_common_append_n(_STRBUF_CSIZE, buf, (const void *) str, _STRBUF_STRLEN_FUNC(str), maxlen);
67 _FUNC_EXPAND(insert)(_STRBUF_STRUCT_NAME *buf, const _STRBUF_DATA_TYPE *str, size_t pos)
69 EINA_MAGIC_CHECK_STRBUF(buf, EINA_FALSE);
70 return eina_strbuf_common_insert(_STRBUF_CSIZE, buf, (const void *) str, _STRBUF_STRLEN_FUNC(str), pos);
74 _FUNC_EXPAND(insert_escaped)(_STRBUF_STRUCT_NAME *buf, const _STRBUF_DATA_TYPE *str, size_t pos)
76 _STRBUF_DATA_TYPE *esc;
78 EINA_MAGIC_CHECK_STRBUF(buf, EINA_FALSE);
80 esc = _STRBUF_STRESCAPE_FUNC(str);
82 return _FUNC_EXPAND(insert)(buf, str, pos);
84 ret = _FUNC_EXPAND(insert)(buf, esc, pos);
92 _FUNC_EXPAND(insert_n)(_STRBUF_STRUCT_NAME *buf, const _STRBUF_DATA_TYPE *str, size_t maxlen, size_t pos)
94 EINA_MAGIC_CHECK_STRBUF(buf, EINA_FALSE);
95 return eina_strbuf_common_insert_n(_STRBUF_CSIZE, buf, (const void *) str, _STRBUF_STRLEN_FUNC(str), maxlen, pos);