1.1 --- a/src/ucx/string.h Wed May 16 14:02:59 2018 +0200 1.2 +++ b/src/ucx/string.h Wed May 16 18:56:44 2018 +0200 1.3 @@ -256,9 +256,6 @@ 1.4 /** 1.5 * Returns the cumulated length of all specified strings. 1.6 * 1.7 - * You may arbitrarily mix up mutable (<code>sstr_t</code>) and immutable 1.8 - * (<code>scstr_t</code>) strings. 1.9 - * 1.10 * <b>Attention:</b> if the count argument does not match the count of the 1.11 * specified strings, the behavior is undefined. 1.12 * 1.13 @@ -266,16 +263,16 @@ 1.14 * @param ... all strings 1.15 * @return the cumulated length of all strings 1.16 */ 1.17 -size_t ucx_strnlen(size_t count, ...); 1.18 +size_t scstrnlen(size_t count, ...); 1.19 1.20 /** 1.21 - * Alias for ucx_strnlen(). 1.22 + * Alias for scstrnlen() which automatically casts the arguments. 1.23 * 1.24 * @param count the total number of specified strings (so at least 1) 1.25 * @param ... all strings 1.26 * @return the cumulated length of all strings 1.27 */ 1.28 -#define sstrnlen(count, ...) ucx_strnlen(count, __VA_ARGS__) 1.29 +#define sstrnlen(count, ...) scstrnlen(count, __VA_ARGS__) 1.30 1.31 /** 1.32 * Concatenates two or more strings. 1.33 @@ -291,22 +288,22 @@ 1.34 * @param ... all remaining strings 1.35 * @return the concatenated string 1.36 */ 1.37 -sstr_t ucx_strcat(size_t count, scstr_t s1, ...); 1.38 +sstr_t scstrcat(size_t count, scstr_t s1, ...); 1.39 1.40 /** 1.41 - * Alias for ucx_strcat() which automatically casts the first string. 1.42 + * Alias for scstrcat() which automatically casts the arguments. 1.43 * 1.44 * @param count the total number of strings to concatenate 1.45 * @param s1 first string 1.46 * @param ... all remaining strings 1.47 * @return the concatenated string 1.48 */ 1.49 -#define sstrcat(count, s1, ...) ucx_strcat(count, SCSTR(s1), __VA_ARGS__) 1.50 +#define sstrcat(count, s1, ...) scstrcat(count, SCSTR(s1), __VA_ARGS__) 1.51 1.52 /** 1.53 * Concatenates two or more strings using a UcxAllocator. 1.54 * 1.55 - * See sstrcat() for details. 1.56 + * See scstrcat() for details. 1.57 * 1.58 * @param a the allocator to use 1.59 * @param count the total number of strings to concatenate 1.60 @@ -314,10 +311,10 @@ 1.61 * @param ... all remaining strings 1.62 * @return the concatenated string 1.63 */ 1.64 -sstr_t ucx_strcat_a(UcxAllocator *a, size_t count, scstr_t s1, ...); 1.65 +sstr_t scstrcat_a(UcxAllocator *a, size_t count, scstr_t s1, ...); 1.66 1.67 /** 1.68 - * Alias for ucx_strcat_a() which automatically casts the first string. 1.69 + * Alias for scstrcat_a() which automatically casts the arguments. 1.70 * 1.71 * See sstrcat() for details. 1.72 * 1.73 @@ -328,7 +325,7 @@ 1.74 * @return the concatenated string 1.75 */ 1.76 #define sstrcat_a(a, count, s1, ...) \ 1.77 - ucx_strcat_a(a, count, SCSTR(s1), __VA_ARGS__) 1.78 + scstrcat_a(a, count, SCSTR(s1), __VA_ARGS__) 1.79 1.80 /** 1.81 * Returns a substring starting at the specified location. 1.82 @@ -471,10 +468,10 @@ 1.83 * <code>match</code>, or an empty string, if the sequence is not 1.84 * present in <code>string</code> 1.85 */ 1.86 -sstr_t ucx_sstrstr(sstr_t string, scstr_t match); 1.87 +sstr_t scstrsstr(sstr_t string, scstr_t match); 1.88 1.89 /** 1.90 - * Alias for ucx_sstrstr() which automatically casts the match string. 1.91 + * Alias for scstrsstr() which automatically casts the match string. 1.92 * 1.93 * @param string the string to be scanned 1.94 * @param match string containing the sequence of characters to match 1.95 @@ -482,7 +479,7 @@ 1.96 * <code>match</code>, or an empty string, if the sequence is not 1.97 * present in <code>string</code> 1.98 */ 1.99 -#define sstrstr(string, match) ucx_sstrstr(string, SCSTR(match)) 1.100 +#define sstrstr(string, match) scstrsstr(string, SCSTR(match)) 1.101 1.102 /** 1.103 * Returns an immutable substring starting at the location of the 1.104 @@ -499,10 +496,10 @@ 1.105 * <code>match</code>, or an empty string, if the sequence is not 1.106 * present in <code>string</code> 1.107 */ 1.108 -scstr_t ucx_scstrstr(scstr_t string, scstr_t match); 1.109 +scstr_t scstrscstr(scstr_t string, scstr_t match); 1.110 1.111 /** 1.112 - * Alias for ucx_scstrstr() which automatically casts the match string. 1.113 + * Alias for scstrscstr() which automatically casts the match string. 1.114 * 1.115 * @param string the string to be scanned 1.116 * @param match string containing the sequence of characters to match 1.117 @@ -510,7 +507,7 @@ 1.118 * <code>match</code>, or an empty string, if the sequence is not 1.119 * present in <code>string</code> 1.120 */ 1.121 -#define scstrstr(string, match) ucx_scstrstr(string, SCSTR(match)) 1.122 +#define sstrscstr(string, match) scstrscstr(string, SCSTR(match)) 1.123 1.124 /** 1.125 * Splits a string into parts by using a delimiter string. 1.126 @@ -557,12 +554,12 @@ 1.127 * @return a sstr_t array containing the split strings or 1.128 * <code>NULL</code> on error 1.129 * 1.130 - * @see ucx_strsplit_a() 1.131 + * @see scstrsplit_a() 1.132 */ 1.133 -sstr_t* ucx_strsplit(scstr_t string, scstr_t delim, ssize_t *count); 1.134 +sstr_t* scstrsplit(scstr_t string, scstr_t delim, ssize_t *count); 1.135 1.136 /** 1.137 - * Alias for ucx_strsplit() which automatically casts the arguments. 1.138 + * Alias for scstrsplit() which automatically casts the arguments. 1.139 * 1.140 * @param string the string to split 1.141 * @param delim the delimiter string 1.142 @@ -574,12 +571,12 @@ 1.143 * @see sstrsplit_a() 1.144 */ 1.145 #define sstrsplit(string, delim, count) \ 1.146 - ucx_strsplit(SCSTR(string), SCSTR(delim), count) 1.147 + scstrsplit(SCSTR(string), SCSTR(delim), count) 1.148 1.149 /** 1.150 - * Performing sstrsplit() using a UcxAllocator. 1.151 + * Performing scstrsplit() using a UcxAllocator. 1.152 * 1.153 - * <i>Read the description of sstrsplit() for details.</i> 1.154 + * <i>Read the description of scstrsplit() for details.</i> 1.155 * 1.156 * The memory for the sstr_t.ptr pointers of the array items and the memory for 1.157 * the sstr_t array itself are allocated by using the UcxAllocator.malloc() 1.158 @@ -596,13 +593,13 @@ 1.159 * @return a sstr_t array containing the split strings or 1.160 * <code>NULL</code> on error 1.161 * 1.162 - * @see ucx_strsplit() 1.163 + * @see scstrsplit() 1.164 */ 1.165 -sstr_t* ucx_strsplit_a(UcxAllocator *allocator, scstr_t string, scstr_t delim, 1.166 +sstr_t* scstrsplit_a(UcxAllocator *allocator, scstr_t string, scstr_t delim, 1.167 ssize_t *count); 1.168 1.169 /** 1.170 - * Alias for ucx_strsplit_a() which automatically casts the arguments. 1.171 + * Alias for scstrsplit_a() which automatically casts the arguments. 1.172 * 1.173 * @param allocator the UcxAllocator used for allocating memory 1.174 * @param string the string to split 1.175 @@ -615,7 +612,7 @@ 1.176 * @see sstrsplit() 1.177 */ 1.178 #define sstrsplit_a(allocator, string, delim, count) \ 1.179 - ucx_strsplit_a(allocator, SCSTR(string), SCSTR(delim, count)) 1.180 + scstrsplit_a(allocator, SCSTR(string), SCSTR(delim, count)) 1.181 1.182 /** 1.183 * Compares two UCX strings with standard <code>memcmp()</code>. 1.184 @@ -629,10 +626,10 @@ 1.185 * length of s1 is greater than the length of s2 or the result of 1.186 * <code>memcmp()</code> otherwise (i.e. 0 if the strings match) 1.187 */ 1.188 -int ucx_strcmp(scstr_t s1, scstr_t s2); 1.189 +int scstrcmp(scstr_t s1, scstr_t s2); 1.190 1.191 /** 1.192 - * Alias for ucx_strcmp() which automatically casts its arguments. 1.193 + * Alias for scstrcmp() which automatically casts its arguments. 1.194 * 1.195 * @param s1 the first string 1.196 * @param s2 the second string 1.197 @@ -640,12 +637,12 @@ 1.198 * length of s1 is greater than the length of s2 or the result of 1.199 * <code>memcmp()</code> otherwise (i.e. 0 if the strings match) 1.200 */ 1.201 -#define sstrcmp(s1, s2) ucx_strcmp(SCSTR(s1), SCSTR(s2)) 1.202 +#define sstrcmp(s1, s2) scstrcmp(SCSTR(s1), SCSTR(s2)) 1.203 1.204 /** 1.205 * Compares two UCX strings ignoring the case. 1.206 * 1.207 - * At first it compares the sstr_t.length attribute of the two strings. If and 1.208 + * At first it compares the scstr_t.length attribute of the two strings. If and 1.209 * only if the lengths match, both strings are compared char by char ignoring 1.210 * the case. 1.211 * 1.212 @@ -655,10 +652,10 @@ 1.213 * length of s1 is greater than the length of s2 or the result of the platform 1.214 * specific string comparison function ignoring the case. 1.215 */ 1.216 -int ucx_strcasecmp(scstr_t s1, scstr_t s2); 1.217 +int scstrcasecmp(scstr_t s1, scstr_t s2); 1.218 1.219 /** 1.220 - * Alias for ucx_strcasecmp() which automatically casts the arguments. 1.221 + * Alias for scstrcasecmp() which automatically casts the arguments. 1.222 * 1.223 * @param s1 the first string 1.224 * @param s2 the second string 1.225 @@ -666,7 +663,7 @@ 1.226 * length of s1 is greater than the length of s2 or the result of the platform 1.227 * specific string comparison function ignoring the case. 1.228 */ 1.229 -#define sstrcasecmp(s1, s2) ucx_strcasecmp(SCSTR(s1), SCSTR(s2)) 1.230 +#define sstrcasecmp(s1, s2) scstrcasecmp(SCSTR(s1), SCSTR(s2)) 1.231 1.232 /** 1.233 * Creates a duplicate of the specified string. 1.234 @@ -680,26 +677,26 @@ 1.235 * 1.236 * @param string the string to duplicate 1.237 * @return a duplicate of the string 1.238 - * @see ucx_strdup_a() 1.239 + * @see scstrdup_a() 1.240 */ 1.241 -sstr_t ucx_strdup(scstr_t string); 1.242 +sstr_t scstrdup(scstr_t string); 1.243 1.244 /** 1.245 - * Alias for ucx_strdup() which automatically casts the argument. 1.246 + * Alias for scstrdup() which automatically casts the argument. 1.247 * 1.248 * @param string the string to duplicate 1.249 * @return a duplicate of the string 1.250 * @see sstrdup_a() 1.251 */ 1.252 -#define sstrdup(string) ucx_strdup(SCSTR(string)) 1.253 +#define sstrdup(string) scstrdup(SCSTR(string)) 1.254 1.255 /** 1.256 * Creates a duplicate of the specified string using a UcxAllocator. 1.257 * 1.258 * The new sstr_t will contain a copy allocated by the allocators 1.259 - * ucx_allocator_malloc function. So it is implementation depended, whether the 1.260 + * UcxAllocator.malloc() function. So it is implementation depended, whether the 1.261 * returned sstr_t.ptr pointer must be passed to the allocators 1.262 - * ucx_allocator_free function manually. 1.263 + * UcxAllocator.free() function manually. 1.264 * 1.265 * The sstr_t.ptr of the return value will <i>always</i> be <code>NULL</code>- 1.266 * terminated and mutable, regardless of the argument. 1.267 @@ -707,19 +704,19 @@ 1.268 * @param allocator a valid instance of a UcxAllocator 1.269 * @param string the string to duplicate 1.270 * @return a duplicate of the string 1.271 - * @see ucx_strdup() 1.272 + * @see scstrdup() 1.273 */ 1.274 -sstr_t ucx_strdup_a(UcxAllocator *allocator, scstr_t string); 1.275 +sstr_t scstrdup_a(UcxAllocator *allocator, scstr_t string); 1.276 1.277 /** 1.278 - * Alias for ucx_strdup_a() which automatically casts the argument. 1.279 + * Alias for scstrdup_a() which automatically casts the argument. 1.280 * 1.281 * @param allocator a valid instance of a UcxAllocator 1.282 * @param string the string to duplicate 1.283 * @return a duplicate of the string 1.284 - * @see ucx_strdup() 1.285 + * @see scstrdup() 1.286 */ 1.287 -#define sstrdup_a(allocator, string) ucx_strdup_a(allocator, SCSTR(string)) 1.288 +#define sstrdup_a(allocator, string) scstrdup_a(allocator, SCSTR(string)) 1.289 1.290 1.291 /** 1.292 @@ -766,16 +763,16 @@ 1.293 * @param prefix the prefix the string should have 1.294 * @return 1, if and only if the string has the specified prefix, 0 otherwise 1.295 */ 1.296 -int ucx_strprefix(scstr_t string, scstr_t prefix); 1.297 +int scstrprefix(scstr_t string, scstr_t prefix); 1.298 1.299 /** 1.300 - * Alias for ucx_strprefix() which automatically casts the arguments. 1.301 + * Alias for scstrprefix() which automatically casts the arguments. 1.302 * 1.303 * @param string the string to check 1.304 * @param prefix the prefix the string should have 1.305 * @return 1, if and only if the string has the specified prefix, 0 otherwise 1.306 */ 1.307 -#define sstrprefix(string, prefix) ucx_strprefix(SCSTR(string), SCSTR(prefix)) 1.308 +#define sstrprefix(string, prefix) scstrprefix(SCSTR(string), SCSTR(prefix)) 1.309 1.310 /** 1.311 * Checks, if a string has a specific suffix. 1.312 @@ -783,16 +780,16 @@ 1.313 * @param suffix the suffix the string should have 1.314 * @return 1, if and only if the string has the specified suffix, 0 otherwise 1.315 */ 1.316 -int ucx_strsuffix(scstr_t string, scstr_t suffix); 1.317 +int scstrsuffix(scstr_t string, scstr_t suffix); 1.318 1.319 /** 1.320 - * Alias for ucx_strsuffix() which automatically casts the arguments. 1.321 + * Alias for scstrsuffix() which automatically casts the arguments. 1.322 * 1.323 * @param string the string to check 1.324 * @param suffix the suffix the string should have 1.325 * @return 1, if and only if the string has the specified suffix, 0 otherwise 1.326 */ 1.327 -#define sstrsuffix(string, suffix) ucx_strsuffix(SCSTR(string), SCSTR(suffix)) 1.328 +#define sstrsuffix(string, suffix) scstrsuffix(SCSTR(string), SCSTR(suffix)) 1.329 1.330 /** 1.331 * Returns a lower case version of a string. 1.332 @@ -804,15 +801,15 @@ 1.333 * @return the resulting lower case string 1.334 * @see scstrdup() 1.335 */ 1.336 -sstr_t ucx_strlower(scstr_t string); 1.337 +sstr_t scstrlower(scstr_t string); 1.338 1.339 /** 1.340 - * Alias for ucx_strlower() which automatically casts the argument. 1.341 + * Alias for scstrlower() which automatically casts the argument. 1.342 * 1.343 * @param string the input string 1.344 * @return the resulting lower case string 1.345 */ 1.346 -#define sstrlower(string) ucx_strlower(SCSTR(string)) 1.347 +#define sstrlower(string) scstrlower(SCSTR(string)) 1.348 1.349 /** 1.350 * Returns a lower case version of a string. 1.351 @@ -825,17 +822,17 @@ 1.352 * @return the resulting lower case string 1.353 * @see scstrdup_a() 1.354 */ 1.355 -sstr_t ucx_strlower_a(UcxAllocator *allocator, scstr_t string); 1.356 +sstr_t scstrlower_a(UcxAllocator *allocator, scstr_t string); 1.357 1.358 1.359 /** 1.360 - * Alias for ucx_strlower_a() which automatically casts the argument. 1.361 + * Alias for scstrlower_a() which automatically casts the argument. 1.362 * 1.363 * @param allocator the allocator used for duplicating the string 1.364 * @param string the input string 1.365 * @return the resulting lower case string 1.366 */ 1.367 -#define sstrlower_a(allocator, string) ucx_strlower_a(allocator, SCSTR(string)) 1.368 +#define sstrlower_a(allocator, string) scstrlower_a(allocator, SCSTR(string)) 1.369 1.370 /** 1.371 * Returns a upper case version of a string. 1.372 @@ -847,15 +844,15 @@ 1.373 * @return the resulting upper case string 1.374 * @see scstrdup() 1.375 */ 1.376 -sstr_t ucx_strupper(scstr_t string); 1.377 +sstr_t scstrupper(scstr_t string); 1.378 1.379 /** 1.380 - * Alias for ucx_strupper() which automatically casts the argument. 1.381 + * Alias for scstrupper() which automatically casts the argument. 1.382 * 1.383 * @param string the input string 1.384 * @return the resulting upper case string 1.385 */ 1.386 -#define sstrupper(string) ucx_strupper(SCSTR(string)) 1.387 +#define sstrupper(string) scstrupper(SCSTR(string)) 1.388 1.389 /** 1.390 * Returns a upper case version of a string. 1.391 @@ -868,16 +865,16 @@ 1.392 * @return the resulting upper case string 1.393 * @see scstrdup_a() 1.394 */ 1.395 -sstr_t ucx_strupper_a(UcxAllocator *allocator, scstr_t string); 1.396 +sstr_t scstrupper_a(UcxAllocator *allocator, scstr_t string); 1.397 1.398 /** 1.399 - * Alias for ucx_strupper_a() which automatically casts the argument. 1.400 + * Alias for scstrupper_a() which automatically casts the argument. 1.401 * 1.402 * @param allocator the allocator used for duplicating the string 1.403 * @param string the input string 1.404 * @return the resulting upper case string 1.405 */ 1.406 -#define sstrupper_a(allocator, string) ucx_strupper_a(allocator, string) 1.407 +#define sstrupper_a(allocator, string) scstrupper_a(allocator, string) 1.408 1.409 #ifdef __cplusplus 1.410 }