| 26 * POSSIBILITY OF SUCH DAMAGE. |
26 * POSSIBILITY OF SUCH DAMAGE. |
| 27 */ |
27 */ |
| 28 |
28 |
| 29 #ifndef STRINGREPLACE_H |
29 #ifndef STRINGREPLACE_H |
| 30 #define STRINGREPLACE_H |
30 #define STRINGREPLACE_H |
| |
31 |
| |
32 #include "../public/nsapi.h" |
| 31 |
33 |
| 32 #include <cx/string.h> |
34 #include <cx/string.h> |
| 33 #include <cx/buffer.h> |
35 #include <cx/buffer.h> |
| 34 |
36 |
| 35 #ifdef __cplusplus |
37 #ifdef __cplusplus |
| 97 /* |
99 /* |
| 98 * Compiles a string template |
100 * Compiles a string template |
| 99 * |
101 * |
| 100 * a: The allocator to use for building the compiled template |
102 * a: The allocator to use for building the compiled template |
| 101 * tpl: Semplate string |
103 * tpl: Semplate string |
| 102 * delim: Delimiter chars for variable names |
|
| 103 */ |
104 */ |
| 104 StringTemplate string_template_compile(const CxAllocator *a, cxstring tpl, char *delim); |
105 StringTemplate* string_template_compile(const CxAllocator *a, cxstring tpl); |
| 105 |
106 |
| 106 /* |
107 /* |
| 107 * Builds a string using the provided template and writes it to the stream. |
108 * Builds a string using the provided template and writes it to the stream. |
| 108 * |
109 * |
| 109 * tpl: Template |
110 * tpl: Template |
| 111 * varfunc: The callback used for converting |
112 * varfunc: The callback used for converting |
| 112 * STRING_SEGMENT_NUM_PLACEHOLDER and STRING_SEGMENT_VAR_PLACEHOLDER segments |
113 * STRING_SEGMENT_NUM_PLACEHOLDER and STRING_SEGMENT_VAR_PLACEHOLDER segments |
| 113 * userdata: The userdata pointer passed to the strtpl_var_func callback |
114 * userdata: The userdata pointer passed to the strtpl_var_func callback |
| 114 * stream: The stream object to which the resulting string should be written |
115 * stream: The stream object to which the resulting string should be written |
| 115 * writef: Stream write function |
116 * writef: Stream write function |
| |
117 * |
| |
118 * returns the number of written bytes or -1 on error |
| 116 */ |
119 */ |
| 117 int string_template_write_to(StringTemplate *tpl, const CxAllocator *a, strtpl_var_func varfunc, void *userdata, void *stream, cx_write_func writef); |
120 ssize_t string_template_write_to(StringTemplate *tpl, const CxAllocator *a, strtpl_var_func varfunc, void *userdata, void *stream, cx_write_func writef); |
| 118 |
121 |
| 119 /* |
122 /* |
| 120 * Builds a string, using the provided template and allocator |
123 * Builds a string, using the provided template and allocator |
| 121 */ |
124 */ |
| 122 cxmutstr string_template_build_string(StringTemplate *tpl, const CxAllocator *a, strtpl_var_func varfunc, void *userdata); |
125 cxmutstr string_template_build_string(StringTemplate *tpl, const CxAllocator *a, strtpl_var_func varfunc, void *userdata); |
| |
126 |
| |
127 void string_template_free(StringTemplate *tpl); |
| 123 |
128 |
| 124 #ifdef __cplusplus |
129 #ifdef __cplusplus |
| 125 } |
130 } |
| 126 #endif |
131 #endif |
| 127 |
132 |