| 887:26541c37b619 | 889:42cdbf9bbd49 |
|---|---|
| 46 #define CX_PRIstr ".*s" | 46 #define CX_PRIstr ".*s" |
| 47 | 47 |
| 48 /** | 48 /** |
| 49 * The maximum length of the "needle" in cx_strstr() that can use SBO. | 49 * The maximum length of the "needle" in cx_strstr() that can use SBO. |
| 50 */ | 50 */ |
| 51 cx_attr_export | 51 CX_EXPORT extern const unsigned cx_strstr_sbo_size; |
| 52 extern const unsigned cx_strstr_sbo_size; | |
| 53 | 52 |
| 54 /** | 53 /** |
| 55 * The UCX string structure. | 54 * The UCX string structure. |
| 56 */ | 55 */ |
| 57 struct cx_mutstr_s { | 56 struct cx_mutstr_s { |
| 110 /** | 109 /** |
| 111 * Position of the currently active token in the source string. | 110 * Position of the currently active token in the source string. |
| 112 */ | 111 */ |
| 113 size_t pos; | 112 size_t pos; |
| 114 /** | 113 /** |
| 115 * Position of next delimiter in the source string. | 114 * Position of the next delimiter in the source string. |
| 116 * | 115 * |
| 117 * If the tokenizer has not yet returned a token, the content of this field | 116 * If the tokenizer has not yet returned a token, the content of this field |
| 118 * is undefined. If the tokenizer reached the end of the string, this field | 117 * is undefined. If the tokenizer reaches the end of the string, this field |
| 119 * contains the length of the source string. | 118 * contains the length of the source string. |
| 120 */ | 119 */ |
| 121 size_t delim_pos; | 120 size_t delim_pos; |
| 122 /** | 121 /** |
| 123 * The position of the next token in the source string. | 122 * The position of the next token in the source string. |
| 172 * @note the wrapped string will share the specified pointer to the string. | 171 * @note the wrapped string will share the specified pointer to the string. |
| 173 * If you do want a copy, use cx_strdup() on the return value of this function. | 172 * If you do want a copy, use cx_strdup() on the return value of this function. |
| 174 * | 173 * |
| 175 * If you need to wrap a constant string, use cx_str(). | 174 * If you need to wrap a constant string, use cx_str(). |
| 176 * | 175 * |
| 177 * @param cstring the string to wrap, must be zero-terminated | 176 * @param cstring the string to wrap (must be zero-terminated) |
| 178 * @return the wrapped string | 177 * @return the wrapped string |
| 179 * | 178 * |
| 180 * @see cx_mutstrn() | 179 * @see cx_mutstrn() |
| 181 */ | 180 */ |
| 182 cx_attr_nodiscard | 181 cx_attr_nodiscard cx_attr_cstr_arg(1) |
| 183 cx_attr_cstr_arg(1) | 182 CX_EXPORT cxmutstr cx_mutstr(char *cstring); |
| 184 cx_attr_export | |
| 185 cxmutstr cx_mutstr(char *cstring); | |
| 186 | 183 |
| 187 /** | 184 /** |
| 188 * Wraps a string that does not need to be zero-terminated. | 185 * Wraps a string that does not need to be zero-terminated. |
| 189 * | 186 * |
| 190 * The argument may be @c NULL if the length is zero. | 187 * The argument may be @c NULL if the length is zero. |
| 198 * @param length the length of the string | 195 * @param length the length of the string |
| 199 * @return the wrapped string | 196 * @return the wrapped string |
| 200 * | 197 * |
| 201 * @see cx_mutstr() | 198 * @see cx_mutstr() |
| 202 */ | 199 */ |
| 203 cx_attr_nodiscard | 200 cx_attr_nodiscard cx_attr_access_rw(1, 2) |
| 204 cx_attr_access_rw(1, 2) | 201 CX_EXPORT cxmutstr cx_mutstrn(char *cstring, size_t length); |
| 205 cx_attr_export | |
| 206 cxmutstr cx_mutstrn( | |
| 207 char *cstring, | |
| 208 size_t length | |
| 209 ); | |
| 210 | 202 |
| 211 /** | 203 /** |
| 212 * Wraps a string that must be zero-terminated. | 204 * Wraps a string that must be zero-terminated. |
| 213 * | 205 * |
| 214 * The length is implicitly inferred by using a call to @c strlen(). | 206 * The length is implicitly inferred by using a call to @c strlen(). |
| 218 * @note the wrapped string will share the specified pointer to the string. | 210 * @note the wrapped string will share the specified pointer to the string. |
| 219 * If you do want a copy, use cx_strdup() on the return value of this function. | 211 * If you do want a copy, use cx_strdup() on the return value of this function. |
| 220 * | 212 * |
| 221 * If you need to wrap a non-constant string, use cx_mutstr(). | 213 * If you need to wrap a non-constant string, use cx_mutstr(). |
| 222 * | 214 * |
| 223 * @param cstring the string to wrap, must be zero-terminated | 215 * @param cstring the string to wrap (must be zero-terminated) |
| 224 * @return the wrapped string | 216 * @return the wrapped string |
| 225 * | 217 * |
| 226 * @see cx_strn() | 218 * @see cx_strn() |
| 227 */ | 219 */ |
| 228 cx_attr_nodiscard | 220 cx_attr_nodiscard cx_attr_cstr_arg(1) |
| 229 cx_attr_cstr_arg(1) | 221 CX_EXPORT cxstring cx_str(const char *cstring); |
| 230 cx_attr_export | |
| 231 cxstring cx_str(const char *cstring); | |
| 232 | 222 |
| 233 | 223 |
| 234 /** | 224 /** |
| 235 * Wraps a string that does not need to be zero-terminated. | 225 * Wraps a string that does not need to be zero-terminated. |
| 236 * | 226 * |
| 245 * @param length the length of the string | 235 * @param length the length of the string |
| 246 * @return the wrapped string | 236 * @return the wrapped string |
| 247 * | 237 * |
| 248 * @see cx_str() | 238 * @see cx_str() |
| 249 */ | 239 */ |
| 250 cx_attr_nodiscard | 240 cx_attr_nodiscard cx_attr_access_r(1, 2) |
| 251 cx_attr_access_r(1, 2) | 241 CX_EXPORT cxstring cx_strn(const char *cstring, size_t length); |
| 252 cx_attr_export | |
| 253 cxstring cx_strn( | |
| 254 const char *cstring, | |
| 255 size_t length | |
| 256 ); | |
| 257 | 242 |
| 258 #ifdef __cplusplus | 243 #ifdef __cplusplus |
| 259 } // extern "C" | 244 } // extern "C" |
| 260 cx_attr_nodiscard | 245 cx_attr_nodiscard |
| 261 static inline cxstring cx_strcast(cxmutstr str) { | 246 CX_CPPDECL cxstring cx_strcast(cxmutstr str) { |
| 262 return cx_strn(str.ptr, str.length); | 247 return cx_strn(str.ptr, str.length); |
| 263 } | 248 } |
| 264 cx_attr_nodiscard | 249 cx_attr_nodiscard |
| 265 static inline cxstring cx_strcast(cxstring str) { | 250 CX_CPPDECL cxstring cx_strcast(cxstring str) { |
| 266 return str; | 251 return str; |
| 267 } | 252 } |
| 268 cx_attr_nodiscard | 253 cx_attr_nodiscard |
| 269 static inline cxstring cx_strcast(const char *str) { | 254 CX_CPPDECL cxstring cx_strcast(const char *str) { |
| 270 return cx_str(str); | 255 return cx_str(str); |
| 256 } | |
| 257 cx_attr_nodiscard | |
| 258 CX_CPPDECL cxstring cx_strcast(const unsigned char *str) { | |
| 259 return cx_str(static_cast<const char*>(str)); | |
| 271 } | 260 } |
| 272 extern "C" { | 261 extern "C" { |
| 273 #else | 262 #else |
| 274 /** | 263 /** |
| 275 * Internal function, do not use. | 264 * Internal function, do not use. |
| 276 * @param str | 265 * @param str |
| 277 * @return | 266 * @return |
| 278 * @see cx_strcast() | 267 * @see cx_strcast() |
| 279 */ | 268 */ |
| 280 cx_attr_nodiscard | 269 cx_attr_nodiscard |
| 281 static inline cxstring cx_strcast_m(cxmutstr str) { | 270 CX_INLINE cxstring cx_strcast_m(cxmutstr str) { |
| 282 return (cxstring) {str.ptr, str.length}; | 271 return (cxstring) {str.ptr, str.length}; |
| 283 } | 272 } |
| 284 /** | 273 /** |
| 285 * Internal function, do not use. | 274 * Internal function, do not use. |
| 286 * @param str | 275 * @param str |
| 287 * @return | 276 * @return |
| 288 * @see cx_strcast() | 277 * @see cx_strcast() |
| 289 */ | 278 */ |
| 290 cx_attr_nodiscard | 279 cx_attr_nodiscard |
| 291 static inline cxstring cx_strcast_c(cxstring str) { | 280 CX_INLINE cxstring cx_strcast_c(cxstring str) { |
| 292 return str; | 281 return str; |
| 293 } | 282 } |
| 294 | 283 |
| 295 /** | 284 /** |
| 296 * Internal function, do not use. | 285 * Internal function, do not use. |
| 297 * @param str | 286 * @param str |
| 298 * @return | 287 * @return |
| 299 * @see cx_strcast() | 288 * @see cx_strcast() |
| 300 */ | 289 */ |
| 301 cx_attr_nodiscard | 290 cx_attr_nodiscard |
| 302 static inline cxstring cx_strcast_z(const char *str) { | 291 CX_INLINE cxstring cx_strcast_u(const unsigned char *str) { |
| 292 return cx_str((const char*)str); | |
| 293 } | |
| 294 | |
| 295 /** | |
| 296 * Internal function, do not use. | |
| 297 * @param str | |
| 298 * @return | |
| 299 * @see cx_strcast() | |
| 300 */ | |
| 301 cx_attr_nodiscard | |
| 302 CX_INLINE cxstring cx_strcast_z(const char *str) { | |
| 303 return cx_str(str); | 303 return cx_str(str); |
| 304 } | 304 } |
| 305 | 305 |
| 306 /** | 306 /** |
| 307 * Casts a mutable string to an immutable string. | 307 * Wraps any string into an UCX string. |
| 308 * | 308 * |
| 309 * Does nothing for already immutable strings. | 309 * @param str (any supported string type) the string to cast |
| 310 * | 310 * @return (@c cxstring) the string wrapped as UCX string |
| 311 * @note This is not seriously a cast. Instead, you get a copy | 311 */ |
| 312 * of the struct with the desired pointer type. Both structs still | |
| 313 * point to the same location, though! | |
| 314 * | |
| 315 * @param str (@c cxstring or @c cxmutstr) the string to cast | |
| 316 * @return (@c cxstring) an immutable copy of the string pointer | |
| 317 */ | |
| 318 #define cx_strcast(str) _Generic((str), \ | 312 #define cx_strcast(str) _Generic((str), \ |
| 319 cxmutstr: cx_strcast_m, \ | 313 cxmutstr: cx_strcast_m, \ |
| 320 cxstring: cx_strcast_c, \ | 314 cxstring: cx_strcast_c, \ |
| 315 const unsigned char*: cx_strcast_u, \ | |
| 316 unsigned char *: cx_strcast_u, \ | |
| 321 const char*: cx_strcast_z, \ | 317 const char*: cx_strcast_z, \ |
| 322 char *: cx_strcast_z) (str) | 318 char *: cx_strcast_z) (str) |
| 323 #endif | 319 #endif |
| 324 | 320 |
| 325 /** | 321 /** |
| 326 * Passes the pointer in this string to the cxDefaultAllocator's @c free() function. | 322 * Passes the pointer in this string to the cxDefaultAllocator's @c free() function. |
| 327 * | 323 * |
| 328 * The pointer in the struct is set to @c NULL and the length is set to zero | 324 * The pointer in the struct is set to @c NULL, and the length is set to zero, |
| 329 * which means that this function protects you against double-free. | 325 * which means that this function protects you against double-free. |
| 330 * | 326 * |
| 331 * @note There is no implementation for cxstring, because it is unlikely that | 327 * @note There is no implementation for cxstring, because it is unlikely that |
| 332 * you ever have a <code>const char*</code> you are really supposed to free. | 328 * you ever have a <code>const char*</code> you are really supposed to free. |
| 333 * If you encounter such situation, you should double-check your code. | 329 * If you encounter such a situation, you should double-check your code. |
| 334 * | 330 * |
| 335 * @param str the string to free | 331 * @param str the string to free |
| 336 */ | 332 */ |
| 337 cx_attr_export | 333 CX_EXPORT void cx_strfree(cxmutstr *str); |
| 338 void cx_strfree(cxmutstr *str); | 334 |
| 339 | 335 /** |
| 340 /** | 336 * Passes the pointer in this string to the allocator's free function. |
| 341 * Passes the pointer in this string to the allocators free function. | 337 * |
| 342 * | 338 * The pointer in the struct is set to @c NULL, and the length is set to zero, |
| 343 * The pointer in the struct is set to @c NULL and the length is set to zero | |
| 344 * which means that this function protects you against double-free. | 339 * which means that this function protects you against double-free. |
| 345 * | 340 * |
| 346 * @note There is no implementation for cxstring, because it is unlikely that | 341 * @note There is no implementation for cxstring, because it is unlikely that |
| 347 * you ever have a <code>const char*</code> you are really supposed to free. | 342 * you ever have a <code>const char*</code> you are really supposed to free. |
| 348 * If you encounter such situation, you should double-check your code. | 343 * If you encounter such a situation, you should double-check your code. |
| 349 * | 344 * |
| 350 * @param alloc the allocator | 345 * @param alloc the allocator |
| 351 * @param str the string to free | 346 * @param str the string to free |
| 352 */ | 347 */ |
| 353 cx_attr_nonnull_arg(1) | 348 cx_attr_nonnull_arg(1) |
| 354 cx_attr_export | 349 CX_EXPORT void cx_strfree_a(const CxAllocator *alloc, cxmutstr *str); |
| 355 void cx_strfree_a( | |
| 356 const CxAllocator *alloc, | |
| 357 cxmutstr *str | |
| 358 ); | |
| 359 | 350 |
| 360 /** | 351 /** |
| 361 * Copies a string. | 352 * Copies a string. |
| 362 * | 353 * |
| 363 * The memory in the @p dest structure is either allocated or re-allocated to fit the entire | 354 * The memory in the @p dest structure is either allocated or re-allocated to fit the entire |
| 371 * | 362 * |
| 372 * @retval zero success | 363 * @retval zero success |
| 373 * @retval non-zero if re-allocation failed | 364 * @retval non-zero if re-allocation failed |
| 374 */ | 365 */ |
| 375 cx_attr_nonnull_arg(1) | 366 cx_attr_nonnull_arg(1) |
| 376 cx_attr_export | 367 CX_EXPORT int cx_strcpy_a(const CxAllocator *alloc, cxmutstr *dest, cxstring src); |
| 377 int cx_strcpy_a( | |
| 378 const CxAllocator *alloc, | |
| 379 cxmutstr *dest, | |
| 380 cxstring src | |
| 381 ); | |
| 382 | 368 |
| 383 | 369 |
| 384 /** | 370 /** |
| 385 * Copies a string. | 371 * Copies a string. |
| 386 * | 372 * |
| 408 * @param count the total number of specified strings | 394 * @param count the total number of specified strings |
| 409 * @param ... all strings | 395 * @param ... all strings |
| 410 * @return the accumulated length of all strings | 396 * @return the accumulated length of all strings |
| 411 */ | 397 */ |
| 412 cx_attr_nodiscard | 398 cx_attr_nodiscard |
| 413 cx_attr_export | 399 CX_EXPORT size_t cx_strlen(size_t count, ...); |
| 414 size_t cx_strlen( | |
| 415 size_t count, | |
| 416 ... | |
| 417 ); | |
| 418 | 400 |
| 419 /** | 401 /** |
| 420 * Concatenates strings. | 402 * Concatenates strings. |
| 421 * | 403 * |
| 422 * The resulting string will be allocated by the specified allocator. | 404 * The resulting string will be allocated by the specified allocator. |
| 436 * @param str the string the other strings shall be concatenated to | 418 * @param str the string the other strings shall be concatenated to |
| 437 * @param count the number of the other following strings to concatenate | 419 * @param count the number of the other following strings to concatenate |
| 438 * @param ... all other UCX strings | 420 * @param ... all other UCX strings |
| 439 * @return the concatenated string | 421 * @return the concatenated string |
| 440 */ | 422 */ |
| 441 cx_attr_nodiscard | 423 cx_attr_nodiscard cx_attr_nonnull |
| 442 cx_attr_nonnull | 424 CX_EXPORT cxmutstr cx_strcat_ma(const CxAllocator *alloc, |
| 443 cx_attr_export | 425 cxmutstr str, size_t count, ...); |
| 444 cxmutstr cx_strcat_ma( | |
| 445 const CxAllocator *alloc, | |
| 446 cxmutstr str, | |
| 447 size_t count, | |
| 448 ... | |
| 449 ); | |
| 450 | 426 |
| 451 /** | 427 /** |
| 452 * Concatenates strings and returns a new string. | 428 * Concatenates strings and returns a new string. |
| 453 * | 429 * |
| 454 * The resulting string will be allocated by the specified allocator. | 430 * The resulting string will be allocated by the specified allocator. |
| 465 * @param count (@c size_t) the number of the other following strings to concatenate | 441 * @param count (@c size_t) the number of the other following strings to concatenate |
| 466 * @param ... all other UCX strings | 442 * @param ... all other UCX strings |
| 467 * @return (@c cxmutstr) the concatenated string | 443 * @return (@c cxmutstr) the concatenated string |
| 468 */ | 444 */ |
| 469 #define cx_strcat_a(alloc, count, ...) \ | 445 #define cx_strcat_a(alloc, count, ...) \ |
| 470 cx_strcat_ma(alloc, cx_mutstrn(NULL, 0), count, __VA_ARGS__) | 446 cx_strcat_ma(alloc, cx_mutstrn(NULL, 0), count, __VA_ARGS__) |
| 471 | 447 |
| 472 /** | 448 /** |
| 473 * Concatenates strings and returns a new string. | 449 * Concatenates strings and returns a new string. |
| 474 * | 450 * |
| 475 * The resulting string will be allocated by the cxDefaultAllocator. | 451 * The resulting string will be allocated by the cxDefaultAllocator. |
| 485 * @param count (@c size_t) the number of the other following strings to concatenate | 461 * @param count (@c size_t) the number of the other following strings to concatenate |
| 486 * @param ... all other UCX strings | 462 * @param ... all other UCX strings |
| 487 * @return (@c cxmutstr) the concatenated string | 463 * @return (@c cxmutstr) the concatenated string |
| 488 */ | 464 */ |
| 489 #define cx_strcat(count, ...) \ | 465 #define cx_strcat(count, ...) \ |
| 490 cx_strcat_ma(cxDefaultAllocator, cx_mutstrn(NULL, 0), count, __VA_ARGS__) | 466 cx_strcat_ma(cxDefaultAllocator, cx_mutstrn(NULL, 0), count, __VA_ARGS__) |
| 491 | 467 |
| 492 /** | 468 /** |
| 493 * Concatenates strings. | 469 * Concatenates strings. |
| 494 * | 470 * |
| 495 * The resulting string will be allocated by the cxDefaultAllocator. | 471 * The resulting string will be allocated by the cxDefaultAllocator. |
| 509 * @param count (@c size_t) the number of the other following strings to concatenate | 485 * @param count (@c size_t) the number of the other following strings to concatenate |
| 510 * @param ... all other strings | 486 * @param ... all other strings |
| 511 * @return (@c cxmutstr) the concatenated string | 487 * @return (@c cxmutstr) the concatenated string |
| 512 */ | 488 */ |
| 513 #define cx_strcat_m(str, count, ...) \ | 489 #define cx_strcat_m(str, count, ...) \ |
| 514 cx_strcat_ma(cxDefaultAllocator, str, count, __VA_ARGS__) | 490 cx_strcat_ma(cxDefaultAllocator, str, count, __VA_ARGS__) |
| 515 | 491 |
| 516 /** | 492 /** |
| 517 * Returns a substring starting at the specified location. | 493 * Returns a substring starting at the specified location. |
| 518 * | 494 * |
| 519 * @attention the new string references the same memory area as the | 495 * @attention the new string references the same memory area as the |
| 527 * @see cx_strsubsl() | 503 * @see cx_strsubsl() |
| 528 * @see cx_strsubs_m() | 504 * @see cx_strsubs_m() |
| 529 * @see cx_strsubsl_m() | 505 * @see cx_strsubsl_m() |
| 530 */ | 506 */ |
| 531 cx_attr_nodiscard | 507 cx_attr_nodiscard |
| 532 cx_attr_export | 508 CX_EXPORT cxstring cx_strsubs(cxstring string, size_t start); |
| 533 cxstring cx_strsubs( | |
| 534 cxstring string, | |
| 535 size_t start | |
| 536 ); | |
| 537 | 509 |
| 538 /** | 510 /** |
| 539 * Returns a substring starting at the specified location. | 511 * Returns a substring starting at the specified location. |
| 540 * | 512 * |
| 541 * The returned string will be limited to @p length bytes or the number | 513 * The returned string will be limited to @p length bytes or the number |
| 553 * @see cx_strsubs() | 525 * @see cx_strsubs() |
| 554 * @see cx_strsubs_m() | 526 * @see cx_strsubs_m() |
| 555 * @see cx_strsubsl_m() | 527 * @see cx_strsubsl_m() |
| 556 */ | 528 */ |
| 557 cx_attr_nodiscard | 529 cx_attr_nodiscard |
| 558 cx_attr_export | 530 CX_EXPORT cxstring cx_strsubsl(cxstring string, size_t start, size_t length); |
| 559 cxstring cx_strsubsl( | |
| 560 cxstring string, | |
| 561 size_t start, | |
| 562 size_t length | |
| 563 ); | |
| 564 | 531 |
| 565 /** | 532 /** |
| 566 * Returns a substring starting at the specified location. | 533 * Returns a substring starting at the specified location. |
| 567 * | 534 * |
| 568 * @attention the new string references the same memory area as the | 535 * @attention the new string references the same memory area as the |
| 576 * @see cx_strsubsl_m() | 543 * @see cx_strsubsl_m() |
| 577 * @see cx_strsubs() | 544 * @see cx_strsubs() |
| 578 * @see cx_strsubsl() | 545 * @see cx_strsubsl() |
| 579 */ | 546 */ |
| 580 cx_attr_nodiscard | 547 cx_attr_nodiscard |
| 581 cx_attr_export | 548 CX_EXPORT cxmutstr cx_strsubs_m(cxmutstr string, size_t start); |
| 582 cxmutstr cx_strsubs_m( | |
| 583 cxmutstr string, | |
| 584 size_t start | |
| 585 ); | |
| 586 | 549 |
| 587 /** | 550 /** |
| 588 * Returns a substring starting at the specified location. | 551 * Returns a substring starting at the specified location. |
| 589 * | 552 * |
| 590 * The returned string will be limited to @p length bytes or the number | 553 * The returned string will be limited to @p length bytes or the number |
| 602 * @see cx_strsubs_m() | 565 * @see cx_strsubs_m() |
| 603 * @see cx_strsubs() | 566 * @see cx_strsubs() |
| 604 * @see cx_strsubsl() | 567 * @see cx_strsubsl() |
| 605 */ | 568 */ |
| 606 cx_attr_nodiscard | 569 cx_attr_nodiscard |
| 607 cx_attr_export | 570 CX_EXPORT cxmutstr cx_strsubsl_m(cxmutstr string, size_t start, size_t length); |
| 608 cxmutstr cx_strsubsl_m( | |
| 609 cxmutstr string, | |
| 610 size_t start, | |
| 611 size_t length | |
| 612 ); | |
| 613 | 571 |
| 614 /** | 572 /** |
| 615 * Returns a substring starting at the location of the first occurrence of the | 573 * Returns a substring starting at the location of the first occurrence of the |
| 616 * specified character. | 574 * specified character. |
| 617 * | 575 * |
| 622 * @return a substring starting at the first location of @p chr | 580 * @return a substring starting at the first location of @p chr |
| 623 * | 581 * |
| 624 * @see cx_strchr_m() | 582 * @see cx_strchr_m() |
| 625 */ | 583 */ |
| 626 cx_attr_nodiscard | 584 cx_attr_nodiscard |
| 627 cx_attr_export | 585 CX_EXPORT cxstring cx_strchr(cxstring string, int chr); |
| 628 cxstring cx_strchr( | |
| 629 cxstring string, | |
| 630 int chr | |
| 631 ); | |
| 632 | 586 |
| 633 /** | 587 /** |
| 634 * Returns a substring starting at the location of the first occurrence of the | 588 * Returns a substring starting at the location of the first occurrence of the |
| 635 * specified character. | 589 * specified character. |
| 636 * | 590 * |
| 641 * @return a substring starting at the first location of @p chr | 595 * @return a substring starting at the first location of @p chr |
| 642 * | 596 * |
| 643 * @see cx_strchr() | 597 * @see cx_strchr() |
| 644 */ | 598 */ |
| 645 cx_attr_nodiscard | 599 cx_attr_nodiscard |
| 646 cx_attr_export | 600 CX_EXPORT cxmutstr cx_strchr_m(cxmutstr string, int chr); |
| 647 cxmutstr cx_strchr_m( | |
| 648 cxmutstr string, | |
| 649 int chr | |
| 650 ); | |
| 651 | 601 |
| 652 /** | 602 /** |
| 653 * Returns a substring starting at the location of the last occurrence of the | 603 * Returns a substring starting at the location of the last occurrence of the |
| 654 * specified character. | 604 * specified character. |
| 655 * | 605 * |
| 660 * @return a substring starting at the last location of @p chr | 610 * @return a substring starting at the last location of @p chr |
| 661 * | 611 * |
| 662 * @see cx_strrchr_m() | 612 * @see cx_strrchr_m() |
| 663 */ | 613 */ |
| 664 cx_attr_nodiscard | 614 cx_attr_nodiscard |
| 665 cx_attr_export | 615 CX_EXPORT cxstring cx_strrchr(cxstring string, int chr); |
| 666 cxstring cx_strrchr( | |
| 667 cxstring string, | |
| 668 int chr | |
| 669 ); | |
| 670 | 616 |
| 671 /** | 617 /** |
| 672 * Returns a substring starting at the location of the last occurrence of the | 618 * Returns a substring starting at the location of the last occurrence of the |
| 673 * specified character. | 619 * specified character. |
| 674 * | 620 * |
| 679 * @return a substring starting at the last location of @p chr | 625 * @return a substring starting at the last location of @p chr |
| 680 * | 626 * |
| 681 * @see cx_strrchr() | 627 * @see cx_strrchr() |
| 682 */ | 628 */ |
| 683 cx_attr_nodiscard | 629 cx_attr_nodiscard |
| 684 cx_attr_export | 630 CX_EXPORT cxmutstr cx_strrchr_m(cxmutstr string, int chr); |
| 685 cxmutstr cx_strrchr_m( | |
| 686 cxmutstr string, | |
| 687 int chr | |
| 688 ); | |
| 689 | 631 |
| 690 /** | 632 /** |
| 691 * Returns a substring starting at the location of the first occurrence of the | 633 * Returns a substring starting at the location of the first occurrence of the |
| 692 * specified string. | 634 * specified string. |
| 693 * | 635 * |
| 702 * @p needle, or an empty string, if the sequence is not | 644 * @p needle, or an empty string, if the sequence is not |
| 703 * contained | 645 * contained |
| 704 * @see cx_strstr_m() | 646 * @see cx_strstr_m() |
| 705 */ | 647 */ |
| 706 cx_attr_nodiscard | 648 cx_attr_nodiscard |
| 707 cx_attr_export | 649 CX_EXPORT cxstring cx_strstr(cxstring haystack, cxstring needle); |
| 708 cxstring cx_strstr( | |
| 709 cxstring haystack, | |
| 710 cxstring needle | |
| 711 ); | |
| 712 | 650 |
| 713 /** | 651 /** |
| 714 * Returns a substring starting at the location of the first occurrence of the | 652 * Returns a substring starting at the location of the first occurrence of the |
| 715 * specified string. | 653 * specified string. |
| 716 * | 654 * |
| 725 * @p needle, or an empty string, if the sequence is not | 663 * @p needle, or an empty string, if the sequence is not |
| 726 * contained | 664 * contained |
| 727 * @see cx_strstr() | 665 * @see cx_strstr() |
| 728 */ | 666 */ |
| 729 cx_attr_nodiscard | 667 cx_attr_nodiscard |
| 730 cx_attr_export | 668 CX_EXPORT cxmutstr cx_strstr_m(cxmutstr haystack, cxstring needle); |
| 731 cxmutstr cx_strstr_m( | |
| 732 cxmutstr haystack, | |
| 733 cxstring needle | |
| 734 ); | |
| 735 | 669 |
| 736 /** | 670 /** |
| 737 * Splits a given string using a delimiter string. | 671 * Splits a given string using a delimiter string. |
| 738 * | 672 * |
| 739 * @note The resulting array contains strings that point to the source | 673 * @note The resulting array contains strings that point to the source |
| 743 * @param delim the delimiter | 677 * @param delim the delimiter |
| 744 * @param limit the maximum number of split items | 678 * @param limit the maximum number of split items |
| 745 * @param output a preallocated array of at least @p limit length | 679 * @param output a preallocated array of at least @p limit length |
| 746 * @return the actual number of split items | 680 * @return the actual number of split items |
| 747 */ | 681 */ |
| 748 cx_attr_nodiscard | 682 cx_attr_nodiscard cx_attr_nonnull cx_attr_access_w(4, 3) |
| 749 cx_attr_nonnull | 683 CX_EXPORT size_t cx_strsplit(cxstring string, cxstring delim, |
| 750 cx_attr_access_w(4, 3) | 684 size_t limit, cxstring *output); |
| 751 cx_attr_export | |
| 752 size_t cx_strsplit( | |
| 753 cxstring string, | |
| 754 cxstring delim, | |
| 755 size_t limit, | |
| 756 cxstring *output | |
| 757 ); | |
| 758 | 685 |
| 759 /** | 686 /** |
| 760 * Splits a given string using a delimiter string. | 687 * Splits a given string using a delimiter string. |
| 761 * | 688 * |
| 762 * The array pointed to by @p output will be allocated by @p allocator. | 689 * The array pointed to by @p output will be allocated by @p allocator. |
| 773 * @param limit the maximum number of split items | 700 * @param limit the maximum number of split items |
| 774 * @param output a pointer where the address of the allocated array shall be | 701 * @param output a pointer where the address of the allocated array shall be |
| 775 * written to | 702 * written to |
| 776 * @return the actual number of split items | 703 * @return the actual number of split items |
| 777 */ | 704 */ |
| 778 cx_attr_nodiscard | 705 cx_attr_nodiscard cx_attr_nonnull cx_attr_access_w(5) |
| 779 cx_attr_nonnull | 706 CX_EXPORT size_t cx_strsplit_a(const CxAllocator *allocator, |
| 780 cx_attr_access_w(5) | 707 cxstring string, cxstring delim, |
| 781 cx_attr_export | 708 size_t limit, cxstring **output); |
| 782 size_t cx_strsplit_a( | |
| 783 const CxAllocator *allocator, | |
| 784 cxstring string, | |
| 785 cxstring delim, | |
| 786 size_t limit, | |
| 787 cxstring **output | |
| 788 ); | |
| 789 | 709 |
| 790 | 710 |
| 791 /** | 711 /** |
| 792 * Splits a given string using a delimiter string. | 712 * Splits a given string using a delimiter string. |
| 793 * | 713 * |
| 798 * @param delim the delimiter | 718 * @param delim the delimiter |
| 799 * @param limit the maximum number of split items | 719 * @param limit the maximum number of split items |
| 800 * @param output a preallocated array of at least @p limit length | 720 * @param output a preallocated array of at least @p limit length |
| 801 * @return the actual number of split items | 721 * @return the actual number of split items |
| 802 */ | 722 */ |
| 803 cx_attr_nodiscard | 723 cx_attr_nodiscard cx_attr_nonnull cx_attr_access_w(4, 3) |
| 804 cx_attr_nonnull | 724 CX_EXPORT size_t cx_strsplit_m(cxmutstr string, cxstring delim, |
| 805 cx_attr_access_w(4, 3) | 725 size_t limit, cxmutstr *output); |
| 806 cx_attr_export | |
| 807 size_t cx_strsplit_m( | |
| 808 cxmutstr string, | |
| 809 cxstring delim, | |
| 810 size_t limit, | |
| 811 cxmutstr *output | |
| 812 ); | |
| 813 | 726 |
| 814 /** | 727 /** |
| 815 * Splits a given string using a delimiter string. | 728 * Splits a given string using a delimiter string. |
| 816 * | 729 * |
| 817 * The array pointed to by @p output will be allocated by @p allocator. | 730 * The array pointed to by @p output will be allocated by @p allocator. |
| 828 * @param limit the maximum number of split items | 741 * @param limit the maximum number of split items |
| 829 * @param output a pointer where the address of the allocated array shall be | 742 * @param output a pointer where the address of the allocated array shall be |
| 830 * written to | 743 * written to |
| 831 * @return the actual number of split items | 744 * @return the actual number of split items |
| 832 */ | 745 */ |
| 833 cx_attr_nodiscard | 746 cx_attr_nodiscard cx_attr_nonnull cx_attr_access_w(5) |
| 834 cx_attr_nonnull | 747 CX_EXPORT size_t cx_strsplit_ma(const CxAllocator *allocator, |
| 835 cx_attr_access_w(5) | 748 cxmutstr string, cxstring delim, size_t limit, |
| 836 cx_attr_export | 749 cxmutstr **output); |
| 837 size_t cx_strsplit_ma( | |
| 838 const CxAllocator *allocator, | |
| 839 cxmutstr string, | |
| 840 cxstring delim, | |
| 841 size_t limit, | |
| 842 cxmutstr **output | |
| 843 ); | |
| 844 | 750 |
| 845 /** | 751 /** |
| 846 * Compares two strings. | 752 * Compares two strings. |
| 847 * | 753 * |
| 848 * @param s1 the first string | 754 * @param s1 the first string |
| 849 * @param s2 the second string | 755 * @param s2 the second string |
| 850 * @return negative if @p s1 is smaller than @p s2, positive if @p s1 is larger | 756 * @return negative if @p s1 is smaller than @p s2, positive if @p s1 is larger |
| 851 * than @p s2, zero if both strings equal | 757 * than @p s2, zero if both strings equal |
| 852 */ | 758 */ |
| 853 cx_attr_nodiscard | 759 cx_attr_nodiscard |
| 854 cx_attr_export | 760 CX_EXPORT int cx_strcmp_(cxstring s1, cxstring s2); |
| 855 int cx_strcmp( | 761 |
| 856 cxstring s1, | 762 /** |
| 857 cxstring s2 | 763 * Compares two strings. |
| 858 ); | 764 * |
| 765 * @param s1 the first string | |
| 766 * @param s2 the second string | |
| 767 * @return negative if @p s1 is smaller than @p s2, positive if @p s1 is larger | |
| 768 * than @p s2, zero if both strings equal | |
| 769 */ | |
| 770 #define cx_strcmp(s1, s2) cx_strcmp_(cx_strcast(s1), cx_strcast(s2)) | |
| 859 | 771 |
| 860 /** | 772 /** |
| 861 * Compares two strings ignoring case. | 773 * Compares two strings ignoring case. |
| 862 * | 774 * |
| 863 * @param s1 the first string | 775 * @param s1 the first string |
| 864 * @param s2 the second string | 776 * @param s2 the second string |
| 865 * @return negative if @p s1 is smaller than @p s2, positive if @p s1 is larger | 777 * @return negative if @p s1 is smaller than @p s2, positive if @p s1 is larger |
| 866 * than @p s2, zero if both strings equal ignoring case | 778 * than @p s2, zero if both strings equal ignoring case |
| 867 */ | 779 */ |
| 868 cx_attr_nodiscard | 780 cx_attr_nodiscard |
| 869 cx_attr_export | 781 CX_EXPORT int cx_strcasecmp_(cxstring s1, cxstring s2); |
| 870 int cx_strcasecmp( | 782 |
| 871 cxstring s1, | 783 /** |
| 872 cxstring s2 | 784 * Compares two strings ignoring case. |
| 873 ); | 785 * |
| 786 * @param s1 the first string | |
| 787 * @param s2 the second string | |
| 788 * @return negative if @p s1 is smaller than @p s2, positive if @p s1 is larger | |
| 789 * than @p s2, zero if both strings equal ignoring case | |
| 790 */ | |
| 791 #define cx_strcasecmp(s1, s2) cx_strcasecmp_(cx_strcast(s1), cx_strcast(s2)) | |
| 874 | 792 |
| 875 /** | 793 /** |
| 876 * Compares two strings. | 794 * Compares two strings. |
| 877 * | 795 * |
| 878 * This function has a compatible signature for the use as a cx_compare_func. | 796 * This function has a compatible signature for the use as a cx_compare_func. |
| 797 * | |
| 798 * @attention This function can @em only compare UCX strings. It is unsafe to | |
| 799 * pass normal C-strings to this function. | |
| 879 * | 800 * |
| 880 * @param s1 the first string | 801 * @param s1 the first string |
| 881 * @param s2 the second string | 802 * @param s2 the second string |
| 882 * @return negative if @p s1 is smaller than @p s2, positive if @p s1 is larger | 803 * @return negative if @p s1 is smaller than @p s2, positive if @p s1 is larger |
| 883 * than @p s2, zero if both strings equal | 804 * than @p s2, zero if both strings equal |
| 884 */ | 805 */ |
| 885 cx_attr_nodiscard | 806 cx_attr_nodiscard cx_attr_nonnull |
| 886 cx_attr_nonnull | 807 CX_EXPORT int cx_strcmp_p(const void *s1, const void *s2); |
| 887 cx_attr_export | |
| 888 int cx_strcmp_p( | |
| 889 const void *s1, | |
| 890 const void *s2 | |
| 891 ); | |
| 892 | 808 |
| 893 /** | 809 /** |
| 894 * Compares two strings ignoring case. | 810 * Compares two strings ignoring case. |
| 895 * | 811 * |
| 896 * This function has a compatible signature for the use as a cx_compare_func. | 812 * This function has a compatible signature for the use as a cx_compare_func. |
| 898 * @param s1 the first string | 814 * @param s1 the first string |
| 899 * @param s2 the second string | 815 * @param s2 the second string |
| 900 * @return negative if @p s1 is smaller than @p s2, positive if @p s1 is larger | 816 * @return negative if @p s1 is smaller than @p s2, positive if @p s1 is larger |
| 901 * than @p s2, zero if both strings equal ignoring case | 817 * than @p s2, zero if both strings equal ignoring case |
| 902 */ | 818 */ |
| 903 cx_attr_nodiscard | 819 cx_attr_nodiscard cx_attr_nonnull |
| 904 cx_attr_nonnull | 820 CX_EXPORT int cx_strcasecmp_p(const void *s1, const void *s2); |
| 905 cx_attr_export | |
| 906 int cx_strcasecmp_p( | |
| 907 const void *s1, | |
| 908 const void *s2 | |
| 909 ); | |
| 910 | 821 |
| 911 | 822 |
| 912 /** | 823 /** |
| 913 * Creates a duplicate of the specified string. | 824 * Creates a duplicate of the specified string. |
| 914 * | 825 * |
| 919 * @param allocator the allocator to use | 830 * @param allocator the allocator to use |
| 920 * @param string the string to duplicate | 831 * @param string the string to duplicate |
| 921 * @return a duplicate of the string | 832 * @return a duplicate of the string |
| 922 * @see cx_strdup() | 833 * @see cx_strdup() |
| 923 */ | 834 */ |
| 924 cx_attr_nodiscard | 835 cx_attr_nodiscard cx_attr_nonnull |
| 925 cx_attr_nonnull | 836 CX_EXPORT cxmutstr cx_strdup_a_(const CxAllocator *allocator, cxstring string); |
| 926 cx_attr_export | |
| 927 cxmutstr cx_strdup_a_( | |
| 928 const CxAllocator *allocator, | |
| 929 cxstring string | |
| 930 ); | |
| 931 | 837 |
| 932 /** | 838 /** |
| 933 * Creates a duplicate of the specified string. | 839 * Creates a duplicate of the specified string. |
| 934 * | 840 * |
| 935 * The new string will contain a copy allocated by @p allocator. | 841 * The new string will contain a copy allocated by @p allocator. |
| 940 * @param string the string to duplicate | 846 * @param string the string to duplicate |
| 941 * @return (@c cxmutstr) a duplicate of the string | 847 * @return (@c cxmutstr) a duplicate of the string |
| 942 * @see cx_strdup() | 848 * @see cx_strdup() |
| 943 * @see cx_strfree_a() | 849 * @see cx_strfree_a() |
| 944 */ | 850 */ |
| 945 #define cx_strdup_a(allocator, string) \ | 851 #define cx_strdup_a(allocator, string) cx_strdup_a_((allocator), cx_strcast(string)) |
| 946 cx_strdup_a_((allocator), cx_strcast(string)) | |
| 947 | 852 |
| 948 /** | 853 /** |
| 949 * Creates a duplicate of the specified string. | 854 * Creates a duplicate of the specified string. |
| 950 * | 855 * |
| 951 * The new string will contain a copy allocated by the cxDefaultAllocator. | 856 * The new string will contain a copy allocated by the cxDefaultAllocator. |
| 968 * | 873 * |
| 969 * @param string the string that shall be trimmed | 874 * @param string the string that shall be trimmed |
| 970 * @return the trimmed string | 875 * @return the trimmed string |
| 971 */ | 876 */ |
| 972 cx_attr_nodiscard | 877 cx_attr_nodiscard |
| 973 cx_attr_export | 878 CX_EXPORT cxstring cx_strtrim(cxstring string); |
| 974 cxstring cx_strtrim(cxstring string); | |
| 975 | 879 |
| 976 /** | 880 /** |
| 977 * Omits leading and trailing spaces. | 881 * Omits leading and trailing spaces. |
| 978 * | 882 * |
| 979 * @note the returned string references the same memory, thus you | 883 * @note the returned string references the same memory, thus you |
| 981 * | 885 * |
| 982 * @param string the string that shall be trimmed | 886 * @param string the string that shall be trimmed |
| 983 * @return the trimmed string | 887 * @return the trimmed string |
| 984 */ | 888 */ |
| 985 cx_attr_nodiscard | 889 cx_attr_nodiscard |
| 986 cx_attr_export | 890 CX_EXPORT cxmutstr cx_strtrim_m(cxmutstr string); |
| 987 cxmutstr cx_strtrim_m(cxmutstr string); | 891 |
| 988 | 892 /** |
| 989 /** | 893 * Checks if a string has a specific prefix. |
| 990 * Checks, if a string has a specific prefix. | |
| 991 * | 894 * |
| 992 * @param string the string to check | 895 * @param string the string to check |
| 993 * @param prefix the prefix the string should have | 896 * @param prefix the prefix the string should have |
| 994 * @return @c true, if and only if the string has the specified prefix, | 897 * @return @c true, if and only if the string has the specified prefix, |
| 995 * @c false otherwise | 898 * @c false otherwise |
| 996 */ | 899 */ |
| 997 cx_attr_nodiscard | 900 cx_attr_nodiscard |
| 998 cx_attr_export | 901 CX_EXPORT bool cx_strprefix_(cxstring string, cxstring prefix); |
| 999 bool cx_strprefix( | 902 |
| 1000 cxstring string, | 903 /** |
| 1001 cxstring prefix | 904 * Checks if a string has a specific prefix. |
| 1002 ); | 905 * |
| 1003 | 906 * @param string the string to check |
| 1004 /** | 907 * @param prefix the prefix the string should have |
| 1005 * Checks, if a string has a specific suffix. | 908 * @return @c true, if and only if the string has the specified prefix, |
| 909 * @c false otherwise | |
| 910 */ | |
| 911 #define cx_strprefix(string, prefix) cx_strprefix_(cx_strcast(string), cx_strcast(prefix)) | |
| 912 | |
| 913 /** | |
| 914 * Checks if a string has a specific suffix. | |
| 1006 * | 915 * |
| 1007 * @param string the string to check | 916 * @param string the string to check |
| 1008 * @param suffix the suffix the string should have | 917 * @param suffix the suffix the string should have |
| 1009 * @return @c true, if and only if the string has the specified suffix, | 918 * @return @c true, if and only if the string has the specified suffix, |
| 1010 * @c false otherwise | 919 * @c false otherwise |
| 1011 */ | 920 */ |
| 1012 cx_attr_nodiscard | 921 cx_attr_nodiscard |
| 1013 cx_attr_export | 922 CX_EXPORT bool cx_strsuffix_(cxstring string, cxstring suffix); |
| 1014 bool cx_strsuffix( | 923 |
| 1015 cxstring string, | 924 /** |
| 1016 cxstring suffix | 925 * Checks if a string has a specific suffix. |
| 1017 ); | 926 * |
| 1018 | 927 * @param string the string to check |
| 1019 /** | 928 * @param suffix the suffix the string should have |
| 1020 * Checks, if a string has a specific prefix, ignoring the case. | 929 * @return @c true, if and only if the string has the specified suffix, |
| 930 * @c false otherwise | |
| 931 */ | |
| 932 #define cx_strsuffix(string, suffix) cx_strsuffix_(cx_strcast(string), cx_strcast(suffix)) | |
| 933 | |
| 934 /** | |
| 935 * Checks if a string has a specific prefix, ignoring the case. | |
| 1021 * | 936 * |
| 1022 * @param string the string to check | 937 * @param string the string to check |
| 1023 * @param prefix the prefix the string should have | 938 * @param prefix the prefix the string should have |
| 1024 * @return @c true, if and only if the string has the specified prefix, | 939 * @return @c true, if and only if the string has the specified prefix, |
| 1025 * @c false otherwise | 940 * @c false otherwise |
| 1026 */ | 941 */ |
| 1027 cx_attr_nodiscard | 942 cx_attr_nodiscard |
| 1028 cx_attr_export | 943 CX_EXPORT bool cx_strcaseprefix_(cxstring string, cxstring prefix); |
| 1029 bool cx_strcaseprefix( | 944 |
| 1030 cxstring string, | 945 /** |
| 1031 cxstring prefix | 946 * Checks if a string has a specific prefix, ignoring the case. |
| 1032 ); | 947 * |
| 948 * @param string the string to check | |
| 949 * @param prefix the prefix the string should have | |
| 950 * @return @c true, if and only if the string has the specified prefix, | |
| 951 * @c false otherwise | |
| 952 */ | |
| 953 #define cx_strcaseprefix(string, prefix) cx_strcaseprefix_(cx_strcast(string), cx_strcast(prefix)) | |
| 1033 | 954 |
| 1034 /** | 955 /** |
| 1035 * Checks, if a string has a specific suffix, ignoring the case. | 956 * Checks, if a string has a specific suffix, ignoring the case. |
| 1036 * | 957 * |
| 1037 * @param string the string to check | 958 * @param string the string to check |
| 1038 * @param suffix the suffix the string should have | 959 * @param suffix the suffix the string should have |
| 1039 * @return @c true, if and only if the string has the specified suffix, | 960 * @return @c true, if and only if the string has the specified suffix, |
| 1040 * @c false otherwise | 961 * @c false otherwise |
| 1041 */ | 962 */ |
| 1042 cx_attr_nodiscard | 963 cx_attr_nodiscard |
| 1043 cx_attr_export | 964 CX_EXPORT bool cx_strcasesuffix_(cxstring string, cxstring suffix); |
| 1044 bool cx_strcasesuffix( | 965 |
| 1045 cxstring string, | 966 /** |
| 1046 cxstring suffix | 967 * Checks, if a string has a specific suffix, ignoring the case. |
| 1047 ); | 968 * |
| 969 * @param string the string to check | |
| 970 * @param suffix the suffix the string should have | |
| 971 * @return @c true, if and only if the string has the specified suffix, | |
| 972 * @c false otherwise | |
| 973 */ | |
| 974 #define cx_strcasesuffix(string, suffix) cx_strcasesuffix_(cx_strcast(string), cx_strcast(suffix)) | |
| 1048 | 975 |
| 1049 /** | 976 /** |
| 1050 * Replaces a string with another string. | 977 * Replaces a string with another string. |
| 1051 * | 978 * |
| 1052 * Replaces at most @p replmax occurrences. | 979 * The function replaces at most @p replmax occurrences. |
| 1053 * | 980 * |
| 1054 * The returned string will be allocated by @p allocator and is guaranteed | 981 * The returned string will be allocated by @p allocator and is guaranteed |
| 1055 * to be zero-terminated. | 982 * to be zero-terminated. |
| 1056 * | 983 * |
| 1057 * If allocation fails, or the input string is empty, | 984 * If allocation fails, or the input string is empty, |
| 1062 * @param search the string to search for | 989 * @param search the string to search for |
| 1063 * @param replacement the replacement string | 990 * @param replacement the replacement string |
| 1064 * @param replmax maximum number of replacements | 991 * @param replmax maximum number of replacements |
| 1065 * @return the resulting string after applying the replacements | 992 * @return the resulting string after applying the replacements |
| 1066 */ | 993 */ |
| 1067 cx_attr_nodiscard | 994 cx_attr_nodiscard cx_attr_nonnull |
| 1068 cx_attr_nonnull | 995 CX_EXPORT cxmutstr cx_strreplacen_a(const CxAllocator *allocator, |
| 1069 cx_attr_export | 996 cxstring str, cxstring search, cxstring replacement, size_t replmax); |
| 1070 cxmutstr cx_strreplacen_a( | |
| 1071 const CxAllocator *allocator, | |
| 1072 cxstring str, | |
| 1073 cxstring search, | |
| 1074 cxstring replacement, | |
| 1075 size_t replmax | |
| 1076 ); | |
| 1077 | 997 |
| 1078 /** | 998 /** |
| 1079 * Replaces a string with another string. | 999 * Replaces a string with another string. |
| 1080 * | 1000 * |
| 1081 * Replaces at most @p replmax occurrences. | 1001 * The function replaces at most @p replmax occurrences. |
| 1082 * | 1002 * |
| 1083 * The returned string will be allocated by the cxDefaultAllocator and is guaranteed | 1003 * The returned string will be allocated by the cxDefaultAllocator and is guaranteed |
| 1084 * to be zero-terminated. | 1004 * to be zero-terminated. |
| 1085 * | 1005 * |
| 1086 * If allocation fails, or the input string is empty, | 1006 * If allocation fails, or the input string is empty, |
| 1091 * @param replacement (@c cxstring) the replacement string | 1011 * @param replacement (@c cxstring) the replacement string |
| 1092 * @param replmax (@c size_t) maximum number of replacements | 1012 * @param replmax (@c size_t) maximum number of replacements |
| 1093 * @return (@c cxmutstr) the resulting string after applying the replacements | 1013 * @return (@c cxmutstr) the resulting string after applying the replacements |
| 1094 */ | 1014 */ |
| 1095 #define cx_strreplacen(str, search, replacement, replmax) \ | 1015 #define cx_strreplacen(str, search, replacement, replmax) \ |
| 1096 cx_strreplacen_a(cxDefaultAllocator, str, search, replacement, replmax) | 1016 cx_strreplacen_a(cxDefaultAllocator, str, search, replacement, replmax) |
| 1097 | 1017 |
| 1098 /** | 1018 /** |
| 1099 * Replaces a string with another string. | 1019 * Replaces a string with another string. |
| 1100 * | 1020 * |
| 1101 * The returned string will be allocated by @p allocator and is guaranteed | 1021 * The returned string will be allocated by @p allocator and is guaranteed |
| 1109 * @param search (@c cxstring) the string to search for | 1029 * @param search (@c cxstring) the string to search for |
| 1110 * @param replacement (@c cxstring) the replacement string | 1030 * @param replacement (@c cxstring) the replacement string |
| 1111 * @return (@c cxmutstr) the resulting string after applying the replacements | 1031 * @return (@c cxmutstr) the resulting string after applying the replacements |
| 1112 */ | 1032 */ |
| 1113 #define cx_strreplace_a(allocator, str, search, replacement) \ | 1033 #define cx_strreplace_a(allocator, str, search, replacement) \ |
| 1114 cx_strreplacen_a(allocator, str, search, replacement, SIZE_MAX) | 1034 cx_strreplacen_a(allocator, str, search, replacement, SIZE_MAX) |
| 1115 | 1035 |
| 1116 /** | 1036 /** |
| 1117 * Replaces a string with another string. | 1037 * Replaces a string with another string. |
| 1118 * | 1038 * |
| 1119 * The returned string will be allocated by the cxDefaultAllocator and is guaranteed | 1039 * The returned string will be allocated by the cxDefaultAllocator and is guaranteed |
| 1126 * @param search (@c cxstring) the string to search for | 1046 * @param search (@c cxstring) the string to search for |
| 1127 * @param replacement (@c cxstring) the replacement string | 1047 * @param replacement (@c cxstring) the replacement string |
| 1128 * @return (@c cxmutstr) the resulting string after applying the replacements | 1048 * @return (@c cxmutstr) the resulting string after applying the replacements |
| 1129 */ | 1049 */ |
| 1130 #define cx_strreplace(str, search, replacement) \ | 1050 #define cx_strreplace(str, search, replacement) \ |
| 1131 cx_strreplacen_a(cxDefaultAllocator, str, search, replacement, SIZE_MAX) | 1051 cx_strreplacen_a(cxDefaultAllocator, str, search, replacement, SIZE_MAX) |
| 1132 | 1052 |
| 1133 /** | 1053 /** |
| 1134 * Creates a string tokenization context. | 1054 * Creates a string tokenization context. |
| 1135 * | 1055 * |
| 1136 * @param str the string to tokenize | 1056 * @param str the string to tokenize |
| 1137 * @param delim the delimiter (must not be empty) | 1057 * @param delim the delimiter (must not be empty) |
| 1138 * @param limit the maximum number of tokens that shall be returned | 1058 * @param limit the maximum number of tokens that shall be returned |
| 1139 * @return a new string tokenization context | 1059 * @return a new string tokenization context |
| 1140 */ | 1060 */ |
| 1141 cx_attr_nodiscard | 1061 cx_attr_nodiscard |
| 1142 cx_attr_export | 1062 CX_EXPORT CxStrtokCtx cx_strtok_(cxstring str, cxstring delim, size_t limit); |
| 1143 CxStrtokCtx cx_strtok_( | |
| 1144 cxstring str, | |
| 1145 cxstring delim, | |
| 1146 size_t limit | |
| 1147 ); | |
| 1148 | 1063 |
| 1149 /** | 1064 /** |
| 1150 * Creates a string tokenization context. | 1065 * Creates a string tokenization context. |
| 1151 * | 1066 * |
| 1152 * @param str the string to tokenize | 1067 * @param str the string to tokenize |
| 1153 * @param delim the delimiter string (must not be empty) | 1068 * @param delim the delimiter string (must not be empty) |
| 1154 * @param limit (@c size_t) the maximum number of tokens that shall be returned | 1069 * @param limit (@c size_t) the maximum number of tokens that shall be returned |
| 1155 * @return (@c CxStrtokCtx) a new string tokenization context | 1070 * @return (@c CxStrtokCtx) a new string tokenization context |
| 1156 */ | 1071 */ |
| 1157 #define cx_strtok(str, delim, limit) \ | 1072 #define cx_strtok(str, delim, limit) \ |
| 1158 cx_strtok_(cx_strcast(str), cx_strcast(delim), (limit)) | 1073 cx_strtok_(cx_strcast(str), cx_strcast(delim), (limit)) |
| 1159 | 1074 |
| 1160 /** | 1075 /** |
| 1161 * Returns the next token. | 1076 * Returns the next token. |
| 1162 * | 1077 * |
| 1163 * The token will point to the source string. | 1078 * The token will point to the source string. |
| 1165 * @param ctx the tokenization context | 1080 * @param ctx the tokenization context |
| 1166 * @param token a pointer to memory where the next token shall be stored | 1081 * @param token a pointer to memory where the next token shall be stored |
| 1167 * @return true if successful, false if the limit or the end of the string | 1082 * @return true if successful, false if the limit or the end of the string |
| 1168 * has been reached | 1083 * has been reached |
| 1169 */ | 1084 */ |
| 1170 cx_attr_nonnull | 1085 cx_attr_nonnull cx_attr_nodiscard cx_attr_access_w(2) |
| 1171 cx_attr_nodiscard | 1086 CX_EXPORT bool cx_strtok_next(CxStrtokCtx *ctx, cxstring *token); |
| 1172 cx_attr_access_w(2) | |
| 1173 cx_attr_export | |
| 1174 bool cx_strtok_next( | |
| 1175 CxStrtokCtx *ctx, | |
| 1176 cxstring *token | |
| 1177 ); | |
| 1178 | 1087 |
| 1179 /** | 1088 /** |
| 1180 * Returns the next token of a mutable string. | 1089 * Returns the next token of a mutable string. |
| 1181 * | 1090 * |
| 1182 * The token will point to the source string. | 1091 * The token will point to the source string. |
| 1188 * @param ctx the tokenization context | 1097 * @param ctx the tokenization context |
| 1189 * @param token a pointer to memory where the next token shall be stored | 1098 * @param token a pointer to memory where the next token shall be stored |
| 1190 * @return true if successful, false if the limit or the end of the string | 1099 * @return true if successful, false if the limit or the end of the string |
| 1191 * has been reached | 1100 * has been reached |
| 1192 */ | 1101 */ |
| 1193 cx_attr_nonnull | 1102 cx_attr_nonnull cx_attr_nodiscard cx_attr_access_w(2) |
| 1194 cx_attr_nodiscard | 1103 CX_EXPORT bool cx_strtok_next_m(CxStrtokCtx *ctx, cxmutstr *token); |
| 1195 cx_attr_access_w(2) | |
| 1196 cx_attr_export | |
| 1197 bool cx_strtok_next_m( | |
| 1198 CxStrtokCtx *ctx, | |
| 1199 cxmutstr *token | |
| 1200 ); | |
| 1201 | 1104 |
| 1202 /** | 1105 /** |
| 1203 * Defines an array of more delimiters for the specified tokenization context. | 1106 * Defines an array of more delimiters for the specified tokenization context. |
| 1204 * | 1107 * |
| 1205 * @param ctx the tokenization context | 1108 * @param ctx the tokenization context |
| 1206 * @param delim array of more delimiters | 1109 * @param delim array of more delimiters |
| 1207 * @param count number of elements in the array | 1110 * @param count number of elements in the array |
| 1208 */ | 1111 */ |
| 1209 cx_attr_nonnull | 1112 cx_attr_nonnull cx_attr_access_r(2, 3) |
| 1210 cx_attr_access_r(2, 3) | 1113 CX_EXPORT void cx_strtok_delim(CxStrtokCtx *ctx, const cxstring *delim, size_t count); |
| 1211 cx_attr_export | |
| 1212 void cx_strtok_delim( | |
| 1213 CxStrtokCtx *ctx, | |
| 1214 const cxstring *delim, | |
| 1215 size_t count | |
| 1216 ); | |
| 1217 | 1114 |
| 1218 /* ------------------------------------------------------------------------- * | 1115 /* ------------------------------------------------------------------------- * |
| 1219 * string to number conversion functions * | 1116 * string to number conversion functions * |
| 1220 * ------------------------------------------------------------------------- */ | 1117 * ------------------------------------------------------------------------- */ |
| 1221 | 1118 |
| 1227 * It sets errno to ERANGE when the target datatype is too small. | 1124 * It sets errno to ERANGE when the target datatype is too small. |
| 1228 * | 1125 * |
| 1229 * @param str the string to convert | 1126 * @param str the string to convert |
| 1230 * @param output a pointer to the integer variable where the result shall be stored | 1127 * @param output a pointer to the integer variable where the result shall be stored |
| 1231 * @param base 2, 8, 10, or 16 | 1128 * @param base 2, 8, 10, or 16 |
| 1232 * @param groupsep each character in this string is treated as group separator and ignored during conversion | 1129 * @param groupsep each character in this string is treated as a group separator and ignored during conversion |
| 1233 * @retval zero success | 1130 * @retval zero success |
| 1234 * @retval non-zero conversion was not possible | 1131 * @retval non-zero conversion was not possible |
| 1235 */ | 1132 */ |
| 1236 cx_attr_access_w(2) cx_attr_nonnull_arg(2) cx_attr_export | 1133 cx_attr_access_w(2) cx_attr_nonnull_arg(2) |
| 1237 int cx_strtos_lc_(cxstring str, short *output, int base, const char *groupsep); | 1134 CX_EXPORT int cx_strtos_lc_(cxstring str, short *output, int base, const char *groupsep); |
| 1238 | 1135 |
| 1239 /** | 1136 /** |
| 1240 * Converts a string to a number. | 1137 * Converts a string to a number. |
| 1241 * | 1138 * |
| 1242 * The function returns non-zero when conversion is not possible. | 1139 * The function returns non-zero when conversion is not possible. |
| 1243 * In that case the function sets errno to EINVAL when the reason is an invalid character or an unsupported base. | 1140 * In that case the function sets errno to EINVAL when the reason is an invalid character or an unsupported base. |
| 1244 * It sets errno to ERANGE when the target datatype is too small. | 1141 * It sets errno to ERANGE when the target datatype is too small. |
| 1245 * | 1142 * |
| 1246 * @param str the string to convert | 1143 * @param str the string to convert |
| 1247 * @param output a pointer to the integer variable where the result shall be stored | 1144 * @param output a pointer to the integer variable where the result shall be stored |
| 1248 * @param base 2, 8, 10, or 16 | 1145 * @param base 2, 8, 10, or 16 |
| 1249 * @param groupsep each character in this string is treated as group separator and ignored during conversion | 1146 * @param groupsep each character in this string is treated as a group separator and ignored during conversion |
| 1250 * @retval zero success | 1147 * @retval zero success |
| 1251 * @retval non-zero conversion was not possible | 1148 * @retval non-zero conversion was not possible |
| 1252 */ | 1149 */ |
| 1253 cx_attr_access_w(2) cx_attr_nonnull_arg(2) cx_attr_export | 1150 cx_attr_access_w(2) cx_attr_nonnull_arg(2) |
| 1254 int cx_strtoi_lc_(cxstring str, int *output, int base, const char *groupsep); | 1151 CX_EXPORT int cx_strtoi_lc_(cxstring str, int *output, int base, const char *groupsep); |
| 1255 | 1152 |
| 1256 /** | 1153 /** |
| 1257 * Converts a string to a number. | 1154 * Converts a string to a number. |
| 1258 * | 1155 * |
| 1259 * The function returns non-zero when conversion is not possible. | 1156 * The function returns non-zero when conversion is not possible. |
| 1260 * In that case the function sets errno to EINVAL when the reason is an invalid character or an unsupported base. | 1157 * In that case the function sets errno to EINVAL when the reason is an invalid character or an unsupported base. |
| 1261 * It sets errno to ERANGE when the target datatype is too small. | 1158 * It sets errno to ERANGE when the target datatype is too small. |
| 1262 * | 1159 * |
| 1263 * @param str the string to convert | 1160 * @param str the string to convert |
| 1264 * @param output a pointer to the integer variable where the result shall be stored | 1161 * @param output a pointer to the integer variable where the result shall be stored |
| 1265 * @param base 2, 8, 10, or 16 | 1162 * @param base 2, 8, 10, or 16 |
| 1266 * @param groupsep each character in this string is treated as group separator and ignored during conversion | 1163 * @param groupsep each character in this string is treated as a group separator and ignored during conversion |
| 1267 * @retval zero success | 1164 * @retval zero success |
| 1268 * @retval non-zero conversion was not possible | 1165 * @retval non-zero conversion was not possible |
| 1269 */ | 1166 */ |
| 1270 cx_attr_access_w(2) cx_attr_nonnull_arg(2) cx_attr_export | 1167 cx_attr_access_w(2) cx_attr_nonnull_arg(2) |
| 1271 int cx_strtol_lc_(cxstring str, long *output, int base, const char *groupsep); | 1168 CX_EXPORT int cx_strtol_lc_(cxstring str, long *output, int base, const char *groupsep); |
| 1272 | 1169 |
| 1273 /** | 1170 /** |
| 1274 * Converts a string to a number. | 1171 * Converts a string to a number. |
| 1275 * | 1172 * |
| 1276 * The function returns non-zero when conversion is not possible. | 1173 * The function returns non-zero when conversion is not possible. |
| 1277 * In that case the function sets errno to EINVAL when the reason is an invalid character or an unsupported base. | 1174 * In that case the function sets errno to EINVAL when the reason is an invalid character or an unsupported base. |
| 1278 * It sets errno to ERANGE when the target datatype is too small. | 1175 * It sets errno to ERANGE when the target datatype is too small. |
| 1279 * | 1176 * |
| 1280 * @param str the string to convert | 1177 * @param str the string to convert |
| 1281 * @param output a pointer to the integer variable where the result shall be stored | 1178 * @param output a pointer to the integer variable where the result shall be stored |
| 1282 * @param base 2, 8, 10, or 16 | 1179 * @param base 2, 8, 10, or 16 |
| 1283 * @param groupsep each character in this string is treated as group separator and ignored during conversion | 1180 * @param groupsep each character in this string is treated as a group separator and ignored during conversion |
| 1284 * @retval zero success | 1181 * @retval zero success |
| 1285 * @retval non-zero conversion was not possible | 1182 * @retval non-zero conversion was not possible |
| 1286 */ | 1183 */ |
| 1287 cx_attr_access_w(2) cx_attr_nonnull_arg(2) cx_attr_export | 1184 cx_attr_access_w(2) cx_attr_nonnull_arg(2) |
| 1288 int cx_strtoll_lc_(cxstring str, long long *output, int base, const char *groupsep); | 1185 CX_EXPORT int cx_strtoll_lc_(cxstring str, long long *output, int base, const char *groupsep); |
| 1289 | 1186 |
| 1290 /** | 1187 /** |
| 1291 * Converts a string to a number. | 1188 * Converts a string to a number. |
| 1292 * | 1189 * |
| 1293 * The function returns non-zero when conversion is not possible. | 1190 * The function returns non-zero when conversion is not possible. |
| 1294 * In that case the function sets errno to EINVAL when the reason is an invalid character or an unsupported base. | 1191 * In that case the function sets errno to EINVAL when the reason is an invalid character or an unsupported base. |
| 1295 * It sets errno to ERANGE when the target datatype is too small. | 1192 * It sets errno to ERANGE when the target datatype is too small. |
| 1296 * | 1193 * |
| 1297 * @param str the string to convert | 1194 * @param str the string to convert |
| 1298 * @param output a pointer to the integer variable where the result shall be stored | 1195 * @param output a pointer to the integer variable where the result shall be stored |
| 1299 * @param base 2, 8, 10, or 16 | 1196 * @param base 2, 8, 10, or 16 |
| 1300 * @param groupsep each character in this string is treated as group separator and ignored during conversion | 1197 * @param groupsep each character in this string is treated as a group separator and ignored during conversion |
| 1301 * @retval zero success | 1198 * @retval zero success |
| 1302 * @retval non-zero conversion was not possible | 1199 * @retval non-zero conversion was not possible |
| 1303 */ | 1200 */ |
| 1304 cx_attr_access_w(2) cx_attr_nonnull_arg(2) cx_attr_export | 1201 cx_attr_access_w(2) cx_attr_nonnull_arg(2) |
| 1305 int cx_strtoi8_lc_(cxstring str, int8_t *output, int base, const char *groupsep); | 1202 CX_EXPORT int cx_strtoi8_lc_(cxstring str, int8_t *output, int base, const char *groupsep); |
| 1306 | 1203 |
| 1307 /** | 1204 /** |
| 1308 * Converts a string to a number. | 1205 * Converts a string to a number. |
| 1309 * | 1206 * |
| 1310 * The function returns non-zero when conversion is not possible. | 1207 * The function returns non-zero when conversion is not possible. |
| 1311 * In that case the function sets errno to EINVAL when the reason is an invalid character or an unsupported base. | 1208 * In that case the function sets errno to EINVAL when the reason is an invalid character or an unsupported base. |
| 1312 * It sets errno to ERANGE when the target datatype is too small. | 1209 * It sets errno to ERANGE when the target datatype is too small. |
| 1313 * | 1210 * |
| 1314 * @param str the string to convert | 1211 * @param str the string to convert |
| 1315 * @param output a pointer to the integer variable where the result shall be stored | 1212 * @param output a pointer to the integer variable where the result shall be stored |
| 1316 * @param base 2, 8, 10, or 16 | 1213 * @param base 2, 8, 10, or 16 |
| 1317 * @param groupsep each character in this string is treated as group separator and ignored during conversion | 1214 * @param groupsep each character in this string is treated as a group separator and ignored during conversion |
| 1318 * @retval zero success | 1215 * @retval zero success |
| 1319 * @retval non-zero conversion was not possible | 1216 * @retval non-zero conversion was not possible |
| 1320 */ | 1217 */ |
| 1321 cx_attr_access_w(2) cx_attr_nonnull_arg(2) cx_attr_export | 1218 cx_attr_access_w(2) cx_attr_nonnull_arg(2) |
| 1322 int cx_strtoi16_lc_(cxstring str, int16_t *output, int base, const char *groupsep); | 1219 CX_EXPORT int cx_strtoi16_lc_(cxstring str, int16_t *output, int base, const char *groupsep); |
| 1323 | 1220 |
| 1324 /** | 1221 /** |
| 1325 * Converts a string to a number. | 1222 * Converts a string to a number. |
| 1326 * | 1223 * |
| 1327 * The function returns non-zero when conversion is not possible. | 1224 * The function returns non-zero when conversion is not possible. |
| 1328 * In that case the function sets errno to EINVAL when the reason is an invalid character or an unsupported base. | 1225 * In that case the function sets errno to EINVAL when the reason is an invalid character or an unsupported base. |
| 1329 * It sets errno to ERANGE when the target datatype is too small. | 1226 * It sets errno to ERANGE when the target datatype is too small. |
| 1330 * | 1227 * |
| 1331 * @param str the string to convert | 1228 * @param str the string to convert |
| 1332 * @param output a pointer to the integer variable where the result shall be stored | 1229 * @param output a pointer to the integer variable where the result shall be stored |
| 1333 * @param base 2, 8, 10, or 16 | 1230 * @param base 2, 8, 10, or 16 |
| 1334 * @param groupsep each character in this string is treated as group separator and ignored during conversion | 1231 * @param groupsep each character in this string is treated as a group separator and ignored during conversion |
| 1335 * @retval zero success | 1232 * @retval zero success |
| 1336 * @retval non-zero conversion was not possible | 1233 * @retval non-zero conversion was not possible |
| 1337 */ | 1234 */ |
| 1338 cx_attr_access_w(2) cx_attr_nonnull_arg(2) cx_attr_export | 1235 cx_attr_access_w(2) cx_attr_nonnull_arg(2) |
| 1339 int cx_strtoi32_lc_(cxstring str, int32_t *output, int base, const char *groupsep); | 1236 CX_EXPORT int cx_strtoi32_lc_(cxstring str, int32_t *output, int base, const char *groupsep); |
| 1340 | 1237 |
| 1341 /** | 1238 /** |
| 1342 * Converts a string to a number. | 1239 * Converts a string to a number. |
| 1343 * | 1240 * |
| 1344 * The function returns non-zero when conversion is not possible. | 1241 * The function returns non-zero when conversion is not possible. |
| 1345 * In that case the function sets errno to EINVAL when the reason is an invalid character or an unsupported base. | 1242 * In that case the function sets errno to EINVAL when the reason is an invalid character or an unsupported base. |
| 1346 * It sets errno to ERANGE when the target datatype is too small. | 1243 * It sets errno to ERANGE when the target datatype is too small. |
| 1347 * | 1244 * |
| 1348 * @param str the string to convert | 1245 * @param str the string to convert |
| 1349 * @param output a pointer to the integer variable where the result shall be stored | 1246 * @param output a pointer to the integer variable where the result shall be stored |
| 1350 * @param base 2, 8, 10, or 16 | 1247 * @param base 2, 8, 10, or 16 |
| 1351 * @param groupsep each character in this string is treated as group separator and ignored during conversion | 1248 * @param groupsep each character in this string is treated as a group separator and ignored during conversion |
| 1352 * @retval zero success | 1249 * @retval zero success |
| 1353 * @retval non-zero conversion was not possible | 1250 * @retval non-zero conversion was not possible |
| 1354 */ | 1251 */ |
| 1355 cx_attr_access_w(2) cx_attr_nonnull_arg(2) cx_attr_export | 1252 cx_attr_access_w(2) cx_attr_nonnull_arg(2) |
| 1356 int cx_strtoi64_lc_(cxstring str, int64_t *output, int base, const char *groupsep); | 1253 CX_EXPORT int cx_strtoi64_lc_(cxstring str, int64_t *output, int base, const char *groupsep); |
| 1357 | 1254 |
| 1358 /** | 1255 /** |
| 1359 * Converts a string to a number. | 1256 * Converts a string to a number. |
| 1360 * | 1257 * |
| 1361 * The function returns non-zero when conversion is not possible. | 1258 * The function returns non-zero when conversion is not possible. |
| 1362 * In that case the function sets errno to EINVAL when the reason is an invalid character or an unsupported base. | 1259 * In that case the function sets errno to EINVAL when the reason is an invalid character or an unsupported base. |
| 1363 * It sets errno to ERANGE when the target datatype is too small. | 1260 * It sets errno to ERANGE when the target datatype is too small. |
| 1364 * | 1261 * |
| 1365 * @param str the string to convert | 1262 * @param str the string to convert |
| 1366 * @param output a pointer to the integer variable where the result shall be stored | 1263 * @param output a pointer to the integer variable where the result shall be stored |
| 1367 * @param base 2, 8, 10, or 16 | 1264 * @param base 2, 8, 10, or 16 |
| 1368 * @param groupsep each character in this string is treated as group separator and ignored during conversion | 1265 * @param groupsep each character in this string is treated as a group separator and ignored during conversion |
| 1369 * @retval zero success | 1266 * @retval zero success |
| 1370 * @retval non-zero conversion was not possible | 1267 * @retval non-zero conversion was not possible |
| 1371 */ | 1268 */ |
| 1372 cx_attr_access_w(2) cx_attr_nonnull_arg(2) cx_attr_export | 1269 cx_attr_access_w(2) cx_attr_nonnull_arg(2) |
| 1373 int cx_strtous_lc_(cxstring str, unsigned short *output, int base, const char *groupsep); | 1270 CX_EXPORT int cx_strtous_lc_(cxstring str, unsigned short *output, int base, const char *groupsep); |
| 1374 | 1271 |
| 1375 /** | 1272 /** |
| 1376 * Converts a string to a number. | 1273 * Converts a string to a number. |
| 1377 * | 1274 * |
| 1378 * The function returns non-zero when conversion is not possible. | 1275 * The function returns non-zero when conversion is not possible. |
| 1379 * In that case the function sets errno to EINVAL when the reason is an invalid character or an unsupported base. | 1276 * In that case the function sets errno to EINVAL when the reason is an invalid character or an unsupported base. |
| 1380 * It sets errno to ERANGE when the target datatype is too small. | 1277 * It sets errno to ERANGE when the target datatype is too small. |
| 1381 * | 1278 * |
| 1382 * @param str the string to convert | 1279 * @param str the string to convert |
| 1383 * @param output a pointer to the integer variable where the result shall be stored | 1280 * @param output a pointer to the integer variable where the result shall be stored |
| 1384 * @param base 2, 8, 10, or 16 | 1281 * @param base 2, 8, 10, or 16 |
| 1385 * @param groupsep each character in this string is treated as group separator and ignored during conversion | 1282 * @param groupsep each character in this string is treated as a group separator and ignored during conversion |
| 1386 * @retval zero success | 1283 * @retval zero success |
| 1387 * @retval non-zero conversion was not possible | 1284 * @retval non-zero conversion was not possible |
| 1388 */ | 1285 */ |
| 1389 cx_attr_access_w(2) cx_attr_nonnull_arg(2) cx_attr_export | 1286 cx_attr_access_w(2) cx_attr_nonnull_arg(2) |
| 1390 int cx_strtou_lc_(cxstring str, unsigned int *output, int base, const char *groupsep); | 1287 CX_EXPORT int cx_strtou_lc_(cxstring str, unsigned int *output, int base, const char *groupsep); |
| 1391 | 1288 |
| 1392 /** | 1289 /** |
| 1393 * Converts a string to a number. | 1290 * Converts a string to a number. |
| 1394 * | 1291 * |
| 1395 * The function returns non-zero when conversion is not possible. | 1292 * The function returns non-zero when conversion is not possible. |
| 1396 * In that case the function sets errno to EINVAL when the reason is an invalid character or an unsupported base. | 1293 * In that case the function sets errno to EINVAL when the reason is an invalid character or an unsupported base. |
| 1397 * It sets errno to ERANGE when the target datatype is too small. | 1294 * It sets errno to ERANGE when the target datatype is too small. |
| 1398 * | 1295 * |
| 1399 * @param str the string to convert | 1296 * @param str the string to convert |
| 1400 * @param output a pointer to the integer variable where the result shall be stored | 1297 * @param output a pointer to the integer variable where the result shall be stored |
| 1401 * @param base 2, 8, 10, or 16 | 1298 * @param base 2, 8, 10, or 16 |
| 1402 * @param groupsep each character in this string is treated as group separator and ignored during conversion | 1299 * @param groupsep each character in this string is treated as a group separator and ignored during conversion |
| 1403 * @retval zero success | 1300 * @retval zero success |
| 1404 * @retval non-zero conversion was not possible | 1301 * @retval non-zero conversion was not possible |
| 1405 */ | 1302 */ |
| 1406 cx_attr_access_w(2) cx_attr_nonnull_arg(2) cx_attr_export | 1303 cx_attr_access_w(2) cx_attr_nonnull_arg(2) |
| 1407 int cx_strtoul_lc_(cxstring str, unsigned long *output, int base, const char *groupsep); | 1304 CX_EXPORT int cx_strtoul_lc_(cxstring str, unsigned long *output, int base, const char *groupsep); |
| 1408 | 1305 |
| 1409 /** | 1306 /** |
| 1410 * Converts a string to a number. | 1307 * Converts a string to a number. |
| 1411 * | 1308 * |
| 1412 * The function returns non-zero when conversion is not possible. | 1309 * The function returns non-zero when conversion is not possible. |
| 1413 * In that case the function sets errno to EINVAL when the reason is an invalid character or an unsupported base. | 1310 * In that case the function sets errno to EINVAL when the reason is an invalid character or an unsupported base. |
| 1414 * It sets errno to ERANGE when the target datatype is too small. | 1311 * It sets errno to ERANGE when the target datatype is too small. |
| 1415 * | 1312 * |
| 1416 * @param str the string to convert | 1313 * @param str the string to convert |
| 1417 * @param output a pointer to the integer variable where the result shall be stored | 1314 * @param output a pointer to the integer variable where the result shall be stored |
| 1418 * @param base 2, 8, 10, or 16 | 1315 * @param base 2, 8, 10, or 16 |
| 1419 * @param groupsep each character in this string is treated as group separator and ignored during conversion | 1316 * @param groupsep each character in this string is treated as a group separator and ignored during conversion |
| 1420 * @retval zero success | 1317 * @retval zero success |
| 1421 * @retval non-zero conversion was not possible | 1318 * @retval non-zero conversion was not possible |
| 1422 */ | 1319 */ |
| 1423 cx_attr_access_w(2) cx_attr_nonnull_arg(2) cx_attr_export | 1320 cx_attr_access_w(2) cx_attr_nonnull_arg(2) |
| 1424 int cx_strtoull_lc_(cxstring str, unsigned long long *output, int base, const char *groupsep); | 1321 CX_EXPORT int cx_strtoull_lc_(cxstring str, unsigned long long *output, int base, const char *groupsep); |
| 1425 | 1322 |
| 1426 /** | 1323 /** |
| 1427 * Converts a string to a number. | 1324 * Converts a string to a number. |
| 1428 * | 1325 * |
| 1429 * The function returns non-zero when conversion is not possible. | 1326 * The function returns non-zero when conversion is not possible. |
| 1430 * In that case the function sets errno to EINVAL when the reason is an invalid character or an unsupported base. | 1327 * In that case the function sets errno to EINVAL when the reason is an invalid character or an unsupported base. |
| 1431 * It sets errno to ERANGE when the target datatype is too small. | 1328 * It sets errno to ERANGE when the target datatype is too small. |
| 1432 * | 1329 * |
| 1433 * @param str the string to convert | 1330 * @param str the string to convert |
| 1434 * @param output a pointer to the integer variable where the result shall be stored | 1331 * @param output a pointer to the integer variable where the result shall be stored |
| 1435 * @param base 2, 8, 10, or 16 | 1332 * @param base 2, 8, 10, or 16 |
| 1436 * @param groupsep each character in this string is treated as group separator and ignored during conversion | 1333 * @param groupsep each character in this string is treated as a group separator and ignored during conversion |
| 1437 * @retval zero success | 1334 * @retval zero success |
| 1438 * @retval non-zero conversion was not possible | 1335 * @retval non-zero conversion was not possible |
| 1439 */ | 1336 */ |
| 1440 cx_attr_access_w(2) cx_attr_nonnull_arg(2) cx_attr_export | 1337 cx_attr_access_w(2) cx_attr_nonnull_arg(2) |
| 1441 int cx_strtou8_lc_(cxstring str, uint8_t *output, int base, const char *groupsep); | 1338 CX_EXPORT int cx_strtou8_lc_(cxstring str, uint8_t *output, int base, const char *groupsep); |
| 1442 | 1339 |
| 1443 /** | 1340 /** |
| 1444 * Converts a string to a number. | 1341 * Converts a string to a number. |
| 1445 * | 1342 * |
| 1446 * The function returns non-zero when conversion is not possible. | 1343 * The function returns non-zero when conversion is not possible. |
| 1447 * In that case the function sets errno to EINVAL when the reason is an invalid character or an unsupported base. | 1344 * In that case the function sets errno to EINVAL when the reason is an invalid character or an unsupported base. |
| 1448 * It sets errno to ERANGE when the target datatype is too small. | 1345 * It sets errno to ERANGE when the target datatype is too small. |
| 1449 * | 1346 * |
| 1450 * @param str the string to convert | 1347 * @param str the string to convert |
| 1451 * @param output a pointer to the integer variable where the result shall be stored | 1348 * @param output a pointer to the integer variable where the result shall be stored |
| 1452 * @param base 2, 8, 10, or 16 | 1349 * @param base 2, 8, 10, or 16 |
| 1453 * @param groupsep each character in this string is treated as group separator and ignored during conversion | 1350 * @param groupsep each character in this string is treated as a group separator and ignored during conversion |
| 1454 * @retval zero success | 1351 * @retval zero success |
| 1455 * @retval non-zero conversion was not possible | 1352 * @retval non-zero conversion was not possible |
| 1456 */ | 1353 */ |
| 1457 cx_attr_access_w(2) cx_attr_nonnull_arg(2) cx_attr_export | 1354 cx_attr_access_w(2) cx_attr_nonnull_arg(2) |
| 1458 int cx_strtou16_lc_(cxstring str, uint16_t *output, int base, const char *groupsep); | 1355 CX_EXPORT int cx_strtou16_lc_(cxstring str, uint16_t *output, int base, const char *groupsep); |
| 1459 | 1356 |
| 1460 /** | 1357 /** |
| 1461 * Converts a string to a number. | 1358 * Converts a string to a number. |
| 1462 * | 1359 * |
| 1463 * The function returns non-zero when conversion is not possible. | 1360 * The function returns non-zero when conversion is not possible. |
| 1464 * In that case the function sets errno to EINVAL when the reason is an invalid character or an unsupported base. | 1361 * In that case the function sets errno to EINVAL when the reason is an invalid character or an unsupported base. |
| 1465 * It sets errno to ERANGE when the target datatype is too small. | 1362 * It sets errno to ERANGE when the target datatype is too small. |
| 1466 * | 1363 * |
| 1467 * @param str the string to convert | 1364 * @param str the string to convert |
| 1468 * @param output a pointer to the integer variable where the result shall be stored | 1365 * @param output a pointer to the integer variable where the result shall be stored |
| 1469 * @param base 2, 8, 10, or 16 | 1366 * @param base 2, 8, 10, or 16 |
| 1470 * @param groupsep each character in this string is treated as group separator and ignored during conversion | 1367 * @param groupsep each character in this string is treated as a group separator and ignored during conversion |
| 1471 * @retval zero success | 1368 * @retval zero success |
| 1472 * @retval non-zero conversion was not possible | 1369 * @retval non-zero conversion was not possible |
| 1473 */ | 1370 */ |
| 1474 cx_attr_access_w(2) cx_attr_nonnull_arg(2) cx_attr_export | 1371 cx_attr_access_w(2) cx_attr_nonnull_arg(2) |
| 1475 int cx_strtou32_lc_(cxstring str, uint32_t *output, int base, const char *groupsep); | 1372 CX_EXPORT int cx_strtou32_lc_(cxstring str, uint32_t *output, int base, const char *groupsep); |
| 1476 | 1373 |
| 1477 /** | 1374 /** |
| 1478 * Converts a string to a number. | 1375 * Converts a string to a number. |
| 1479 * | 1376 * |
| 1480 * The function returns non-zero when conversion is not possible. | 1377 * The function returns non-zero when conversion is not possible. |
| 1481 * In that case the function sets errno to EINVAL when the reason is an invalid character or an unsupported base. | 1378 * In that case the function sets errno to EINVAL when the reason is an invalid character or an unsupported base. |
| 1482 * It sets errno to ERANGE when the target datatype is too small. | 1379 * It sets errno to ERANGE when the target datatype is too small. |
| 1483 * | 1380 * |
| 1484 * @param str the string to convert | 1381 * @param str the string to convert |
| 1485 * @param output a pointer to the integer variable where the result shall be stored | 1382 * @param output a pointer to the integer variable where the result shall be stored |
| 1486 * @param base 2, 8, 10, or 16 | 1383 * @param base 2, 8, 10, or 16 |
| 1487 * @param groupsep each character in this string is treated as group separator and ignored during conversion | 1384 * @param groupsep each character in this string is treated as a group separator and ignored during conversion |
| 1488 * @retval zero success | 1385 * @retval zero success |
| 1489 * @retval non-zero conversion was not possible | 1386 * @retval non-zero conversion was not possible |
| 1490 */ | 1387 */ |
| 1491 cx_attr_access_w(2) cx_attr_nonnull_arg(2) cx_attr_export | 1388 cx_attr_access_w(2) cx_attr_nonnull_arg(2) |
| 1492 int cx_strtou64_lc_(cxstring str, uint64_t *output, int base, const char *groupsep); | 1389 CX_EXPORT int cx_strtou64_lc_(cxstring str, uint64_t *output, int base, const char *groupsep); |
| 1493 | 1390 |
| 1494 /** | 1391 /** |
| 1495 * Converts a string to a number. | 1392 * Converts a string to a number. |
| 1496 * | 1393 * |
| 1497 * The function returns non-zero when conversion is not possible. | 1394 * The function returns non-zero when conversion is not possible. |
| 1498 * In that case the function sets errno to EINVAL when the reason is an invalid character or an unsupported base. | 1395 * In that case the function sets errno to EINVAL when the reason is an invalid character or an unsupported base. |
| 1499 * It sets errno to ERANGE when the target datatype is too small. | 1396 * It sets errno to ERANGE when the target datatype is too small. |
| 1500 * | 1397 * |
| 1501 * @param str the string to convert | 1398 * @param str the string to convert |
| 1502 * @param output a pointer to the integer variable where the result shall be stored | 1399 * @param output a pointer to the integer variable where the result shall be stored |
| 1503 * @param base 2, 8, 10, or 16 | 1400 * @param base 2, 8, 10, or 16 |
| 1504 * @param groupsep each character in this string is treated as group separator and ignored during conversion | 1401 * @param groupsep each character in this string is treated as a group separator and ignored during conversion |
| 1505 * @retval zero success | 1402 * @retval zero success |
| 1506 * @retval non-zero conversion was not possible | 1403 * @retval non-zero conversion was not possible |
| 1507 */ | 1404 */ |
| 1508 cx_attr_access_w(2) cx_attr_nonnull_arg(2) cx_attr_export | 1405 cx_attr_access_w(2) cx_attr_nonnull_arg(2) |
| 1509 int cx_strtoz_lc_(cxstring str, size_t *output, int base, const char *groupsep); | 1406 CX_EXPORT int cx_strtoz_lc_(cxstring str, size_t *output, int base, const char *groupsep); |
| 1510 | 1407 |
| 1511 /** | 1408 /** |
| 1512 * Converts a string to a single precision floating point number. | 1409 * Converts a string to a single precision floating-point number. |
| 1513 * | 1410 * |
| 1514 * The function returns non-zero when conversion is not possible. | 1411 * The function returns non-zero when conversion is not possible. |
| 1515 * In that case the function sets errno to EINVAL when the reason is an invalid character. | 1412 * In that case the function sets errno to EINVAL when the reason is an invalid character. |
| 1516 * It sets errno to ERANGE when the necessary representation would exceed the limits defined in libc's float.h. | 1413 * It sets errno to ERANGE when the necessary representation would exceed the limits defined in libc's float.h. |
| 1517 * | 1414 * |
| 1518 * @param str the string to convert | 1415 * @param str the string to convert |
| 1519 * @param output a pointer to the float variable where the result shall be stored | 1416 * @param output a pointer to the float variable where the result shall be stored |
| 1520 * @param decsep the decimal separator | 1417 * @param decsep the decimal separator |
| 1521 * @param groupsep each character in this string is treated as group separator and ignored during conversion | 1418 * @param groupsep each character in this string is treated as a group separator and ignored during conversion |
| 1522 * @retval zero success | 1419 * @retval zero success |
| 1523 * @retval non-zero conversion was not possible | 1420 * @retval non-zero conversion was not possible |
| 1524 */ | 1421 */ |
| 1525 cx_attr_access_w(2) cx_attr_nonnull_arg(2) cx_attr_export | 1422 cx_attr_access_w(2) cx_attr_nonnull_arg(2) |
| 1526 int cx_strtof_lc_(cxstring str, float *output, char decsep, const char *groupsep); | 1423 CX_EXPORT int cx_strtof_lc_(cxstring str, float *output, char decsep, const char *groupsep); |
| 1527 | 1424 |
| 1528 /** | 1425 /** |
| 1529 * Converts a string to a double precision floating point number. | 1426 * Converts a string to a double precision floating-point number. |
| 1530 * | 1427 * |
| 1531 * The function returns non-zero when conversion is not possible. | 1428 * The function returns non-zero when conversion is not possible. |
| 1532 * In that case the function sets errno to EINVAL when the reason is an invalid character. | 1429 * In that case the function sets errno to EINVAL when the reason is an invalid character. |
| 1533 * It sets errno to ERANGE when the necessary representation would exceed the limits defined in libc's float.h. | 1430 * It sets errno to ERANGE when the necessary representation would exceed the limits defined in libc's float.h. |
| 1534 * | 1431 * |
| 1535 * @param str the string to convert | 1432 * @param str the string to convert |
| 1536 * @param output a pointer to the float variable where the result shall be stored | 1433 * @param output a pointer to the float variable where the result shall be stored |
| 1537 * @param decsep the decimal separator | 1434 * @param decsep the decimal separator |
| 1538 * @param groupsep each character in this string is treated as group separator and ignored during conversion | 1435 * @param groupsep each character in this string is treated as a group separator and ignored during conversion |
| 1539 * @retval zero success | 1436 * @retval zero success |
| 1540 * @retval non-zero conversion was not possible | 1437 * @retval non-zero conversion was not possible |
| 1541 */ | 1438 */ |
| 1542 cx_attr_access_w(2) cx_attr_nonnull_arg(2) cx_attr_export | 1439 cx_attr_access_w(2) cx_attr_nonnull_arg(2) |
| 1543 int cx_strtod_lc_(cxstring str, double *output, char decsep, const char *groupsep); | 1440 CX_EXPORT int cx_strtod_lc_(cxstring str, double *output, char decsep, const char *groupsep); |
| 1544 | 1441 |
| 1545 /** | 1442 /** |
| 1546 * Converts a string to a number. | 1443 * Converts a string to a number. |
| 1547 * | 1444 * |
| 1548 * The function returns non-zero when conversion is not possible. | 1445 * The function returns non-zero when conversion is not possible. |
| 1549 * In that case the function sets errno to EINVAL when the reason is an invalid character or an unsupported base. | 1446 * In that case the function sets errno to EINVAL when the reason is an invalid character or an unsupported base. |
| 1550 * It sets errno to ERANGE when the target datatype is too small. | 1447 * It sets errno to ERANGE when the target datatype is too small. |
| 1551 * | 1448 * |
| 1552 * @param str the string to convert | 1449 * @param str the string to convert |
| 1553 * @param output a pointer to the integer variable where the result shall be stored | 1450 * @param output a pointer to the integer variable where the result shall be stored |
| 1554 * @param base 2, 8, 10, or 16 | 1451 * @param base 2, 8, 10, or 16 |
| 1555 * @param groupsep (@c const @c char*) each character in this string is treated as group separator and ignored during conversion | 1452 * @param groupsep (@c const @c char*) each character in this string is treated as a group separator and ignored during conversion |
| 1556 * @retval zero success | 1453 * @retval zero success |
| 1557 * @retval non-zero conversion was not possible | 1454 * @retval non-zero conversion was not possible |
| 1558 */ | 1455 */ |
| 1559 #define cx_strtos_lc(str, output, base, groupsep) cx_strtos_lc_(cx_strcast(str), output, base, groupsep) | 1456 #define cx_strtos_lc(str, output, base, groupsep) cx_strtos_lc_(cx_strcast(str), output, base, groupsep) |
| 1560 | 1457 |
| 1566 * It sets errno to ERANGE when the target datatype is too small. | 1463 * It sets errno to ERANGE when the target datatype is too small. |
| 1567 * | 1464 * |
| 1568 * @param str the string to convert | 1465 * @param str the string to convert |
| 1569 * @param output a pointer to the integer variable where the result shall be stored | 1466 * @param output a pointer to the integer variable where the result shall be stored |
| 1570 * @param base 2, 8, 10, or 16 | 1467 * @param base 2, 8, 10, or 16 |
| 1571 * @param groupsep (@c const @c char*) each character in this string is treated as group separator and ignored during conversion | 1468 * @param groupsep (@c const @c char*) each character in this string is treated as a group separator and ignored during conversion |
| 1572 * @retval zero success | 1469 * @retval zero success |
| 1573 * @retval non-zero conversion was not possible | 1470 * @retval non-zero conversion was not possible |
| 1574 */ | 1471 */ |
| 1575 #define cx_strtoi_lc(str, output, base, groupsep) cx_strtoi_lc_(cx_strcast(str), output, base, groupsep) | 1472 #define cx_strtoi_lc(str, output, base, groupsep) cx_strtoi_lc_(cx_strcast(str), output, base, groupsep) |
| 1576 | 1473 |
| 1582 * It sets errno to ERANGE when the target datatype is too small. | 1479 * It sets errno to ERANGE when the target datatype is too small. |
| 1583 * | 1480 * |
| 1584 * @param str the string to convert | 1481 * @param str the string to convert |
| 1585 * @param output a pointer to the integer variable where the result shall be stored | 1482 * @param output a pointer to the integer variable where the result shall be stored |
| 1586 * @param base 2, 8, 10, or 16 | 1483 * @param base 2, 8, 10, or 16 |
| 1587 * @param groupsep (@c const @c char*) each character in this string is treated as group separator and ignored during conversion | 1484 * @param groupsep (@c const @c char*) each character in this string is treated as a group separator and ignored during conversion |
| 1588 * @retval zero success | 1485 * @retval zero success |
| 1589 * @retval non-zero conversion was not possible | 1486 * @retval non-zero conversion was not possible |
| 1590 */ | 1487 */ |
| 1591 #define cx_strtol_lc(str, output, base, groupsep) cx_strtol_lc_(cx_strcast(str), output, base, groupsep) | 1488 #define cx_strtol_lc(str, output, base, groupsep) cx_strtol_lc_(cx_strcast(str), output, base, groupsep) |
| 1592 | 1489 |
| 1598 * It sets errno to ERANGE when the target datatype is too small. | 1495 * It sets errno to ERANGE when the target datatype is too small. |
| 1599 * | 1496 * |
| 1600 * @param str the string to convert | 1497 * @param str the string to convert |
| 1601 * @param output a pointer to the integer variable where the result shall be stored | 1498 * @param output a pointer to the integer variable where the result shall be stored |
| 1602 * @param base 2, 8, 10, or 16 | 1499 * @param base 2, 8, 10, or 16 |
| 1603 * @param groupsep (@c const @c char*) each character in this string is treated as group separator and ignored during conversion | 1500 * @param groupsep (@c const @c char*) each character in this string is treated as a group separator and ignored during conversion |
| 1604 * @retval zero success | 1501 * @retval zero success |
| 1605 * @retval non-zero conversion was not possible | 1502 * @retval non-zero conversion was not possible |
| 1606 */ | 1503 */ |
| 1607 #define cx_strtoll_lc(str, output, base, groupsep) cx_strtoll_lc_(cx_strcast(str), output, base, groupsep) | 1504 #define cx_strtoll_lc(str, output, base, groupsep) cx_strtoll_lc_(cx_strcast(str), output, base, groupsep) |
| 1608 | 1505 |
| 1614 * It sets errno to ERANGE when the target datatype is too small. | 1511 * It sets errno to ERANGE when the target datatype is too small. |
| 1615 * | 1512 * |
| 1616 * @param str the string to convert | 1513 * @param str the string to convert |
| 1617 * @param output a pointer to the integer variable where the result shall be stored | 1514 * @param output a pointer to the integer variable where the result shall be stored |
| 1618 * @param base 2, 8, 10, or 16 | 1515 * @param base 2, 8, 10, or 16 |
| 1619 * @param groupsep (@c const @c char*) each character in this string is treated as group separator and ignored during conversion | 1516 * @param groupsep (@c const @c char*) each character in this string is treated as a group separator and ignored during conversion |
| 1620 * @retval zero success | 1517 * @retval zero success |
| 1621 * @retval non-zero conversion was not possible | 1518 * @retval non-zero conversion was not possible |
| 1622 */ | 1519 */ |
| 1623 #define cx_strtoi8_lc(str, output, base, groupsep) cx_strtoi8_lc_(cx_strcast(str), output, base, groupsep) | 1520 #define cx_strtoi8_lc(str, output, base, groupsep) cx_strtoi8_lc_(cx_strcast(str), output, base, groupsep) |
| 1624 | 1521 |
| 1630 * It sets errno to ERANGE when the target datatype is too small. | 1527 * It sets errno to ERANGE when the target datatype is too small. |
| 1631 * | 1528 * |
| 1632 * @param str the string to convert | 1529 * @param str the string to convert |
| 1633 * @param output a pointer to the integer variable where the result shall be stored | 1530 * @param output a pointer to the integer variable where the result shall be stored |
| 1634 * @param base 2, 8, 10, or 16 | 1531 * @param base 2, 8, 10, or 16 |
| 1635 * @param groupsep (@c const @c char*) each character in this string is treated as group separator and ignored during conversion | 1532 * @param groupsep (@c const @c char*) each character in this string is treated as a group separator and ignored during conversion |
| 1636 * @retval zero success | 1533 * @retval zero success |
| 1637 * @retval non-zero conversion was not possible | 1534 * @retval non-zero conversion was not possible |
| 1638 */ | 1535 */ |
| 1639 #define cx_strtoi16_lc(str, output, base, groupsep) cx_strtoi16_lc_(cx_strcast(str), output, base, groupsep) | 1536 #define cx_strtoi16_lc(str, output, base, groupsep) cx_strtoi16_lc_(cx_strcast(str), output, base, groupsep) |
| 1640 | 1537 |
| 1646 * It sets errno to ERANGE when the target datatype is too small. | 1543 * It sets errno to ERANGE when the target datatype is too small. |
| 1647 * | 1544 * |
| 1648 * @param str the string to convert | 1545 * @param str the string to convert |
| 1649 * @param output a pointer to the integer variable where the result shall be stored | 1546 * @param output a pointer to the integer variable where the result shall be stored |
| 1650 * @param base 2, 8, 10, or 16 | 1547 * @param base 2, 8, 10, or 16 |
| 1651 * @param groupsep (@c const @c char*) each character in this string is treated as group separator and ignored during conversion | 1548 * @param groupsep (@c const @c char*) each character in this string is treated as a group separator and ignored during conversion |
| 1652 * @retval zero success | 1549 * @retval zero success |
| 1653 * @retval non-zero conversion was not possible | 1550 * @retval non-zero conversion was not possible |
| 1654 */ | 1551 */ |
| 1655 #define cx_strtoi32_lc(str, output, base, groupsep) cx_strtoi32_lc_(cx_strcast(str), output, base, groupsep) | 1552 #define cx_strtoi32_lc(str, output, base, groupsep) cx_strtoi32_lc_(cx_strcast(str), output, base, groupsep) |
| 1656 | 1553 |
| 1662 * It sets errno to ERANGE when the target datatype is too small. | 1559 * It sets errno to ERANGE when the target datatype is too small. |
| 1663 * | 1560 * |
| 1664 * @param str the string to convert | 1561 * @param str the string to convert |
| 1665 * @param output a pointer to the integer variable where the result shall be stored | 1562 * @param output a pointer to the integer variable where the result shall be stored |
| 1666 * @param base 2, 8, 10, or 16 | 1563 * @param base 2, 8, 10, or 16 |
| 1667 * @param groupsep (@c const @c char*) each character in this string is treated as group separator and ignored during conversion | 1564 * @param groupsep (@c const @c char*) each character in this string is treated as a group separator and ignored during conversion |
| 1668 * @retval zero success | 1565 * @retval zero success |
| 1669 * @retval non-zero conversion was not possible | 1566 * @retval non-zero conversion was not possible |
| 1670 */ | 1567 */ |
| 1671 #define cx_strtoi64_lc(str, output, base, groupsep) cx_strtoi64_lc_(cx_strcast(str), output, base, groupsep) | 1568 #define cx_strtoi64_lc(str, output, base, groupsep) cx_strtoi64_lc_(cx_strcast(str), output, base, groupsep) |
| 1672 | 1569 |
| 1678 * It sets errno to ERANGE when the target datatype is too small. | 1575 * It sets errno to ERANGE when the target datatype is too small. |
| 1679 * | 1576 * |
| 1680 * @param str the string to convert | 1577 * @param str the string to convert |
| 1681 * @param output a pointer to the integer variable where the result shall be stored | 1578 * @param output a pointer to the integer variable where the result shall be stored |
| 1682 * @param base 2, 8, 10, or 16 | 1579 * @param base 2, 8, 10, or 16 |
| 1683 * @param groupsep (@c const @c char*) each character in this string is treated as group separator and ignored during conversion | 1580 * @param groupsep (@c const @c char*) each character in this string is treated as a group separator and ignored during conversion |
| 1684 * @retval zero success | 1581 * @retval zero success |
| 1685 * @retval non-zero conversion was not possible | 1582 * @retval non-zero conversion was not possible |
| 1686 */ | 1583 */ |
| 1687 #define cx_strtous_lc(str, output, base, groupsep) cx_strtous_lc_(cx_strcast(str), output, base, groupsep) | 1584 #define cx_strtous_lc(str, output, base, groupsep) cx_strtous_lc_(cx_strcast(str), output, base, groupsep) |
| 1688 | 1585 |
| 1694 * It sets errno to ERANGE when the target datatype is too small. | 1591 * It sets errno to ERANGE when the target datatype is too small. |
| 1695 * | 1592 * |
| 1696 * @param str the string to convert | 1593 * @param str the string to convert |
| 1697 * @param output a pointer to the integer variable where the result shall be stored | 1594 * @param output a pointer to the integer variable where the result shall be stored |
| 1698 * @param base 2, 8, 10, or 16 | 1595 * @param base 2, 8, 10, or 16 |
| 1699 * @param groupsep (@c const @c char*) each character in this string is treated as group separator and ignored during conversion | 1596 * @param groupsep (@c const @c char*) each character in this string is treated as a group separator and ignored during conversion |
| 1700 * @retval zero success | 1597 * @retval zero success |
| 1701 * @retval non-zero conversion was not possible | 1598 * @retval non-zero conversion was not possible |
| 1702 */ | 1599 */ |
| 1703 #define cx_strtou_lc(str, output, base, groupsep) cx_strtou_lc_(cx_strcast(str), output, base, groupsep) | 1600 #define cx_strtou_lc(str, output, base, groupsep) cx_strtou_lc_(cx_strcast(str), output, base, groupsep) |
| 1704 | 1601 |
| 1710 * It sets errno to ERANGE when the target datatype is too small. | 1607 * It sets errno to ERANGE when the target datatype is too small. |
| 1711 * | 1608 * |
| 1712 * @param str the string to convert | 1609 * @param str the string to convert |
| 1713 * @param output a pointer to the integer variable where the result shall be stored | 1610 * @param output a pointer to the integer variable where the result shall be stored |
| 1714 * @param base 2, 8, 10, or 16 | 1611 * @param base 2, 8, 10, or 16 |
| 1715 * @param groupsep (@c const @c char*) each character in this string is treated as group separator and ignored during conversion | 1612 * @param groupsep (@c const @c char*) each character in this string is treated as a group separator and ignored during conversion |
| 1716 * @retval zero success | 1613 * @retval zero success |
| 1717 * @retval non-zero conversion was not possible | 1614 * @retval non-zero conversion was not possible |
| 1718 */ | 1615 */ |
| 1719 #define cx_strtoul_lc(str, output, base, groupsep) cx_strtoul_lc_(cx_strcast(str), output, base, groupsep) | 1616 #define cx_strtoul_lc(str, output, base, groupsep) cx_strtoul_lc_(cx_strcast(str), output, base, groupsep) |
| 1720 | 1617 |
| 1726 * It sets errno to ERANGE when the target datatype is too small. | 1623 * It sets errno to ERANGE when the target datatype is too small. |
| 1727 * | 1624 * |
| 1728 * @param str the string to convert | 1625 * @param str the string to convert |
| 1729 * @param output a pointer to the integer variable where the result shall be stored | 1626 * @param output a pointer to the integer variable where the result shall be stored |
| 1730 * @param base 2, 8, 10, or 16 | 1627 * @param base 2, 8, 10, or 16 |
| 1731 * @param groupsep (@c const @c char*) each character in this string is treated as group separator and ignored during conversion | 1628 * @param groupsep (@c const @c char*) each character in this string is treated as a group separator and ignored during conversion |
| 1732 * @retval zero success | 1629 * @retval zero success |
| 1733 * @retval non-zero conversion was not possible | 1630 * @retval non-zero conversion was not possible |
| 1734 */ | 1631 */ |
| 1735 #define cx_strtoull_lc(str, output, base, groupsep) cx_strtoull_lc_(cx_strcast(str), output, base, groupsep) | 1632 #define cx_strtoull_lc(str, output, base, groupsep) cx_strtoull_lc_(cx_strcast(str), output, base, groupsep) |
| 1736 | 1633 |
| 1742 * It sets errno to ERANGE when the target datatype is too small. | 1639 * It sets errno to ERANGE when the target datatype is too small. |
| 1743 * | 1640 * |
| 1744 * @param str the string to convert | 1641 * @param str the string to convert |
| 1745 * @param output a pointer to the integer variable where the result shall be stored | 1642 * @param output a pointer to the integer variable where the result shall be stored |
| 1746 * @param base 2, 8, 10, or 16 | 1643 * @param base 2, 8, 10, or 16 |
| 1747 * @param groupsep (@c const @c char*) each character in this string is treated as group separator and ignored during conversion | 1644 * @param groupsep (@c const @c char*) each character in this string is treated as a group separator and ignored during conversion |
| 1748 * @retval zero success | 1645 * @retval zero success |
| 1749 * @retval non-zero conversion was not possible | 1646 * @retval non-zero conversion was not possible |
| 1750 */ | 1647 */ |
| 1751 #define cx_strtou8_lc(str, output, base, groupsep) cx_strtou8_lc_(cx_strcast(str), output, base, groupsep) | 1648 #define cx_strtou8_lc(str, output, base, groupsep) cx_strtou8_lc_(cx_strcast(str), output, base, groupsep) |
| 1752 | 1649 |
| 1758 * It sets errno to ERANGE when the target datatype is too small. | 1655 * It sets errno to ERANGE when the target datatype is too small. |
| 1759 * | 1656 * |
| 1760 * @param str the string to convert | 1657 * @param str the string to convert |
| 1761 * @param output a pointer to the integer variable where the result shall be stored | 1658 * @param output a pointer to the integer variable where the result shall be stored |
| 1762 * @param base 2, 8, 10, or 16 | 1659 * @param base 2, 8, 10, or 16 |
| 1763 * @param groupsep (@c const @c char*) each character in this string is treated as group separator and ignored during conversion | 1660 * @param groupsep (@c const @c char*) each character in this string is treated as a group separator and ignored during conversion |
| 1764 * @retval zero success | 1661 * @retval zero success |
| 1765 * @retval non-zero conversion was not possible | 1662 * @retval non-zero conversion was not possible |
| 1766 */ | 1663 */ |
| 1767 #define cx_strtou16_lc(str, output, base, groupsep) cx_strtou16_lc_(cx_strcast(str), output, base, groupsep) | 1664 #define cx_strtou16_lc(str, output, base, groupsep) cx_strtou16_lc_(cx_strcast(str), output, base, groupsep) |
| 1768 | 1665 |
| 1774 * It sets errno to ERANGE when the target datatype is too small. | 1671 * It sets errno to ERANGE when the target datatype is too small. |
| 1775 * | 1672 * |
| 1776 * @param str the string to convert | 1673 * @param str the string to convert |
| 1777 * @param output a pointer to the integer variable where the result shall be stored | 1674 * @param output a pointer to the integer variable where the result shall be stored |
| 1778 * @param base 2, 8, 10, or 16 | 1675 * @param base 2, 8, 10, or 16 |
| 1779 * @param groupsep (@c const @c char*) each character in this string is treated as group separator and ignored during conversion | 1676 * @param groupsep (@c const @c char*) each character in this string is treated as a group separator and ignored during conversion |
| 1780 * @retval zero success | 1677 * @retval zero success |
| 1781 * @retval non-zero conversion was not possible | 1678 * @retval non-zero conversion was not possible |
| 1782 */ | 1679 */ |
| 1783 #define cx_strtou32_lc(str, output, base, groupsep) cx_strtou32_lc_(cx_strcast(str), output, base, groupsep) | 1680 #define cx_strtou32_lc(str, output, base, groupsep) cx_strtou32_lc_(cx_strcast(str), output, base, groupsep) |
| 1784 | 1681 |
| 1790 * It sets errno to ERANGE when the target datatype is too small. | 1687 * It sets errno to ERANGE when the target datatype is too small. |
| 1791 * | 1688 * |
| 1792 * @param str the string to convert | 1689 * @param str the string to convert |
| 1793 * @param output a pointer to the integer variable where the result shall be stored | 1690 * @param output a pointer to the integer variable where the result shall be stored |
| 1794 * @param base 2, 8, 10, or 16 | 1691 * @param base 2, 8, 10, or 16 |
| 1795 * @param groupsep (@c const @c char*) each character in this string is treated as group separator and ignored during conversion | 1692 * @param groupsep (@c const @c char*) each character in this string is treated as a group separator and ignored during conversion |
| 1796 * @retval zero success | 1693 * @retval zero success |
| 1797 * @retval non-zero conversion was not possible | 1694 * @retval non-zero conversion was not possible |
| 1798 */ | 1695 */ |
| 1799 #define cx_strtou64_lc(str, output, base, groupsep) cx_strtou64_lc_(cx_strcast(str), output, base, groupsep) | 1696 #define cx_strtou64_lc(str, output, base, groupsep) cx_strtou64_lc_(cx_strcast(str), output, base, groupsep) |
| 1800 | 1697 |
| 1806 * It sets errno to ERANGE when the target datatype is too small. | 1703 * It sets errno to ERANGE when the target datatype is too small. |
| 1807 * | 1704 * |
| 1808 * @param str the string to convert | 1705 * @param str the string to convert |
| 1809 * @param output a pointer to the integer variable where the result shall be stored | 1706 * @param output a pointer to the integer variable where the result shall be stored |
| 1810 * @param base 2, 8, 10, or 16 | 1707 * @param base 2, 8, 10, or 16 |
| 1811 * @param groupsep (@c const @c char*) each character in this string is treated as group separator and ignored during conversion | 1708 * @param groupsep (@c const @c char*) each character in this string is treated as a group separator and ignored during conversion |
| 1812 * @retval zero success | 1709 * @retval zero success |
| 1813 * @retval non-zero conversion was not possible | 1710 * @retval non-zero conversion was not possible |
| 1814 */ | 1711 */ |
| 1815 #define cx_strtoz_lc(str, output, base, groupsep) cx_strtoz_lc_(cx_strcast(str), output, base, groupsep) | 1712 #define cx_strtoz_lc(str, output, base, groupsep) cx_strtoz_lc_(cx_strcast(str), output, base, groupsep) |
| 1816 | 1713 |
| 1819 * | 1716 * |
| 1820 * The function returns non-zero when conversion is not possible. | 1717 * The function returns non-zero when conversion is not possible. |
| 1821 * In that case the function sets errno to EINVAL when the reason is an invalid character or an unsupported base. | 1718 * In that case the function sets errno to EINVAL when the reason is an invalid character or an unsupported base. |
| 1822 * It sets errno to ERANGE when the target datatype is too small. | 1719 * It sets errno to ERANGE when the target datatype is too small. |
| 1823 * | 1720 * |
| 1824 * The comma character is treated as group separator and ignored during parsing. | 1721 * The comma character is treated as a group separator and ignored during parsing. |
| 1825 * If you want to choose the set of group separators, use the @c _lc variant of this function (e.g. cx_strtoz_lc()). | 1722 * If you want to choose the set of group separators, use the @c _lc variant of this function (e.g. cx_strtoz_lc()). |
| 1826 * | 1723 * |
| 1827 * @param str the string to convert | 1724 * @param str the string to convert |
| 1828 * @param output a pointer to the integer variable where the result shall be stored | 1725 * @param output a pointer to the integer variable where the result shall be stored |
| 1829 * @param base 2, 8, 10, or 16 | 1726 * @param base 2, 8, 10, or 16 |
| 1837 * | 1734 * |
| 1838 * The function returns non-zero when conversion is not possible. | 1735 * The function returns non-zero when conversion is not possible. |
| 1839 * In that case the function sets errno to EINVAL when the reason is an invalid character or an unsupported base. | 1736 * In that case the function sets errno to EINVAL when the reason is an invalid character or an unsupported base. |
| 1840 * It sets errno to ERANGE when the target datatype is too small. | 1737 * It sets errno to ERANGE when the target datatype is too small. |
| 1841 * | 1738 * |
| 1842 * The comma character is treated as group separator and ignored during parsing. | 1739 * The comma character is treated as a group separator and ignored during parsing. |
| 1843 * If you want to choose the set of group separators, use the @c _lc variant of this function (e.g. cx_strtoz_lc()). | 1740 * If you want to choose the set of group separators, use the @c _lc variant of this function (e.g. cx_strtoz_lc()). |
| 1844 * | 1741 * |
| 1845 * @param str the string to convert | 1742 * @param str the string to convert |
| 1846 * @param output a pointer to the integer variable where the result shall be stored | 1743 * @param output a pointer to the integer variable where the result shall be stored |
| 1847 * @param base 2, 8, 10, or 16 | 1744 * @param base 2, 8, 10, or 16 |
| 1855 * | 1752 * |
| 1856 * The function returns non-zero when conversion is not possible. | 1753 * The function returns non-zero when conversion is not possible. |
| 1857 * In that case the function sets errno to EINVAL when the reason is an invalid character or an unsupported base. | 1754 * In that case the function sets errno to EINVAL when the reason is an invalid character or an unsupported base. |
| 1858 * It sets errno to ERANGE when the target datatype is too small. | 1755 * It sets errno to ERANGE when the target datatype is too small. |
| 1859 * | 1756 * |
| 1860 * The comma character is treated as group separator and ignored during parsing. | 1757 * The comma character is treated as a group separator and ignored during parsing. |
| 1861 * If you want to choose the set of group separators, use the @c _lc variant of this function (e.g. cx_strtoz_lc()). | 1758 * If you want to choose the set of group separators, use the @c _lc variant of this function (e.g. cx_strtoz_lc()). |
| 1862 * | 1759 * |
| 1863 * @param str the string to convert | 1760 * @param str the string to convert |
| 1864 * @param output a pointer to the integer variable where the result shall be stored | 1761 * @param output a pointer to the integer variable where the result shall be stored |
| 1865 * @param base 2, 8, 10, or 16 | 1762 * @param base 2, 8, 10, or 16 |
| 1873 * | 1770 * |
| 1874 * The function returns non-zero when conversion is not possible. | 1771 * The function returns non-zero when conversion is not possible. |
| 1875 * In that case the function sets errno to EINVAL when the reason is an invalid character or an unsupported base. | 1772 * In that case the function sets errno to EINVAL when the reason is an invalid character or an unsupported base. |
| 1876 * It sets errno to ERANGE when the target datatype is too small. | 1773 * It sets errno to ERANGE when the target datatype is too small. |
| 1877 * | 1774 * |
| 1878 * The comma character is treated as group separator and ignored during parsing. | 1775 * The comma character is treated as a group separator and ignored during parsing. |
| 1879 * If you want to choose the set of group separators, use the @c _lc variant of this function (e.g. cx_strtoz_lc()). | 1776 * If you want to choose the set of group separators, use the @c _lc variant of this function (e.g. cx_strtoz_lc()). |
| 1880 * | 1777 * |
| 1881 * @param str the string to convert | 1778 * @param str the string to convert |
| 1882 * @param output a pointer to the integer variable where the result shall be stored | 1779 * @param output a pointer to the integer variable where the result shall be stored |
| 1883 * @param base 2, 8, 10, or 16 | 1780 * @param base 2, 8, 10, or 16 |
| 1891 * | 1788 * |
| 1892 * The function returns non-zero when conversion is not possible. | 1789 * The function returns non-zero when conversion is not possible. |
| 1893 * In that case the function sets errno to EINVAL when the reason is an invalid character or an unsupported base. | 1790 * In that case the function sets errno to EINVAL when the reason is an invalid character or an unsupported base. |
| 1894 * It sets errno to ERANGE when the target datatype is too small. | 1791 * It sets errno to ERANGE when the target datatype is too small. |
| 1895 * | 1792 * |
| 1896 * The comma character is treated as group separator and ignored during parsing. | 1793 * The comma character is treated as a group separator and ignored during parsing. |
| 1897 * If you want to choose the set of group separators, use the @c _lc variant of this function (e.g. cx_strtoz_lc()). | 1794 * If you want to choose the set of group separators, use the @c _lc variant of this function (e.g. cx_strtoz_lc()). |
| 1898 * | 1795 * |
| 1899 * @param str the string to convert | 1796 * @param str the string to convert |
| 1900 * @param output a pointer to the integer variable where the result shall be stored | 1797 * @param output a pointer to the integer variable where the result shall be stored |
| 1901 * @param base 2, 8, 10, or 16 | 1798 * @param base 2, 8, 10, or 16 |
| 1909 * | 1806 * |
| 1910 * The function returns non-zero when conversion is not possible. | 1807 * The function returns non-zero when conversion is not possible. |
| 1911 * In that case the function sets errno to EINVAL when the reason is an invalid character or an unsupported base. | 1808 * In that case the function sets errno to EINVAL when the reason is an invalid character or an unsupported base. |
| 1912 * It sets errno to ERANGE when the target datatype is too small. | 1809 * It sets errno to ERANGE when the target datatype is too small. |
| 1913 * | 1810 * |
| 1914 * The comma character is treated as group separator and ignored during parsing. | 1811 * The comma character is treated as a group separator and ignored during parsing. |
| 1915 * If you want to choose the set of group separators, use the @c _lc variant of this function (e.g. cx_strtoz_lc()). | 1812 * If you want to choose the set of group separators, use the @c _lc variant of this function (e.g. cx_strtoz_lc()). |
| 1916 * | 1813 * |
| 1917 * @param str the string to convert | 1814 * @param str the string to convert |
| 1918 * @param output a pointer to the integer variable where the result shall be stored | 1815 * @param output a pointer to the integer variable where the result shall be stored |
| 1919 * @param base 2, 8, 10, or 16 | 1816 * @param base 2, 8, 10, or 16 |
| 1927 * | 1824 * |
| 1928 * The function returns non-zero when conversion is not possible. | 1825 * The function returns non-zero when conversion is not possible. |
| 1929 * In that case the function sets errno to EINVAL when the reason is an invalid character or an unsupported base. | 1826 * In that case the function sets errno to EINVAL when the reason is an invalid character or an unsupported base. |
| 1930 * It sets errno to ERANGE when the target datatype is too small. | 1827 * It sets errno to ERANGE when the target datatype is too small. |
| 1931 * | 1828 * |
| 1932 * The comma character is treated as group separator and ignored during parsing. | 1829 * The comma character is treated as a group separator and ignored during parsing. |
| 1933 * If you want to choose the set of group separators, use the @c _lc variant of this function (e.g. cx_strtoz_lc()). | 1830 * If you want to choose the set of group separators, use the @c _lc variant of this function (e.g. cx_strtoz_lc()). |
| 1934 * | 1831 * |
| 1935 * @param str the string to convert | 1832 * @param str the string to convert |
| 1936 * @param output a pointer to the integer variable where the result shall be stored | 1833 * @param output a pointer to the integer variable where the result shall be stored |
| 1937 * @param base 2, 8, 10, or 16 | 1834 * @param base 2, 8, 10, or 16 |
| 1945 * | 1842 * |
| 1946 * The function returns non-zero when conversion is not possible. | 1843 * The function returns non-zero when conversion is not possible. |
| 1947 * In that case the function sets errno to EINVAL when the reason is an invalid character or an unsupported base. | 1844 * In that case the function sets errno to EINVAL when the reason is an invalid character or an unsupported base. |
| 1948 * It sets errno to ERANGE when the target datatype is too small. | 1845 * It sets errno to ERANGE when the target datatype is too small. |
| 1949 * | 1846 * |
| 1950 * The comma character is treated as group separator and ignored during parsing. | 1847 * The comma character is treated as a group separator and ignored during parsing. |
| 1951 * If you want to choose the set of group separators, use the @c _lc variant of this function (e.g. cx_strtoz_lc()). | 1848 * If you want to choose the set of group separators, use the @c _lc variant of this function (e.g. cx_strtoz_lc()). |
| 1952 * | 1849 * |
| 1953 * @param str the string to convert | 1850 * @param str the string to convert |
| 1954 * @param output a pointer to the integer variable where the result shall be stored | 1851 * @param output a pointer to the integer variable where the result shall be stored |
| 1955 * @param base 2, 8, 10, or 16 | 1852 * @param base 2, 8, 10, or 16 |
| 1963 * | 1860 * |
| 1964 * The function returns non-zero when conversion is not possible. | 1861 * The function returns non-zero when conversion is not possible. |
| 1965 * In that case the function sets errno to EINVAL when the reason is an invalid character or an unsupported base. | 1862 * In that case the function sets errno to EINVAL when the reason is an invalid character or an unsupported base. |
| 1966 * It sets errno to ERANGE when the target datatype is too small. | 1863 * It sets errno to ERANGE when the target datatype is too small. |
| 1967 * | 1864 * |
| 1968 * The comma character is treated as group separator and ignored during parsing. | 1865 * The comma character is treated as a group separator and ignored during parsing. |
| 1969 * If you want to choose the set of group separators, use the @c _lc variant of this function (e.g. cx_strtoz_lc()). | 1866 * If you want to choose the set of group separators, use the @c _lc variant of this function (e.g. cx_strtoz_lc()). |
| 1970 * | 1867 * |
| 1971 * @param str the string to convert | 1868 * @param str the string to convert |
| 1972 * @param output a pointer to the integer variable where the result shall be stored | 1869 * @param output a pointer to the integer variable where the result shall be stored |
| 1973 * @param base 2, 8, 10, or 16 | 1870 * @param base 2, 8, 10, or 16 |
| 1981 * | 1878 * |
| 1982 * The function returns non-zero when conversion is not possible. | 1879 * The function returns non-zero when conversion is not possible. |
| 1983 * In that case the function sets errno to EINVAL when the reason is an invalid character or an unsupported base. | 1880 * In that case the function sets errno to EINVAL when the reason is an invalid character or an unsupported base. |
| 1984 * It sets errno to ERANGE when the target datatype is too small. | 1881 * It sets errno to ERANGE when the target datatype is too small. |
| 1985 * | 1882 * |
| 1986 * The comma character is treated as group separator and ignored during parsing. | 1883 * The comma character is treated as a group separator and ignored during parsing. |
| 1987 * If you want to choose the set of group separators, use the @c _lc variant of this function (e.g. cx_strtoz_lc()). | 1884 * If you want to choose the set of group separators, use the @c _lc variant of this function (e.g. cx_strtoz_lc()). |
| 1988 * | 1885 * |
| 1989 * @param str the string to convert | 1886 * @param str the string to convert |
| 1990 * @param output a pointer to the integer variable where the result shall be stored | 1887 * @param output a pointer to the integer variable where the result shall be stored |
| 1991 * @param base 2, 8, 10, or 16 | 1888 * @param base 2, 8, 10, or 16 |
| 1999 * | 1896 * |
| 2000 * The function returns non-zero when conversion is not possible. | 1897 * The function returns non-zero when conversion is not possible. |
| 2001 * In that case the function sets errno to EINVAL when the reason is an invalid character or an unsupported base. | 1898 * In that case the function sets errno to EINVAL when the reason is an invalid character or an unsupported base. |
| 2002 * It sets errno to ERANGE when the target datatype is too small. | 1899 * It sets errno to ERANGE when the target datatype is too small. |
| 2003 * | 1900 * |
| 2004 * The comma character is treated as group separator and ignored during parsing. | 1901 * The comma character is treated as a group separator and ignored during parsing. |
| 2005 * If you want to choose the set of group separators, use the @c _lc variant of this function (e.g. cx_strtoz_lc()). | 1902 * If you want to choose the set of group separators, use the @c _lc variant of this function (e.g. cx_strtoz_lc()). |
| 2006 * | 1903 * |
| 2007 * @param str the string to convert | 1904 * @param str the string to convert |
| 2008 * @param output a pointer to the integer variable where the result shall be stored | 1905 * @param output a pointer to the integer variable where the result shall be stored |
| 2009 * @param base 2, 8, 10, or 16 | 1906 * @param base 2, 8, 10, or 16 |
| 2017 * | 1914 * |
| 2018 * The function returns non-zero when conversion is not possible. | 1915 * The function returns non-zero when conversion is not possible. |
| 2019 * In that case the function sets errno to EINVAL when the reason is an invalid character or an unsupported base. | 1916 * In that case the function sets errno to EINVAL when the reason is an invalid character or an unsupported base. |
| 2020 * It sets errno to ERANGE when the target datatype is too small. | 1917 * It sets errno to ERANGE when the target datatype is too small. |
| 2021 * | 1918 * |
| 2022 * The comma character is treated as group separator and ignored during parsing. | 1919 * The comma character is treated as a group separator and ignored during parsing. |
| 2023 * If you want to choose the set of group separators, use the @c _lc variant of this function (e.g. cx_strtoz_lc()). | 1920 * If you want to choose the set of group separators, use the @c _lc variant of this function (e.g. cx_strtoz_lc()). |
| 2024 * | 1921 * |
| 2025 * @param str the string to convert | 1922 * @param str the string to convert |
| 2026 * @param output a pointer to the integer variable where the result shall be stored | 1923 * @param output a pointer to the integer variable where the result shall be stored |
| 2027 * @param base 2, 8, 10, or 16 | 1924 * @param base 2, 8, 10, or 16 |
| 2035 * | 1932 * |
| 2036 * The function returns non-zero when conversion is not possible. | 1933 * The function returns non-zero when conversion is not possible. |
| 2037 * In that case the function sets errno to EINVAL when the reason is an invalid character or an unsupported base. | 1934 * In that case the function sets errno to EINVAL when the reason is an invalid character or an unsupported base. |
| 2038 * It sets errno to ERANGE when the target datatype is too small. | 1935 * It sets errno to ERANGE when the target datatype is too small. |
| 2039 * | 1936 * |
| 2040 * The comma character is treated as group separator and ignored during parsing. | 1937 * The comma character is treated as a group separator and ignored during parsing. |
| 2041 * If you want to choose the set of group separators, use the @c _lc variant of this function (e.g. cx_strtoz_lc()). | 1938 * If you want to choose the set of group separators, use the @c _lc variant of this function (e.g. cx_strtoz_lc()). |
| 2042 * | 1939 * |
| 2043 * @param str the string to convert | 1940 * @param str the string to convert |
| 2044 * @param output a pointer to the integer variable where the result shall be stored | 1941 * @param output a pointer to the integer variable where the result shall be stored |
| 2045 * @param base 2, 8, 10, or 16 | 1942 * @param base 2, 8, 10, or 16 |
| 2053 * | 1950 * |
| 2054 * The function returns non-zero when conversion is not possible. | 1951 * The function returns non-zero when conversion is not possible. |
| 2055 * In that case the function sets errno to EINVAL when the reason is an invalid character or an unsupported base. | 1952 * In that case the function sets errno to EINVAL when the reason is an invalid character or an unsupported base. |
| 2056 * It sets errno to ERANGE when the target datatype is too small. | 1953 * It sets errno to ERANGE when the target datatype is too small. |
| 2057 * | 1954 * |
| 2058 * The comma character is treated as group separator and ignored during parsing. | 1955 * The comma character is treated as a group separator and ignored during parsing. |
| 2059 * If you want to choose the set of group separators, use the @c _lc variant of this function (e.g. cx_strtoz_lc()). | 1956 * If you want to choose the set of group separators, use the @c _lc variant of this function (e.g. cx_strtoz_lc()). |
| 2060 * | 1957 * |
| 2061 * @param str the string to convert | 1958 * @param str the string to convert |
| 2062 * @param output a pointer to the integer variable where the result shall be stored | 1959 * @param output a pointer to the integer variable where the result shall be stored |
| 2063 * @param base 2, 8, 10, or 16 | 1960 * @param base 2, 8, 10, or 16 |
| 2071 * | 1968 * |
| 2072 * The function returns non-zero when conversion is not possible. | 1969 * The function returns non-zero when conversion is not possible. |
| 2073 * In that case the function sets errno to EINVAL when the reason is an invalid character or an unsupported base. | 1970 * In that case the function sets errno to EINVAL when the reason is an invalid character or an unsupported base. |
| 2074 * It sets errno to ERANGE when the target datatype is too small. | 1971 * It sets errno to ERANGE when the target datatype is too small. |
| 2075 * | 1972 * |
| 2076 * The comma character is treated as group separator and ignored during parsing. | 1973 * The comma character is treated as a group separator and ignored during parsing. |
| 2077 * If you want to choose the set of group separators, use the @c _lc variant of this function (e.g. cx_strtoz_lc()). | 1974 * If you want to choose the set of group separators, use the @c _lc variant of this function (e.g. cx_strtoz_lc()). |
| 2078 * | 1975 * |
| 2079 * @param str the string to convert | 1976 * @param str the string to convert |
| 2080 * @param output a pointer to the integer variable where the result shall be stored | 1977 * @param output a pointer to the integer variable where the result shall be stored |
| 2081 * @param base 2, 8, 10, or 16 | 1978 * @param base 2, 8, 10, or 16 |
| 2089 * | 1986 * |
| 2090 * The function returns non-zero when conversion is not possible. | 1987 * The function returns non-zero when conversion is not possible. |
| 2091 * In that case the function sets errno to EINVAL when the reason is an invalid character or an unsupported base. | 1988 * In that case the function sets errno to EINVAL when the reason is an invalid character or an unsupported base. |
| 2092 * It sets errno to ERANGE when the target datatype is too small. | 1989 * It sets errno to ERANGE when the target datatype is too small. |
| 2093 * | 1990 * |
| 2094 * The comma character is treated as group separator and ignored during parsing. | 1991 * The comma character is treated as a group separator and ignored during parsing. |
| 2095 * If you want to choose the set of group separators, use the @c _lc variant of this function (e.g. cx_strtoz_lc()). | 1992 * If you want to choose the set of group separators, use the @c _lc variant of this function (e.g. cx_strtoz_lc()). |
| 2096 * | 1993 * |
| 2097 * @param str the string to convert | 1994 * @param str the string to convert |
| 2098 * @param output a pointer to the integer variable where the result shall be stored | 1995 * @param output a pointer to the integer variable where the result shall be stored |
| 2099 * @param base 2, 8, 10, or 16 | 1996 * @param base 2, 8, 10, or 16 |
| 2107 * | 2004 * |
| 2108 * The function returns non-zero when conversion is not possible. | 2005 * The function returns non-zero when conversion is not possible. |
| 2109 * In that case the function sets errno to EINVAL when the reason is an invalid character or an unsupported base. | 2006 * In that case the function sets errno to EINVAL when the reason is an invalid character or an unsupported base. |
| 2110 * It sets errno to ERANGE when the target datatype is too small. | 2007 * It sets errno to ERANGE when the target datatype is too small. |
| 2111 * | 2008 * |
| 2112 * The comma character is treated as group separator and ignored during parsing. | 2009 * The comma character is treated as a group separator and ignored during parsing. |
| 2113 * If you want to choose the set of group separators, use the @c _lc variant of this function (e.g. cx_strtoz_lc()). | 2010 * If you want to choose the set of group separators, use the @c _lc variant of this function (e.g. cx_strtoz_lc()). |
| 2114 * | 2011 * |
| 2115 * @param str the string to convert | 2012 * @param str the string to convert |
| 2116 * @param output a pointer to the integer variable where the result shall be stored | 2013 * @param output a pointer to the integer variable where the result shall be stored |
| 2117 * @param base 2, 8, 10, or 16 | 2014 * @param base 2, 8, 10, or 16 |
| 2119 * @retval non-zero conversion was not possible | 2016 * @retval non-zero conversion was not possible |
| 2120 */ | 2017 */ |
| 2121 #define cx_strtou64(str, output, base) cx_strtou64_lc_(cx_strcast(str), output, base, ",") | 2018 #define cx_strtou64(str, output, base) cx_strtou64_lc_(cx_strcast(str), output, base, ",") |
| 2122 | 2019 |
| 2123 /** | 2020 /** |
| 2124 * Converts a string to a single precision floating point number. | 2021 * Converts a string to a single precision floating-point number. |
| 2125 * | 2022 * |
| 2126 * The function returns non-zero when conversion is not possible. | 2023 * The function returns non-zero when conversion is not possible. |
| 2127 * In that case the function sets errno to EINVAL when the reason is an invalid character. | 2024 * In that case the function sets errno to EINVAL when the reason is an invalid character. |
| 2128 * It sets errno to ERANGE when the necessary representation would exceed the limits defined in libc's float.h. | 2025 * It sets errno to ERANGE when the necessary representation would exceed the limits defined in libc's float.h. |
| 2129 * | 2026 * |
| 2130 * @param str the string to convert | 2027 * @param str the string to convert |
| 2131 * @param output a pointer to the float variable where the result shall be stored | 2028 * @param output a pointer to the float variable where the result shall be stored |
| 2132 * @param decsep the decimal separator | 2029 * @param decsep the decimal separator |
| 2133 * @param groupsep each character in this string is treated as group separator and ignored during conversion | 2030 * @param groupsep each character in this string is treated as a group separator and ignored during conversion |
| 2134 * @retval zero success | 2031 * @retval zero success |
| 2135 * @retval non-zero conversion was not possible | 2032 * @retval non-zero conversion was not possible |
| 2136 */ | 2033 */ |
| 2137 #define cx_strtof_lc(str, output, decsep, groupsep) cx_strtof_lc_(cx_strcast(str), output, decsep, groupsep) | 2034 #define cx_strtof_lc(str, output, decsep, groupsep) cx_strtof_lc_(cx_strcast(str), output, decsep, groupsep) |
| 2138 | 2035 |
| 2139 /** | 2036 /** |
| 2140 * Converts a string to a double precision floating point number. | 2037 * Converts a string to a double precision floating-point number. |
| 2141 * | 2038 * |
| 2142 * The function returns non-zero when conversion is not possible. | 2039 * The function returns non-zero when conversion is not possible. |
| 2143 * In that case the function sets errno to EINVAL when the reason is an invalid character. | 2040 * In that case the function sets errno to EINVAL when the reason is an invalid character. |
| 2144 * | 2041 * |
| 2145 * @param str the string to convert | 2042 * @param str the string to convert |
| 2146 * @param output a pointer to the double variable where the result shall be stored | 2043 * @param output a pointer to the double variable where the result shall be stored |
| 2147 * @param decsep the decimal separator | 2044 * @param decsep the decimal separator |
| 2148 * @param groupsep each character in this string is treated as group separator and ignored during conversion | 2045 * @param groupsep each character in this string is treated as a group separator and ignored during conversion |
| 2149 * @retval zero success | 2046 * @retval zero success |
| 2150 * @retval non-zero conversion was not possible | 2047 * @retval non-zero conversion was not possible |
| 2151 */ | 2048 */ |
| 2152 #define cx_strtod_lc(str, output, decsep, groupsep) cx_strtod_lc_(cx_strcast(str), output, decsep, groupsep) | 2049 #define cx_strtod_lc(str, output, decsep, groupsep) cx_strtod_lc_(cx_strcast(str), output, decsep, groupsep) |
| 2153 | 2050 |
| 2154 /** | 2051 /** |
| 2155 * Converts a string to a single precision floating point number. | 2052 * Converts a string to a single precision floating-point number. |
| 2156 * | 2053 * |
| 2157 * The function returns non-zero when conversion is not possible. | 2054 * The function returns non-zero when conversion is not possible. |
| 2158 * In that case the function sets errno to EINVAL when the reason is an invalid character. | 2055 * In that case the function sets errno to EINVAL when the reason is an invalid character. |
| 2159 * It sets errno to ERANGE when the necessary representation would exceed the limits defined in libc's float.h. | 2056 * It sets errno to ERANGE when the necessary representation would exceed the limits defined in libc's float.h. |
| 2160 * | 2057 * |
| 2161 * The decimal separator is assumed to be a dot character. | 2058 * The decimal separator is assumed to be a dot character. |
| 2162 * The comma character is treated as group separator and ignored during parsing. | 2059 * The comma character is treated as a group separator and ignored during parsing. |
| 2163 * If you want to choose a different format, use cx_strtof_lc(). | 2060 * If you want to choose a different format, use cx_strtof_lc(). |
| 2164 * | 2061 * |
| 2165 * @param str the string to convert | 2062 * @param str the string to convert |
| 2166 * @param output a pointer to the float variable where the result shall be stored | 2063 * @param output a pointer to the float variable where the result shall be stored |
| 2167 * @retval zero success | 2064 * @retval zero success |
| 2168 * @retval non-zero conversion was not possible | 2065 * @retval non-zero conversion was not possible |
| 2169 */ | 2066 */ |
| 2170 #define cx_strtof(str, output) cx_strtof_lc_(cx_strcast(str), output, '.', ",") | 2067 #define cx_strtof(str, output) cx_strtof_lc_(cx_strcast(str), output, '.', ",") |
| 2171 | 2068 |
| 2172 /** | 2069 /** |
| 2173 * Converts a string to a double precision floating point number. | 2070 * Converts a string to a double precision floating-point number. |
| 2174 * | 2071 * |
| 2175 * The function returns non-zero when conversion is not possible. | 2072 * The function returns non-zero when conversion is not possible. |
| 2176 * In that case the function sets errno to EINVAL when the reason is an invalid character. | 2073 * In that case the function sets errno to EINVAL when the reason is an invalid character. |
| 2177 * | 2074 * |
| 2178 * The decimal separator is assumed to be a dot character. | 2075 * The decimal separator is assumed to be a dot character. |
| 2179 * The comma character is treated as group separator and ignored during parsing. | 2076 * The comma character is treated as a group separator and ignored during parsing. |
| 2180 * If you want to choose a different format, use cx_strtof_lc(). | 2077 * If you want to choose a different format, use cx_strtof_lc(). |
| 2181 * | 2078 * |
| 2182 * @param str the string to convert | 2079 * @param str the string to convert |
| 2183 * @param output a pointer to the double variable where the result shall be stored | 2080 * @param output a pointer to the double variable where the result shall be stored |
| 2184 * @retval zero success | 2081 * @retval zero success |