src/cx/string.h

changeset 985
68754c7de906
parent 926
8fdd8d78c14b
equal deleted inserted replaced
984:e8f354a25ac8 985:68754c7de906
170 * @param cstring the string to wrap, must be zero-terminated 170 * @param cstring the string to wrap, must be zero-terminated
171 * @return the wrapped string 171 * @return the wrapped string
172 * 172 *
173 * @see cx_mutstrn() 173 * @see cx_mutstrn()
174 */ 174 */
175 __attribute__((__warn_unused_result__, __nonnull__)) 175 cx_attr_nonnull
176 cx_attr_nodiscard
177 cx_attr_cstr_arg(1)
176 cxmutstr cx_mutstr(char *cstring); 178 cxmutstr cx_mutstr(char *cstring);
177 179
178 /** 180 /**
179 * Wraps a string that does not need to be zero-terminated. 181 * Wraps a string that does not need to be zero-terminated.
180 * 182 *
189 * @param length the length of the string 191 * @param length the length of the string
190 * @return the wrapped string 192 * @return the wrapped string
191 * 193 *
192 * @see cx_mutstr() 194 * @see cx_mutstr()
193 */ 195 */
194 __attribute__((__warn_unused_result__)) 196 cx_attr_nodiscard
197 cx_attr_access_rw(1, 2)
195 cxmutstr cx_mutstrn( 198 cxmutstr cx_mutstrn(
196 char *cstring, 199 char *cstring,
197 size_t length 200 size_t length
198 ); 201 );
199 202
210 * @param cstring the string to wrap, must be zero-terminated 213 * @param cstring the string to wrap, must be zero-terminated
211 * @return the wrapped string 214 * @return the wrapped string
212 * 215 *
213 * @see cx_strn() 216 * @see cx_strn()
214 */ 217 */
215 __attribute__((__warn_unused_result__, __nonnull__)) 218 cx_attr_nonnull
219 cx_attr_nodiscard
220 cx_attr_cstr_arg(1)
216 cxstring cx_str(const char *cstring); 221 cxstring cx_str(const char *cstring);
217 222
218 223
219 /** 224 /**
220 * Wraps a string that does not need to be zero-terminated. 225 * Wraps a string that does not need to be zero-terminated.
230 * @param length the length of the string 235 * @param length the length of the string
231 * @return the wrapped string 236 * @return the wrapped string
232 * 237 *
233 * @see cx_str() 238 * @see cx_str()
234 */ 239 */
235 __attribute__((__warn_unused_result__)) 240 cx_attr_nodiscard
241 cx_attr_access_r(1, 2)
236 cxstring cx_strn( 242 cxstring cx_strn(
237 const char *cstring, 243 const char *cstring,
238 size_t length 244 size_t length
239 ); 245 );
240 246
246 * point to the same location, though! 252 * point to the same location, though!
247 * 253 *
248 * @param str the mutable string to cast 254 * @param str the mutable string to cast
249 * @return an immutable copy of the string pointer 255 * @return an immutable copy of the string pointer
250 */ 256 */
251 __attribute__((__warn_unused_result__)) 257 cx_attr_nodiscard
252 cxstring cx_strcast(cxmutstr str); 258 cxstring cx_strcast(cxmutstr str);
253 259
254 /** 260 /**
255 * Passes the pointer in this string to \c free(). 261 * Passes the pointer in this string to \c free().
256 * 262 *
260 * you ever have a <code>const char*</code> you are really supposed to free. 266 * you ever have a <code>const char*</code> you are really supposed to free.
261 * If you encounter such situation, you should double-check your code. 267 * If you encounter such situation, you should double-check your code.
262 * 268 *
263 * @param str the string to free 269 * @param str the string to free
264 */ 270 */
265 __attribute__((__nonnull__))
266 void cx_strfree(cxmutstr *str); 271 void cx_strfree(cxmutstr *str);
267 272
268 /** 273 /**
269 * Passes the pointer in this string to the allocators free function. 274 * Passes the pointer in this string to the allocators free function.
270 * 275 *
275 * If you encounter such situation, you should double-check your code. 280 * If you encounter such situation, you should double-check your code.
276 * 281 *
277 * @param alloc the allocator 282 * @param alloc the allocator
278 * @param str the string to free 283 * @param str the string to free
279 */ 284 */
280 __attribute__((__nonnull__)) 285 cx_attr_nonnull_arg(1)
281 void cx_strfree_a( 286 void cx_strfree_a(
282 const CxAllocator *alloc, 287 const CxAllocator *alloc,
283 cxmutstr *str 288 cxmutstr *str
284 ); 289 );
285 290
291 * 296 *
292 * @param count the total number of specified strings 297 * @param count the total number of specified strings
293 * @param ... all strings 298 * @param ... all strings
294 * @return the accumulated length of all strings 299 * @return the accumulated length of all strings
295 */ 300 */
296 __attribute__((__warn_unused_result__)) 301 cx_attr_nodiscard
297 size_t cx_strlen( 302 size_t cx_strlen(
298 size_t count, 303 size_t count,
299 ... 304 ...
300 ); 305 );
301 306
315 * @param str the string the other strings shall be concatenated to 320 * @param str the string the other strings shall be concatenated to
316 * @param count the number of the other following strings to concatenate 321 * @param count the number of the other following strings to concatenate
317 * @param ... all other strings 322 * @param ... all other strings
318 * @return the concatenated string 323 * @return the concatenated string
319 */ 324 */
320 __attribute__((__warn_unused_result__, __nonnull__)) 325 cx_attr_nodiscard
326 cx_attr_nonnull
321 cxmutstr cx_strcat_ma( 327 cxmutstr cx_strcat_ma(
322 const CxAllocator *alloc, 328 const CxAllocator *alloc,
323 cxmutstr str, 329 cxmutstr str,
324 size_t count, 330 size_t count,
325 ... 331 ...
391 * 397 *
392 * @see cx_strsubsl() 398 * @see cx_strsubsl()
393 * @see cx_strsubs_m() 399 * @see cx_strsubs_m()
394 * @see cx_strsubsl_m() 400 * @see cx_strsubsl_m()
395 */ 401 */
396 __attribute__((__warn_unused_result__)) 402 cx_attr_nodiscard
397 cxstring cx_strsubs( 403 cxstring cx_strsubs(
398 cxstring string, 404 cxstring string,
399 size_t start 405 size_t start
400 ); 406 );
401 407
416 * 422 *
417 * @see cx_strsubs() 423 * @see cx_strsubs()
418 * @see cx_strsubs_m() 424 * @see cx_strsubs_m()
419 * @see cx_strsubsl_m() 425 * @see cx_strsubsl_m()
420 */ 426 */
421 __attribute__((__warn_unused_result__)) 427 cx_attr_nodiscard
422 cxstring cx_strsubsl( 428 cxstring cx_strsubsl(
423 cxstring string, 429 cxstring string,
424 size_t start, 430 size_t start,
425 size_t length 431 size_t length
426 ); 432 );
438 * 444 *
439 * @see cx_strsubsl_m() 445 * @see cx_strsubsl_m()
440 * @see cx_strsubs() 446 * @see cx_strsubs()
441 * @see cx_strsubsl() 447 * @see cx_strsubsl()
442 */ 448 */
443 __attribute__((__warn_unused_result__)) 449 cx_attr_nodiscard
444 cxmutstr cx_strsubs_m( 450 cxmutstr cx_strsubs_m(
445 cxmutstr string, 451 cxmutstr string,
446 size_t start 452 size_t start
447 ); 453 );
448 454
463 * 469 *
464 * @see cx_strsubs_m() 470 * @see cx_strsubs_m()
465 * @see cx_strsubs() 471 * @see cx_strsubs()
466 * @see cx_strsubsl() 472 * @see cx_strsubsl()
467 */ 473 */
468 __attribute__((__warn_unused_result__)) 474 cx_attr_nodiscard
469 cxmutstr cx_strsubsl_m( 475 cxmutstr cx_strsubsl_m(
470 cxmutstr string, 476 cxmutstr string,
471 size_t start, 477 size_t start,
472 size_t length 478 size_t length
473 ); 479 );
482 * @param chr the character to locate 488 * @param chr the character to locate
483 * @return a substring starting at the first location of \p chr 489 * @return a substring starting at the first location of \p chr
484 * 490 *
485 * @see cx_strchr_m() 491 * @see cx_strchr_m()
486 */ 492 */
487 __attribute__((__warn_unused_result__)) 493 cx_attr_nodiscard
488 cxstring cx_strchr( 494 cxstring cx_strchr(
489 cxstring string, 495 cxstring string,
490 int chr 496 int chr
491 ); 497 );
492 498
500 * @param chr the character to locate 506 * @param chr the character to locate
501 * @return a substring starting at the first location of \p chr 507 * @return a substring starting at the first location of \p chr
502 * 508 *
503 * @see cx_strchr() 509 * @see cx_strchr()
504 */ 510 */
505 __attribute__((__warn_unused_result__)) 511 cx_attr_nodiscard
506 cxmutstr cx_strchr_m( 512 cxmutstr cx_strchr_m(
507 cxmutstr string, 513 cxmutstr string,
508 int chr 514 int chr
509 ); 515 );
510 516
518 * @param chr the character to locate 524 * @param chr the character to locate
519 * @return a substring starting at the last location of \p chr 525 * @return a substring starting at the last location of \p chr
520 * 526 *
521 * @see cx_strrchr_m() 527 * @see cx_strrchr_m()
522 */ 528 */
523 __attribute__((__warn_unused_result__)) 529 cx_attr_nodiscard
524 cxstring cx_strrchr( 530 cxstring cx_strrchr(
525 cxstring string, 531 cxstring string,
526 int chr 532 int chr
527 ); 533 );
528 534
536 * @param chr the character to locate 542 * @param chr the character to locate
537 * @return a substring starting at the last location of \p chr 543 * @return a substring starting at the last location of \p chr
538 * 544 *
539 * @see cx_strrchr() 545 * @see cx_strrchr()
540 */ 546 */
541 __attribute__((__warn_unused_result__)) 547 cx_attr_nodiscard
542 cxmutstr cx_strrchr_m( 548 cxmutstr cx_strrchr_m(
543 cxmutstr string, 549 cxmutstr string,
544 int chr 550 int chr
545 ); 551 );
546 552
558 * @return a substring starting at the first occurrence of 564 * @return a substring starting at the first occurrence of
559 * \p needle, or an empty string, if the sequence is not 565 * \p needle, or an empty string, if the sequence is not
560 * contained 566 * contained
561 * @see cx_strstr_m() 567 * @see cx_strstr_m()
562 */ 568 */
563 __attribute__((__warn_unused_result__)) 569 cx_attr_nodiscard
564 cxstring cx_strstr( 570 cxstring cx_strstr(
565 cxstring haystack, 571 cxstring haystack,
566 cxstring needle 572 cxstring needle
567 ); 573 );
568 574
580 * @return a substring starting at the first occurrence of 586 * @return a substring starting at the first occurrence of
581 * \p needle, or an empty string, if the sequence is not 587 * \p needle, or an empty string, if the sequence is not
582 * contained 588 * contained
583 * @see cx_strstr() 589 * @see cx_strstr()
584 */ 590 */
585 __attribute__((__warn_unused_result__)) 591 cx_attr_nodiscard
586 cxmutstr cx_strstr_m( 592 cxmutstr cx_strstr_m(
587 cxmutstr haystack, 593 cxmutstr haystack,
588 cxstring needle 594 cxstring needle
589 ); 595 );
590 596
598 * @param delim the delimiter 604 * @param delim the delimiter
599 * @param limit the maximum number of split items 605 * @param limit the maximum number of split items
600 * @param output a pre-allocated array of at least \p limit length 606 * @param output a pre-allocated array of at least \p limit length
601 * @return the actual number of split items 607 * @return the actual number of split items
602 */ 608 */
603 __attribute__((__warn_unused_result__, __nonnull__)) 609 cx_attr_nodiscard
610 cx_attr_nonnull
611 cx_attr_access_w(4, 3)
604 size_t cx_strsplit( 612 size_t cx_strsplit(
605 cxstring string, 613 cxstring string,
606 cxstring delim, 614 cxstring delim,
607 size_t limit, 615 size_t limit,
608 cxstring *output 616 cxstring *output
625 * @param limit the maximum number of split items 633 * @param limit the maximum number of split items
626 * @param output a pointer where the address of the allocated array shall be 634 * @param output a pointer where the address of the allocated array shall be
627 * written to 635 * written to
628 * @return the actual number of split items 636 * @return the actual number of split items
629 */ 637 */
630 __attribute__((__warn_unused_result__, __nonnull__)) 638 cx_attr_nodiscard
639 cx_attr_nonnull
640 cx_attr_access_w(5)
631 size_t cx_strsplit_a( 641 size_t cx_strsplit_a(
632 const CxAllocator *allocator, 642 const CxAllocator *allocator,
633 cxstring string, 643 cxstring string,
634 cxstring delim, 644 cxstring delim,
635 size_t limit, 645 size_t limit,
647 * @param delim the delimiter 657 * @param delim the delimiter
648 * @param limit the maximum number of split items 658 * @param limit the maximum number of split items
649 * @param output a pre-allocated array of at least \p limit length 659 * @param output a pre-allocated array of at least \p limit length
650 * @return the actual number of split items 660 * @return the actual number of split items
651 */ 661 */
652 __attribute__((__warn_unused_result__, __nonnull__)) 662 cx_attr_nodiscard
663 cx_attr_nonnull
664 cx_attr_access_w(4, 3)
653 size_t cx_strsplit_m( 665 size_t cx_strsplit_m(
654 cxmutstr string, 666 cxmutstr string,
655 cxstring delim, 667 cxstring delim,
656 size_t limit, 668 size_t limit,
657 cxmutstr *output 669 cxmutstr *output
674 * @param limit the maximum number of split items 686 * @param limit the maximum number of split items
675 * @param output a pointer where the address of the allocated array shall be 687 * @param output a pointer where the address of the allocated array shall be
676 * written to 688 * written to
677 * @return the actual number of split items 689 * @return the actual number of split items
678 */ 690 */
679 __attribute__((__warn_unused_result__, __nonnull__)) 691 cx_attr_nodiscard
692 cx_attr_nonnull
693 cx_attr_access_w(5)
680 size_t cx_strsplit_ma( 694 size_t cx_strsplit_ma(
681 const CxAllocator *allocator, 695 const CxAllocator *allocator,
682 cxmutstr string, 696 cxmutstr string,
683 cxstring delim, 697 cxstring delim,
684 size_t limit, 698 size_t limit,
691 * @param s1 the first string 705 * @param s1 the first string
692 * @param s2 the second string 706 * @param s2 the second string
693 * @return negative if \p s1 is smaller than \p s2, positive if \p s1 is larger 707 * @return negative if \p s1 is smaller than \p s2, positive if \p s1 is larger
694 * than \p s2, zero if both strings equal 708 * than \p s2, zero if both strings equal
695 */ 709 */
696 __attribute__((__warn_unused_result__)) 710 cx_attr_nodiscard
697 int cx_strcmp( 711 int cx_strcmp(
698 cxstring s1, 712 cxstring s1,
699 cxstring s2 713 cxstring s2
700 ); 714 );
701 715
705 * @param s1 the first string 719 * @param s1 the first string
706 * @param s2 the second string 720 * @param s2 the second string
707 * @return negative if \p s1 is smaller than \p s2, positive if \p s1 is larger 721 * @return negative if \p s1 is smaller than \p s2, positive if \p s1 is larger
708 * than \p s2, zero if both strings equal ignoring case 722 * than \p s2, zero if both strings equal ignoring case
709 */ 723 */
710 __attribute__((__warn_unused_result__)) 724 cx_attr_nodiscard
711 int cx_strcasecmp( 725 int cx_strcasecmp(
712 cxstring s1, 726 cxstring s1,
713 cxstring s2 727 cxstring s2
714 ); 728 );
715 729
721 * @param s1 the first string 735 * @param s1 the first string
722 * @param s2 the second string 736 * @param s2 the second string
723 * @return negative if \p s1 is smaller than \p s2, positive if \p s1 is larger 737 * @return negative if \p s1 is smaller than \p s2, positive if \p s1 is larger
724 * than \p s2, zero if both strings equal 738 * than \p s2, zero if both strings equal
725 */ 739 */
726 __attribute__((__warn_unused_result__, __nonnull__)) 740 cx_attr_nodiscard
741 cx_attr_nonnull
727 int cx_strcmp_p( 742 int cx_strcmp_p(
728 const void *s1, 743 const void *s1,
729 const void *s2 744 const void *s2
730 ); 745 );
731 746
737 * @param s1 the first string 752 * @param s1 the first string
738 * @param s2 the second string 753 * @param s2 the second string
739 * @return negative if \p s1 is smaller than \p s2, positive if \p s1 is larger 754 * @return negative if \p s1 is smaller than \p s2, positive if \p s1 is larger
740 * than \p s2, zero if both strings equal ignoring case 755 * than \p s2, zero if both strings equal ignoring case
741 */ 756 */
742 __attribute__((__warn_unused_result__, __nonnull__)) 757 cx_attr_nodiscard
758 cx_attr_nonnull
743 int cx_strcasecmp_p( 759 int cx_strcasecmp_p(
744 const void *s1, 760 const void *s1,
745 const void *s2 761 const void *s2
746 ); 762 );
747 763
756 * @param allocator the allocator to use 772 * @param allocator the allocator to use
757 * @param string the string to duplicate 773 * @param string the string to duplicate
758 * @return a duplicate of the string 774 * @return a duplicate of the string
759 * @see cx_strdup() 775 * @see cx_strdup()
760 */ 776 */
761 __attribute__((__warn_unused_result__, __nonnull__)) 777 cx_attr_nodiscard
778 cx_attr_nonnull
762 cxmutstr cx_strdup_a( 779 cxmutstr cx_strdup_a(
763 const CxAllocator *allocator, 780 const CxAllocator *allocator,
764 cxstring string 781 cxstring string
765 ); 782 );
766 783
814 * must \em not free the returned memory. 831 * must \em not free the returned memory.
815 * 832 *
816 * @param string the string that shall be trimmed 833 * @param string the string that shall be trimmed
817 * @return the trimmed string 834 * @return the trimmed string
818 */ 835 */
819 __attribute__((__warn_unused_result__)) 836 cx_attr_nodiscard
820 cxstring cx_strtrim(cxstring string); 837 cxstring cx_strtrim(cxstring string);
821 838
822 /** 839 /**
823 * Omits leading and trailing spaces. 840 * Omits leading and trailing spaces.
824 * 841 *
826 * must \em not free the returned memory. 843 * must \em not free the returned memory.
827 * 844 *
828 * @param string the string that shall be trimmed 845 * @param string the string that shall be trimmed
829 * @return the trimmed string 846 * @return the trimmed string
830 */ 847 */
831 __attribute__((__warn_unused_result__)) 848 cx_attr_nodiscard
832 cxmutstr cx_strtrim_m(cxmutstr string); 849 cxmutstr cx_strtrim_m(cxmutstr string);
833 850
834 /** 851 /**
835 * Checks, if a string has a specific prefix. 852 * Checks, if a string has a specific prefix.
836 * 853 *
837 * @param string the string to check 854 * @param string the string to check
838 * @param prefix the prefix the string should have 855 * @param prefix the prefix the string should have
839 * @return \c true, if and only if the string has the specified prefix, 856 * @return \c true, if and only if the string has the specified prefix,
840 * \c false otherwise 857 * \c false otherwise
841 */ 858 */
842 __attribute__((__warn_unused_result__)) 859 cx_attr_nodiscard
843 bool cx_strprefix( 860 bool cx_strprefix(
844 cxstring string, 861 cxstring string,
845 cxstring prefix 862 cxstring prefix
846 ); 863 );
847 864
851 * @param string the string to check 868 * @param string the string to check
852 * @param suffix the suffix the string should have 869 * @param suffix the suffix the string should have
853 * @return \c true, if and only if the string has the specified suffix, 870 * @return \c true, if and only if the string has the specified suffix,
854 * \c false otherwise 871 * \c false otherwise
855 */ 872 */
856 __attribute__((__warn_unused_result__)) 873 cx_attr_nodiscard
857 bool cx_strsuffix( 874 bool cx_strsuffix(
858 cxstring string, 875 cxstring string,
859 cxstring suffix 876 cxstring suffix
860 ); 877 );
861 878
865 * @param string the string to check 882 * @param string the string to check
866 * @param prefix the prefix the string should have 883 * @param prefix the prefix the string should have
867 * @return \c true, if and only if the string has the specified prefix, 884 * @return \c true, if and only if the string has the specified prefix,
868 * \c false otherwise 885 * \c false otherwise
869 */ 886 */
870 __attribute__((__warn_unused_result__)) 887 cx_attr_nodiscard
871 bool cx_strcaseprefix( 888 bool cx_strcaseprefix(
872 cxstring string, 889 cxstring string,
873 cxstring prefix 890 cxstring prefix
874 ); 891 );
875 892
879 * @param string the string to check 896 * @param string the string to check
880 * @param suffix the suffix the string should have 897 * @param suffix the suffix the string should have
881 * @return \c true, if and only if the string has the specified suffix, 898 * @return \c true, if and only if the string has the specified suffix,
882 * \c false otherwise 899 * \c false otherwise
883 */ 900 */
884 __attribute__((__warn_unused_result__)) 901 cx_attr_nodiscard
885 bool cx_strcasesuffix( 902 bool cx_strcasesuffix(
886 cxstring string, 903 cxstring string,
887 cxstring suffix 904 cxstring suffix
888 ); 905 );
889 906
924 * @param pattern the pattern to search for 941 * @param pattern the pattern to search for
925 * @param replacement the replacement string 942 * @param replacement the replacement string
926 * @param replmax maximum number of replacements 943 * @param replmax maximum number of replacements
927 * @return the resulting string after applying the replacements 944 * @return the resulting string after applying the replacements
928 */ 945 */
929 __attribute__((__warn_unused_result__, __nonnull__)) 946 cx_attr_nodiscard
947 cx_attr_nonnull
930 cxmutstr cx_strreplacen_a( 948 cxmutstr cx_strreplacen_a(
931 const CxAllocator *allocator, 949 const CxAllocator *allocator,
932 cxstring str, 950 cxstring str,
933 cxstring pattern, 951 cxstring pattern,
934 cxstring replacement, 952 cxstring replacement,
1002 * @param str the string to tokenize 1020 * @param str the string to tokenize
1003 * @param delim the delimiter (must not be empty) 1021 * @param delim the delimiter (must not be empty)
1004 * @param limit the maximum number of tokens that shall be returned 1022 * @param limit the maximum number of tokens that shall be returned
1005 * @return a new string tokenization context 1023 * @return a new string tokenization context
1006 */ 1024 */
1007 __attribute__((__warn_unused_result__)) 1025 cx_attr_nodiscard
1008 CxStrtokCtx cx_strtok( 1026 CxStrtokCtx cx_strtok(
1009 cxstring str, 1027 cxstring str,
1010 cxstring delim, 1028 cxstring delim,
1011 size_t limit 1029 size_t limit
1012 ); 1030 );
1017 * @param str the string to tokenize 1035 * @param str the string to tokenize
1018 * @param delim the delimiter (must not be empty) 1036 * @param delim the delimiter (must not be empty)
1019 * @param limit the maximum number of tokens that shall be returned 1037 * @param limit the maximum number of tokens that shall be returned
1020 * @return a new string tokenization context 1038 * @return a new string tokenization context
1021 */ 1039 */
1022 __attribute__((__warn_unused_result__)) 1040 cx_attr_nodiscard
1023 CxStrtokCtx cx_strtok_m( 1041 CxStrtokCtx cx_strtok_m(
1024 cxmutstr str, 1042 cxmutstr str,
1025 cxstring delim, 1043 cxstring delim,
1026 size_t limit 1044 size_t limit
1027 ); 1045 );
1034 * @param ctx the tokenization context 1052 * @param ctx the tokenization context
1035 * @param token a pointer to memory where the next token shall be stored 1053 * @param token a pointer to memory where the next token shall be stored
1036 * @return true if successful, false if the limit or the end of the string 1054 * @return true if successful, false if the limit or the end of the string
1037 * has been reached 1055 * has been reached
1038 */ 1056 */
1039 __attribute__((__warn_unused_result__, __nonnull__)) 1057 cx_attr_nonnull
1058 cx_attr_nodiscard
1059 cx_attr_access_w(2)
1040 bool cx_strtok_next( 1060 bool cx_strtok_next(
1041 CxStrtokCtx *ctx, 1061 CxStrtokCtx *ctx,
1042 cxstring *token 1062 cxstring *token
1043 ); 1063 );
1044 1064
1052 * @param ctx the tokenization context 1072 * @param ctx the tokenization context
1053 * @param token a pointer to memory where the next token shall be stored 1073 * @param token a pointer to memory where the next token shall be stored
1054 * @return true if successful, false if the limit or the end of the string 1074 * @return true if successful, false if the limit or the end of the string
1055 * has been reached 1075 * has been reached
1056 */ 1076 */
1057 __attribute__((__warn_unused_result__, __nonnull__)) 1077 cx_attr_nonnull
1078 cx_attr_nodiscard
1079 cx_attr_access_w(2)
1058 bool cx_strtok_next_m( 1080 bool cx_strtok_next_m(
1059 CxStrtokCtx *ctx, 1081 CxStrtokCtx *ctx,
1060 cxmutstr *token 1082 cxmutstr *token
1061 ); 1083 );
1062 1084
1065 * 1087 *
1066 * @param ctx the tokenization context 1088 * @param ctx the tokenization context
1067 * @param delim array of more delimiters 1089 * @param delim array of more delimiters
1068 * @param count number of elements in the array 1090 * @param count number of elements in the array
1069 */ 1091 */
1070 __attribute__((__nonnull__)) 1092 cx_attr_nonnull
1093 cx_attr_access_r(2, 3)
1071 void cx_strtok_delim( 1094 void cx_strtok_delim(
1072 CxStrtokCtx *ctx, 1095 CxStrtokCtx *ctx,
1073 const cxstring *delim, 1096 const cxstring *delim,
1074 size_t count 1097 size_t count
1075 ); 1098 );

mercurial