src/ucx/string.h

branch
constsstr
changeset 288
6af5798342e8
parent 276
f1b2146d4805
child 300
d1f814633049
equal deleted inserted replaced
276:f1b2146d4805 288:6af5798342e8
74 74
75 typedef struct { 75 typedef struct {
76 const char *ptr; 76 const char *ptr;
77 size_t length; 77 size_t length;
78 } scstr_t; 78 } scstr_t;
79
79 #ifdef __cplusplus 80 #ifdef __cplusplus
80 } 81 }
81 #endif 82 #endif
82 83
83 84
166 * @param count the total number of specified strings (so at least 1) 167 * @param count the total number of specified strings (so at least 1)
167 * @param string the first string 168 * @param string the first string
168 * @param ... all other strings 169 * @param ... all other strings
169 * @return the cumulated length of all strings 170 * @return the cumulated length of all strings
170 */ 171 */
171 size_t sstrnlen(size_t count, sstr_t string, ...); 172 size_t ucx_strnlen(size_t count, ...);
173
174 #define sstrnlen(count, ...) ucx_strnlen(count, __VA_ARGS__)
172 175
173 /** 176 /**
174 * Concatenates two or more strings. 177 * Concatenates two or more strings.
175 * 178 *
176 * The resulting string will be allocated by standard <code>malloc()</code>. 179 * The resulting string will be allocated by standard <code>malloc()</code>.
183 * @param s1 first string 186 * @param s1 first string
184 * @param s2 second string 187 * @param s2 second string
185 * @param ... all remaining strings 188 * @param ... all remaining strings
186 * @return the concatenated string 189 * @return the concatenated string
187 */ 190 */
188 sstr_t sstrcat(size_t count, sstr_t s1, sstr_t s2, ...); 191 sstr_t ucx_strcat(size_t count, scstr_t s1, ...);
192
193 #define sstrcat(count, s1, ...) ucx_strcat(count, SCSTR(s1), __VA_ARGS__)
189 194
190 /** 195 /**
191 * Concatenates two or more strings using a UcxAllocator. 196 * Concatenates two or more strings using a UcxAllocator.
192 * 197 *
193 * See sstrcat() for details. 198 * See sstrcat() for details.
197 * @param s1 first string 202 * @param s1 first string
198 * @param s2 second string 203 * @param s2 second string
199 * @param ... all remaining strings 204 * @param ... all remaining strings
200 * @return the concatenated string 205 * @return the concatenated string
201 */ 206 */
202 sstr_t sstrcat_a(UcxAllocator *a, size_t count, sstr_t s1, sstr_t s2, ...); 207 sstr_t ucx_strcat_a(UcxAllocator *a, size_t count, scstr_t s1, ...);
203 208
209 #define sstrcat_a(count, s1, ...) ucx_strcat_a(count, SCSTR(s1), __VA_ARGS__)
204 210
205 /** 211 /**
206 * Returns a substring starting at the specified location. 212 * Returns a substring starting at the specified location.
207 * 213 *
208 * <b>Attention:</b> the new string references the same memory area as the 214 * <b>Attention:</b> the new string references the same memory area as the

mercurial