src/cx/string.h

changeset 1180
4c3a69b9723a
parent 1176
247db6e629ad
equal deleted inserted replaced
1179:ca4c6f590a08 1180:4c3a69b9723a
40 #include "allocator.h" 40 #include "allocator.h"
41 41
42 /** 42 /**
43 * The maximum length of the "needle" in cx_strstr() that can use SBO. 43 * The maximum length of the "needle" in cx_strstr() that can use SBO.
44 */ 44 */
45 cx_attr_export
45 extern const unsigned cx_strstr_sbo_size; 46 extern const unsigned cx_strstr_sbo_size;
46 47
47 /** 48 /**
48 * The UCX string structure. 49 * The UCX string structure.
49 */ 50 */
173 * @see cx_mutstrn() 174 * @see cx_mutstrn()
174 */ 175 */
175 cx_attr_nonnull 176 cx_attr_nonnull
176 cx_attr_nodiscard 177 cx_attr_nodiscard
177 cx_attr_cstr_arg(1) 178 cx_attr_cstr_arg(1)
179 cx_attr_export
178 cxmutstr cx_mutstr(char *cstring); 180 cxmutstr cx_mutstr(char *cstring);
179 181
180 /** 182 /**
181 * Wraps a string that does not need to be zero-terminated. 183 * Wraps a string that does not need to be zero-terminated.
182 * 184 *
193 * 195 *
194 * @see cx_mutstr() 196 * @see cx_mutstr()
195 */ 197 */
196 cx_attr_nodiscard 198 cx_attr_nodiscard
197 cx_attr_access_rw(1, 2) 199 cx_attr_access_rw(1, 2)
200 cx_attr_export
198 cxmutstr cx_mutstrn( 201 cxmutstr cx_mutstrn(
199 char *cstring, 202 char *cstring,
200 size_t length 203 size_t length
201 ); 204 );
202 205
216 * @see cx_strn() 219 * @see cx_strn()
217 */ 220 */
218 cx_attr_nonnull 221 cx_attr_nonnull
219 cx_attr_nodiscard 222 cx_attr_nodiscard
220 cx_attr_cstr_arg(1) 223 cx_attr_cstr_arg(1)
224 cx_attr_export
221 cxstring cx_str(const char *cstring); 225 cxstring cx_str(const char *cstring);
222 226
223 227
224 /** 228 /**
225 * Wraps a string that does not need to be zero-terminated. 229 * Wraps a string that does not need to be zero-terminated.
237 * 241 *
238 * @see cx_str() 242 * @see cx_str()
239 */ 243 */
240 cx_attr_nodiscard 244 cx_attr_nodiscard
241 cx_attr_access_r(1, 2) 245 cx_attr_access_r(1, 2)
246 cx_attr_export
242 cxstring cx_strn( 247 cxstring cx_strn(
243 const char *cstring, 248 const char *cstring,
244 size_t length 249 size_t length
245 ); 250 );
246 251
305 * you ever have a <code>const char*</code> you are really supposed to free. 310 * you ever have a <code>const char*</code> you are really supposed to free.
306 * If you encounter such situation, you should double-check your code. 311 * If you encounter such situation, you should double-check your code.
307 * 312 *
308 * @param str the string to free 313 * @param str the string to free
309 */ 314 */
315 cx_attr_export
310 void cx_strfree(cxmutstr *str); 316 void cx_strfree(cxmutstr *str);
311 317
312 /** 318 /**
313 * Passes the pointer in this string to the allocators free function. 319 * Passes the pointer in this string to the allocators free function.
314 * 320 *
321 * 327 *
322 * @param alloc the allocator 328 * @param alloc the allocator
323 * @param str the string to free 329 * @param str the string to free
324 */ 330 */
325 cx_attr_nonnull_arg(1) 331 cx_attr_nonnull_arg(1)
332 cx_attr_export
326 void cx_strfree_a( 333 void cx_strfree_a(
327 const CxAllocator *alloc, 334 const CxAllocator *alloc,
328 cxmutstr *str 335 cxmutstr *str
329 ); 336 );
330 337
339 * @param count the total number of specified strings 346 * @param count the total number of specified strings
340 * @param ... all strings 347 * @param ... all strings
341 * @return the accumulated length of all strings 348 * @return the accumulated length of all strings
342 */ 349 */
343 cx_attr_nodiscard 350 cx_attr_nodiscard
351 cx_attr_export
344 size_t cx_strlen( 352 size_t cx_strlen(
345 size_t count, 353 size_t count,
346 ... 354 ...
347 ); 355 );
348 356
368 * @param ... all other UCX strings 376 * @param ... all other UCX strings
369 * @return the concatenated string 377 * @return the concatenated string
370 */ 378 */
371 cx_attr_nodiscard 379 cx_attr_nodiscard
372 cx_attr_nonnull 380 cx_attr_nonnull
381 cx_attr_export
373 cxmutstr cx_strcat_ma( 382 cxmutstr cx_strcat_ma(
374 const CxAllocator *alloc, 383 const CxAllocator *alloc,
375 cxmutstr str, 384 cxmutstr str,
376 size_t count, 385 size_t count,
377 ... 386 ...
456 * @see cx_strsubsl() 465 * @see cx_strsubsl()
457 * @see cx_strsubs_m() 466 * @see cx_strsubs_m()
458 * @see cx_strsubsl_m() 467 * @see cx_strsubsl_m()
459 */ 468 */
460 cx_attr_nodiscard 469 cx_attr_nodiscard
470 cx_attr_export
461 cxstring cx_strsubs( 471 cxstring cx_strsubs(
462 cxstring string, 472 cxstring string,
463 size_t start 473 size_t start
464 ); 474 );
465 475
481 * @see cx_strsubs() 491 * @see cx_strsubs()
482 * @see cx_strsubs_m() 492 * @see cx_strsubs_m()
483 * @see cx_strsubsl_m() 493 * @see cx_strsubsl_m()
484 */ 494 */
485 cx_attr_nodiscard 495 cx_attr_nodiscard
496 cx_attr_export
486 cxstring cx_strsubsl( 497 cxstring cx_strsubsl(
487 cxstring string, 498 cxstring string,
488 size_t start, 499 size_t start,
489 size_t length 500 size_t length
490 ); 501 );
503 * @see cx_strsubsl_m() 514 * @see cx_strsubsl_m()
504 * @see cx_strsubs() 515 * @see cx_strsubs()
505 * @see cx_strsubsl() 516 * @see cx_strsubsl()
506 */ 517 */
507 cx_attr_nodiscard 518 cx_attr_nodiscard
519 cx_attr_export
508 cxmutstr cx_strsubs_m( 520 cxmutstr cx_strsubs_m(
509 cxmutstr string, 521 cxmutstr string,
510 size_t start 522 size_t start
511 ); 523 );
512 524
528 * @see cx_strsubs_m() 540 * @see cx_strsubs_m()
529 * @see cx_strsubs() 541 * @see cx_strsubs()
530 * @see cx_strsubsl() 542 * @see cx_strsubsl()
531 */ 543 */
532 cx_attr_nodiscard 544 cx_attr_nodiscard
545 cx_attr_export
533 cxmutstr cx_strsubsl_m( 546 cxmutstr cx_strsubsl_m(
534 cxmutstr string, 547 cxmutstr string,
535 size_t start, 548 size_t start,
536 size_t length 549 size_t length
537 ); 550 );
547 * @return a substring starting at the first location of @p chr 560 * @return a substring starting at the first location of @p chr
548 * 561 *
549 * @see cx_strchr_m() 562 * @see cx_strchr_m()
550 */ 563 */
551 cx_attr_nodiscard 564 cx_attr_nodiscard
565 cx_attr_export
552 cxstring cx_strchr( 566 cxstring cx_strchr(
553 cxstring string, 567 cxstring string,
554 int chr 568 int chr
555 ); 569 );
556 570
565 * @return a substring starting at the first location of @p chr 579 * @return a substring starting at the first location of @p chr
566 * 580 *
567 * @see cx_strchr() 581 * @see cx_strchr()
568 */ 582 */
569 cx_attr_nodiscard 583 cx_attr_nodiscard
584 cx_attr_export
570 cxmutstr cx_strchr_m( 585 cxmutstr cx_strchr_m(
571 cxmutstr string, 586 cxmutstr string,
572 int chr 587 int chr
573 ); 588 );
574 589
583 * @return a substring starting at the last location of @p chr 598 * @return a substring starting at the last location of @p chr
584 * 599 *
585 * @see cx_strrchr_m() 600 * @see cx_strrchr_m()
586 */ 601 */
587 cx_attr_nodiscard 602 cx_attr_nodiscard
603 cx_attr_export
588 cxstring cx_strrchr( 604 cxstring cx_strrchr(
589 cxstring string, 605 cxstring string,
590 int chr 606 int chr
591 ); 607 );
592 608
601 * @return a substring starting at the last location of @p chr 617 * @return a substring starting at the last location of @p chr
602 * 618 *
603 * @see cx_strrchr() 619 * @see cx_strrchr()
604 */ 620 */
605 cx_attr_nodiscard 621 cx_attr_nodiscard
622 cx_attr_export
606 cxmutstr cx_strrchr_m( 623 cxmutstr cx_strrchr_m(
607 cxmutstr string, 624 cxmutstr string,
608 int chr 625 int chr
609 ); 626 );
610 627
623 * @p needle, or an empty string, if the sequence is not 640 * @p needle, or an empty string, if the sequence is not
624 * contained 641 * contained
625 * @see cx_strstr_m() 642 * @see cx_strstr_m()
626 */ 643 */
627 cx_attr_nodiscard 644 cx_attr_nodiscard
645 cx_attr_export
628 cxstring cx_strstr( 646 cxstring cx_strstr(
629 cxstring haystack, 647 cxstring haystack,
630 cxstring needle 648 cxstring needle
631 ); 649 );
632 650
645 * @p needle, or an empty string, if the sequence is not 663 * @p needle, or an empty string, if the sequence is not
646 * contained 664 * contained
647 * @see cx_strstr() 665 * @see cx_strstr()
648 */ 666 */
649 cx_attr_nodiscard 667 cx_attr_nodiscard
668 cx_attr_export
650 cxmutstr cx_strstr_m( 669 cxmutstr cx_strstr_m(
651 cxmutstr haystack, 670 cxmutstr haystack,
652 cxstring needle 671 cxstring needle
653 ); 672 );
654 673
665 * @return the actual number of split items 684 * @return the actual number of split items
666 */ 685 */
667 cx_attr_nodiscard 686 cx_attr_nodiscard
668 cx_attr_nonnull 687 cx_attr_nonnull
669 cx_attr_access_w(4, 3) 688 cx_attr_access_w(4, 3)
689 cx_attr_export
670 size_t cx_strsplit( 690 size_t cx_strsplit(
671 cxstring string, 691 cxstring string,
672 cxstring delim, 692 cxstring delim,
673 size_t limit, 693 size_t limit,
674 cxstring *output 694 cxstring *output
694 * @return the actual number of split items 714 * @return the actual number of split items
695 */ 715 */
696 cx_attr_nodiscard 716 cx_attr_nodiscard
697 cx_attr_nonnull 717 cx_attr_nonnull
698 cx_attr_access_w(5) 718 cx_attr_access_w(5)
719 cx_attr_export
699 size_t cx_strsplit_a( 720 size_t cx_strsplit_a(
700 const CxAllocator *allocator, 721 const CxAllocator *allocator,
701 cxstring string, 722 cxstring string,
702 cxstring delim, 723 cxstring delim,
703 size_t limit, 724 size_t limit,
718 * @return the actual number of split items 739 * @return the actual number of split items
719 */ 740 */
720 cx_attr_nodiscard 741 cx_attr_nodiscard
721 cx_attr_nonnull 742 cx_attr_nonnull
722 cx_attr_access_w(4, 3) 743 cx_attr_access_w(4, 3)
744 cx_attr_export
723 size_t cx_strsplit_m( 745 size_t cx_strsplit_m(
724 cxmutstr string, 746 cxmutstr string,
725 cxstring delim, 747 cxstring delim,
726 size_t limit, 748 size_t limit,
727 cxmutstr *output 749 cxmutstr *output
747 * @return the actual number of split items 769 * @return the actual number of split items
748 */ 770 */
749 cx_attr_nodiscard 771 cx_attr_nodiscard
750 cx_attr_nonnull 772 cx_attr_nonnull
751 cx_attr_access_w(5) 773 cx_attr_access_w(5)
774 cx_attr_export
752 size_t cx_strsplit_ma( 775 size_t cx_strsplit_ma(
753 const CxAllocator *allocator, 776 const CxAllocator *allocator,
754 cxmutstr string, 777 cxmutstr string,
755 cxstring delim, 778 cxstring delim,
756 size_t limit, 779 size_t limit,
764 * @param s2 the second string 787 * @param s2 the second string
765 * @return negative if @p s1 is smaller than @p s2, positive if @p s1 is larger 788 * @return negative if @p s1 is smaller than @p s2, positive if @p s1 is larger
766 * than @p s2, zero if both strings equal 789 * than @p s2, zero if both strings equal
767 */ 790 */
768 cx_attr_nodiscard 791 cx_attr_nodiscard
792 cx_attr_export
769 int cx_strcmp( 793 int cx_strcmp(
770 cxstring s1, 794 cxstring s1,
771 cxstring s2 795 cxstring s2
772 ); 796 );
773 797
778 * @param s2 the second string 802 * @param s2 the second string
779 * @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
780 * than @p s2, zero if both strings equal ignoring case 804 * than @p s2, zero if both strings equal ignoring case
781 */ 805 */
782 cx_attr_nodiscard 806 cx_attr_nodiscard
807 cx_attr_export
783 int cx_strcasecmp( 808 int cx_strcasecmp(
784 cxstring s1, 809 cxstring s1,
785 cxstring s2 810 cxstring s2
786 ); 811 );
787 812
795 * @return negative if @p s1 is smaller than @p s2, positive if @p s1 is larger 820 * @return negative if @p s1 is smaller than @p s2, positive if @p s1 is larger
796 * than @p s2, zero if both strings equal 821 * than @p s2, zero if both strings equal
797 */ 822 */
798 cx_attr_nodiscard 823 cx_attr_nodiscard
799 cx_attr_nonnull 824 cx_attr_nonnull
825 cx_attr_export
800 int cx_strcmp_p( 826 int cx_strcmp_p(
801 const void *s1, 827 const void *s1,
802 const void *s2 828 const void *s2
803 ); 829 );
804 830
812 * @return negative if @p s1 is smaller than @p s2, positive if @p s1 is larger 838 * @return negative if @p s1 is smaller than @p s2, positive if @p s1 is larger
813 * than @p s2, zero if both strings equal ignoring case 839 * than @p s2, zero if both strings equal ignoring case
814 */ 840 */
815 cx_attr_nodiscard 841 cx_attr_nodiscard
816 cx_attr_nonnull 842 cx_attr_nonnull
843 cx_attr_export
817 int cx_strcasecmp_p( 844 int cx_strcasecmp_p(
818 const void *s1, 845 const void *s1,
819 const void *s2 846 const void *s2
820 ); 847 );
821 848
832 * @return a duplicate of the string 859 * @return a duplicate of the string
833 * @see cx_strdup() 860 * @see cx_strdup()
834 */ 861 */
835 cx_attr_nodiscard 862 cx_attr_nodiscard
836 cx_attr_nonnull 863 cx_attr_nonnull
864 cx_attr_export
837 cxmutstr cx_strdup_a_( 865 cxmutstr cx_strdup_a_(
838 const CxAllocator *allocator, 866 const CxAllocator *allocator,
839 cxstring string 867 cxstring string
840 ); 868 );
841 869
878 * 906 *
879 * @param string the string that shall be trimmed 907 * @param string the string that shall be trimmed
880 * @return the trimmed string 908 * @return the trimmed string
881 */ 909 */
882 cx_attr_nodiscard 910 cx_attr_nodiscard
911 cx_attr_export
883 cxstring cx_strtrim(cxstring string); 912 cxstring cx_strtrim(cxstring string);
884 913
885 /** 914 /**
886 * Omits leading and trailing spaces. 915 * Omits leading and trailing spaces.
887 * 916 *
890 * 919 *
891 * @param string the string that shall be trimmed 920 * @param string the string that shall be trimmed
892 * @return the trimmed string 921 * @return the trimmed string
893 */ 922 */
894 cx_attr_nodiscard 923 cx_attr_nodiscard
924 cx_attr_export
895 cxmutstr cx_strtrim_m(cxmutstr string); 925 cxmutstr cx_strtrim_m(cxmutstr string);
896 926
897 /** 927 /**
898 * Checks, if a string has a specific prefix. 928 * Checks, if a string has a specific prefix.
899 * 929 *
901 * @param prefix the prefix the string should have 931 * @param prefix the prefix the string should have
902 * @return @c true, if and only if the string has the specified prefix, 932 * @return @c true, if and only if the string has the specified prefix,
903 * @c false otherwise 933 * @c false otherwise
904 */ 934 */
905 cx_attr_nodiscard 935 cx_attr_nodiscard
936 cx_attr_export
906 bool cx_strprefix( 937 bool cx_strprefix(
907 cxstring string, 938 cxstring string,
908 cxstring prefix 939 cxstring prefix
909 ); 940 );
910 941
915 * @param suffix the suffix the string should have 946 * @param suffix the suffix the string should have
916 * @return @c true, if and only if the string has the specified suffix, 947 * @return @c true, if and only if the string has the specified suffix,
917 * @c false otherwise 948 * @c false otherwise
918 */ 949 */
919 cx_attr_nodiscard 950 cx_attr_nodiscard
951 cx_attr_export
920 bool cx_strsuffix( 952 bool cx_strsuffix(
921 cxstring string, 953 cxstring string,
922 cxstring suffix 954 cxstring suffix
923 ); 955 );
924 956
929 * @param prefix the prefix the string should have 961 * @param prefix the prefix the string should have
930 * @return @c true, if and only if the string has the specified prefix, 962 * @return @c true, if and only if the string has the specified prefix,
931 * @c false otherwise 963 * @c false otherwise
932 */ 964 */
933 cx_attr_nodiscard 965 cx_attr_nodiscard
966 cx_attr_export
934 bool cx_strcaseprefix( 967 bool cx_strcaseprefix(
935 cxstring string, 968 cxstring string,
936 cxstring prefix 969 cxstring prefix
937 ); 970 );
938 971
943 * @param suffix the suffix the string should have 976 * @param suffix the suffix the string should have
944 * @return @c true, if and only if the string has the specified suffix, 977 * @return @c true, if and only if the string has the specified suffix,
945 * @c false otherwise 978 * @c false otherwise
946 */ 979 */
947 cx_attr_nodiscard 980 cx_attr_nodiscard
981 cx_attr_export
948 bool cx_strcasesuffix( 982 bool cx_strcasesuffix(
949 cxstring string, 983 cxstring string,
950 cxstring suffix 984 cxstring suffix
951 ); 985 );
952 986
969 * @param replmax maximum number of replacements 1003 * @param replmax maximum number of replacements
970 * @return the resulting string after applying the replacements 1004 * @return the resulting string after applying the replacements
971 */ 1005 */
972 cx_attr_nodiscard 1006 cx_attr_nodiscard
973 cx_attr_nonnull 1007 cx_attr_nonnull
1008 cx_attr_export
974 cxmutstr cx_strreplacen_a( 1009 cxmutstr cx_strreplacen_a(
975 const CxAllocator *allocator, 1010 const CxAllocator *allocator,
976 cxstring str, 1011 cxstring str,
977 cxstring pattern, 1012 cxstring pattern,
978 cxstring replacement, 1013 cxstring replacement,
1047 * @param delim the delimiter (must not be empty) 1082 * @param delim the delimiter (must not be empty)
1048 * @param limit the maximum number of tokens that shall be returned 1083 * @param limit the maximum number of tokens that shall be returned
1049 * @return a new string tokenization context 1084 * @return a new string tokenization context
1050 */ 1085 */
1051 cx_attr_nodiscard 1086 cx_attr_nodiscard
1087 cx_attr_export
1052 CxStrtokCtx cx_strtok_( 1088 CxStrtokCtx cx_strtok_(
1053 cxstring str, 1089 cxstring str,
1054 cxstring delim, 1090 cxstring delim,
1055 size_t limit 1091 size_t limit
1056 ); 1092 );
1077 * has been reached 1113 * has been reached
1078 */ 1114 */
1079 cx_attr_nonnull 1115 cx_attr_nonnull
1080 cx_attr_nodiscard 1116 cx_attr_nodiscard
1081 cx_attr_access_w(2) 1117 cx_attr_access_w(2)
1118 cx_attr_export
1082 bool cx_strtok_next( 1119 bool cx_strtok_next(
1083 CxStrtokCtx *ctx, 1120 CxStrtokCtx *ctx,
1084 cxstring *token 1121 cxstring *token
1085 ); 1122 );
1086 1123
1099 * has been reached 1136 * has been reached
1100 */ 1137 */
1101 cx_attr_nonnull 1138 cx_attr_nonnull
1102 cx_attr_nodiscard 1139 cx_attr_nodiscard
1103 cx_attr_access_w(2) 1140 cx_attr_access_w(2)
1141 cx_attr_export
1104 bool cx_strtok_next_m( 1142 bool cx_strtok_next_m(
1105 CxStrtokCtx *ctx, 1143 CxStrtokCtx *ctx,
1106 cxmutstr *token 1144 cxmutstr *token
1107 ); 1145 );
1108 1146
1113 * @param delim array of more delimiters 1151 * @param delim array of more delimiters
1114 * @param count number of elements in the array 1152 * @param count number of elements in the array
1115 */ 1153 */
1116 cx_attr_nonnull 1154 cx_attr_nonnull
1117 cx_attr_access_r(2, 3) 1155 cx_attr_access_r(2, 3)
1156 cx_attr_export
1118 void cx_strtok_delim( 1157 void cx_strtok_delim(
1119 CxStrtokCtx *ctx, 1158 CxStrtokCtx *ctx,
1120 const cxstring *delim, 1159 const cxstring *delim,
1121 size_t count 1160 size_t count
1122 ); 1161 );
1137 * @param base 2, 8, 10, or 16 1176 * @param base 2, 8, 10, or 16
1138 * @param groupsep each character in this string is treated as group separator and ignored during conversion 1177 * @param groupsep each character in this string is treated as group separator and ignored during conversion
1139 * @retval zero success 1178 * @retval zero success
1140 * @retval non-zero conversion was not possible 1179 * @retval non-zero conversion was not possible
1141 */ 1180 */
1142 cx_attr_access_w(2) cx_attr_nonnull_arg(2) 1181 cx_attr_access_w(2) cx_attr_nonnull_arg(2) cx_attr_export
1143 int cx_strtos_lc_(cxstring str, short *output, int base, const char *groupsep); 1182 int cx_strtos_lc_(cxstring str, short *output, int base, const char *groupsep);
1144 1183
1145 /** 1184 /**
1146 * Converts a string to a number. 1185 * Converts a string to a number.
1147 * 1186 *
1154 * @param base 2, 8, 10, or 16 1193 * @param base 2, 8, 10, or 16
1155 * @param groupsep each character in this string is treated as group separator and ignored during conversion 1194 * @param groupsep each character in this string is treated as group separator and ignored during conversion
1156 * @retval zero success 1195 * @retval zero success
1157 * @retval non-zero conversion was not possible 1196 * @retval non-zero conversion was not possible
1158 */ 1197 */
1159 cx_attr_access_w(2) cx_attr_nonnull_arg(2) 1198 cx_attr_access_w(2) cx_attr_nonnull_arg(2) cx_attr_export
1160 int cx_strtoi_lc_(cxstring str, int *output, int base, const char *groupsep); 1199 int cx_strtoi_lc_(cxstring str, int *output, int base, const char *groupsep);
1161 1200
1162 /** 1201 /**
1163 * Converts a string to a number. 1202 * Converts a string to a number.
1164 * 1203 *
1171 * @param base 2, 8, 10, or 16 1210 * @param base 2, 8, 10, or 16
1172 * @param groupsep each character in this string is treated as group separator and ignored during conversion 1211 * @param groupsep each character in this string is treated as group separator and ignored during conversion
1173 * @retval zero success 1212 * @retval zero success
1174 * @retval non-zero conversion was not possible 1213 * @retval non-zero conversion was not possible
1175 */ 1214 */
1176 cx_attr_access_w(2) cx_attr_nonnull_arg(2) 1215 cx_attr_access_w(2) cx_attr_nonnull_arg(2) cx_attr_export
1177 int cx_strtol_lc_(cxstring str, long *output, int base, const char *groupsep); 1216 int cx_strtol_lc_(cxstring str, long *output, int base, const char *groupsep);
1178 1217
1179 /** 1218 /**
1180 * Converts a string to a number. 1219 * Converts a string to a number.
1181 * 1220 *
1188 * @param base 2, 8, 10, or 16 1227 * @param base 2, 8, 10, or 16
1189 * @param groupsep each character in this string is treated as group separator and ignored during conversion 1228 * @param groupsep each character in this string is treated as group separator and ignored during conversion
1190 * @retval zero success 1229 * @retval zero success
1191 * @retval non-zero conversion was not possible 1230 * @retval non-zero conversion was not possible
1192 */ 1231 */
1193 cx_attr_access_w(2) cx_attr_nonnull_arg(2) 1232 cx_attr_access_w(2) cx_attr_nonnull_arg(2) cx_attr_export
1194 int cx_strtoll_lc_(cxstring str, long long *output, int base, const char *groupsep); 1233 int cx_strtoll_lc_(cxstring str, long long *output, int base, const char *groupsep);
1195 1234
1196 /** 1235 /**
1197 * Converts a string to a number. 1236 * Converts a string to a number.
1198 * 1237 *
1205 * @param base 2, 8, 10, or 16 1244 * @param base 2, 8, 10, or 16
1206 * @param groupsep each character in this string is treated as group separator and ignored during conversion 1245 * @param groupsep each character in this string is treated as group separator and ignored during conversion
1207 * @retval zero success 1246 * @retval zero success
1208 * @retval non-zero conversion was not possible 1247 * @retval non-zero conversion was not possible
1209 */ 1248 */
1210 cx_attr_access_w(2) cx_attr_nonnull_arg(2) 1249 cx_attr_access_w(2) cx_attr_nonnull_arg(2) cx_attr_export
1211 int cx_strtoi8_lc_(cxstring str, int8_t *output, int base, const char *groupsep); 1250 int cx_strtoi8_lc_(cxstring str, int8_t *output, int base, const char *groupsep);
1212 1251
1213 /** 1252 /**
1214 * Converts a string to a number. 1253 * Converts a string to a number.
1215 * 1254 *
1222 * @param base 2, 8, 10, or 16 1261 * @param base 2, 8, 10, or 16
1223 * @param groupsep each character in this string is treated as group separator and ignored during conversion 1262 * @param groupsep each character in this string is treated as group separator and ignored during conversion
1224 * @retval zero success 1263 * @retval zero success
1225 * @retval non-zero conversion was not possible 1264 * @retval non-zero conversion was not possible
1226 */ 1265 */
1227 cx_attr_access_w(2) cx_attr_nonnull_arg(2) 1266 cx_attr_access_w(2) cx_attr_nonnull_arg(2) cx_attr_export
1228 int cx_strtoi16_lc_(cxstring str, int16_t *output, int base, const char *groupsep); 1267 int cx_strtoi16_lc_(cxstring str, int16_t *output, int base, const char *groupsep);
1229 1268
1230 /** 1269 /**
1231 * Converts a string to a number. 1270 * Converts a string to a number.
1232 * 1271 *
1239 * @param base 2, 8, 10, or 16 1278 * @param base 2, 8, 10, or 16
1240 * @param groupsep each character in this string is treated as group separator and ignored during conversion 1279 * @param groupsep each character in this string is treated as group separator and ignored during conversion
1241 * @retval zero success 1280 * @retval zero success
1242 * @retval non-zero conversion was not possible 1281 * @retval non-zero conversion was not possible
1243 */ 1282 */
1244 cx_attr_access_w(2) cx_attr_nonnull_arg(2) 1283 cx_attr_access_w(2) cx_attr_nonnull_arg(2) cx_attr_export
1245 int cx_strtoi32_lc_(cxstring str, int32_t *output, int base, const char *groupsep); 1284 int cx_strtoi32_lc_(cxstring str, int32_t *output, int base, const char *groupsep);
1246 1285
1247 /** 1286 /**
1248 * Converts a string to a number. 1287 * Converts a string to a number.
1249 * 1288 *
1256 * @param base 2, 8, 10, or 16 1295 * @param base 2, 8, 10, or 16
1257 * @param groupsep each character in this string is treated as group separator and ignored during conversion 1296 * @param groupsep each character in this string is treated as group separator and ignored during conversion
1258 * @retval zero success 1297 * @retval zero success
1259 * @retval non-zero conversion was not possible 1298 * @retval non-zero conversion was not possible
1260 */ 1299 */
1261 cx_attr_access_w(2) cx_attr_nonnull_arg(2) 1300 cx_attr_access_w(2) cx_attr_nonnull_arg(2) cx_attr_export
1262 int cx_strtoi64_lc_(cxstring str, int64_t *output, int base, const char *groupsep); 1301 int cx_strtoi64_lc_(cxstring str, int64_t *output, int base, const char *groupsep);
1263 1302
1264 /** 1303 /**
1265 * Converts a string to a number. 1304 * Converts a string to a number.
1266 * 1305 *
1273 * @param base 2, 8, 10, or 16 1312 * @param base 2, 8, 10, or 16
1274 * @param groupsep each character in this string is treated as group separator and ignored during conversion 1313 * @param groupsep each character in this string is treated as group separator and ignored during conversion
1275 * @retval zero success 1314 * @retval zero success
1276 * @retval non-zero conversion was not possible 1315 * @retval non-zero conversion was not possible
1277 */ 1316 */
1278 cx_attr_access_w(2) cx_attr_nonnull_arg(2) 1317 cx_attr_access_w(2) cx_attr_nonnull_arg(2) cx_attr_export
1279 int cx_strtous_lc_(cxstring str, unsigned short *output, int base, const char *groupsep); 1318 int cx_strtous_lc_(cxstring str, unsigned short *output, int base, const char *groupsep);
1280 1319
1281 /** 1320 /**
1282 * Converts a string to a number. 1321 * Converts a string to a number.
1283 * 1322 *
1290 * @param base 2, 8, 10, or 16 1329 * @param base 2, 8, 10, or 16
1291 * @param groupsep each character in this string is treated as group separator and ignored during conversion 1330 * @param groupsep each character in this string is treated as group separator and ignored during conversion
1292 * @retval zero success 1331 * @retval zero success
1293 * @retval non-zero conversion was not possible 1332 * @retval non-zero conversion was not possible
1294 */ 1333 */
1295 cx_attr_access_w(2) cx_attr_nonnull_arg(2) 1334 cx_attr_access_w(2) cx_attr_nonnull_arg(2) cx_attr_export
1296 int cx_strtou_lc_(cxstring str, unsigned int *output, int base, const char *groupsep); 1335 int cx_strtou_lc_(cxstring str, unsigned int *output, int base, const char *groupsep);
1297 1336
1298 /** 1337 /**
1299 * Converts a string to a number. 1338 * Converts a string to a number.
1300 * 1339 *
1307 * @param base 2, 8, 10, or 16 1346 * @param base 2, 8, 10, or 16
1308 * @param groupsep each character in this string is treated as group separator and ignored during conversion 1347 * @param groupsep each character in this string is treated as group separator and ignored during conversion
1309 * @retval zero success 1348 * @retval zero success
1310 * @retval non-zero conversion was not possible 1349 * @retval non-zero conversion was not possible
1311 */ 1350 */
1312 cx_attr_access_w(2) cx_attr_nonnull_arg(2) 1351 cx_attr_access_w(2) cx_attr_nonnull_arg(2) cx_attr_export
1313 int cx_strtoul_lc_(cxstring str, unsigned long *output, int base, const char *groupsep); 1352 int cx_strtoul_lc_(cxstring str, unsigned long *output, int base, const char *groupsep);
1314 1353
1315 /** 1354 /**
1316 * Converts a string to a number. 1355 * Converts a string to a number.
1317 * 1356 *
1324 * @param base 2, 8, 10, or 16 1363 * @param base 2, 8, 10, or 16
1325 * @param groupsep each character in this string is treated as group separator and ignored during conversion 1364 * @param groupsep each character in this string is treated as group separator and ignored during conversion
1326 * @retval zero success 1365 * @retval zero success
1327 * @retval non-zero conversion was not possible 1366 * @retval non-zero conversion was not possible
1328 */ 1367 */
1329 cx_attr_access_w(2) cx_attr_nonnull_arg(2) 1368 cx_attr_access_w(2) cx_attr_nonnull_arg(2) cx_attr_export
1330 int cx_strtoull_lc_(cxstring str, unsigned long long *output, int base, const char *groupsep); 1369 int cx_strtoull_lc_(cxstring str, unsigned long long *output, int base, const char *groupsep);
1331 1370
1332 /** 1371 /**
1333 * Converts a string to a number. 1372 * Converts a string to a number.
1334 * 1373 *
1341 * @param base 2, 8, 10, or 16 1380 * @param base 2, 8, 10, or 16
1342 * @param groupsep each character in this string is treated as group separator and ignored during conversion 1381 * @param groupsep each character in this string is treated as group separator and ignored during conversion
1343 * @retval zero success 1382 * @retval zero success
1344 * @retval non-zero conversion was not possible 1383 * @retval non-zero conversion was not possible
1345 */ 1384 */
1346 cx_attr_access_w(2) cx_attr_nonnull_arg(2) 1385 cx_attr_access_w(2) cx_attr_nonnull_arg(2) cx_attr_export
1347 int cx_strtou8_lc_(cxstring str, uint8_t *output, int base, const char *groupsep); 1386 int cx_strtou8_lc_(cxstring str, uint8_t *output, int base, const char *groupsep);
1348 1387
1349 /** 1388 /**
1350 * Converts a string to a number. 1389 * Converts a string to a number.
1351 * 1390 *
1358 * @param base 2, 8, 10, or 16 1397 * @param base 2, 8, 10, or 16
1359 * @param groupsep each character in this string is treated as group separator and ignored during conversion 1398 * @param groupsep each character in this string is treated as group separator and ignored during conversion
1360 * @retval zero success 1399 * @retval zero success
1361 * @retval non-zero conversion was not possible 1400 * @retval non-zero conversion was not possible
1362 */ 1401 */
1363 cx_attr_access_w(2) cx_attr_nonnull_arg(2) 1402 cx_attr_access_w(2) cx_attr_nonnull_arg(2) cx_attr_export
1364 int cx_strtou16_lc_(cxstring str, uint16_t *output, int base, const char *groupsep); 1403 int cx_strtou16_lc_(cxstring str, uint16_t *output, int base, const char *groupsep);
1365 1404
1366 /** 1405 /**
1367 * Converts a string to a number. 1406 * Converts a string to a number.
1368 * 1407 *
1375 * @param base 2, 8, 10, or 16 1414 * @param base 2, 8, 10, or 16
1376 * @param groupsep each character in this string is treated as group separator and ignored during conversion 1415 * @param groupsep each character in this string is treated as group separator and ignored during conversion
1377 * @retval zero success 1416 * @retval zero success
1378 * @retval non-zero conversion was not possible 1417 * @retval non-zero conversion was not possible
1379 */ 1418 */
1380 cx_attr_access_w(2) cx_attr_nonnull_arg(2) 1419 cx_attr_access_w(2) cx_attr_nonnull_arg(2) cx_attr_export
1381 int cx_strtou32_lc_(cxstring str, uint32_t *output, int base, const char *groupsep); 1420 int cx_strtou32_lc_(cxstring str, uint32_t *output, int base, const char *groupsep);
1382 1421
1383 /** 1422 /**
1384 * Converts a string to a number. 1423 * Converts a string to a number.
1385 * 1424 *
1392 * @param base 2, 8, 10, or 16 1431 * @param base 2, 8, 10, or 16
1393 * @param groupsep each character in this string is treated as group separator and ignored during conversion 1432 * @param groupsep each character in this string is treated as group separator and ignored during conversion
1394 * @retval zero success 1433 * @retval zero success
1395 * @retval non-zero conversion was not possible 1434 * @retval non-zero conversion was not possible
1396 */ 1435 */
1397 cx_attr_access_w(2) cx_attr_nonnull_arg(2) 1436 cx_attr_access_w(2) cx_attr_nonnull_arg(2) cx_attr_export
1398 int cx_strtou64_lc_(cxstring str, uint64_t *output, int base, const char *groupsep); 1437 int cx_strtou64_lc_(cxstring str, uint64_t *output, int base, const char *groupsep);
1399 1438
1400 /** 1439 /**
1401 * Converts a string to a number. 1440 * Converts a string to a number.
1402 * 1441 *
1409 * @param base 2, 8, 10, or 16 1448 * @param base 2, 8, 10, or 16
1410 * @param groupsep each character in this string is treated as group separator and ignored during conversion 1449 * @param groupsep each character in this string is treated as group separator and ignored during conversion
1411 * @retval zero success 1450 * @retval zero success
1412 * @retval non-zero conversion was not possible 1451 * @retval non-zero conversion was not possible
1413 */ 1452 */
1414 cx_attr_access_w(2) cx_attr_nonnull_arg(2) 1453 cx_attr_access_w(2) cx_attr_nonnull_arg(2) cx_attr_export
1415 int cx_strtoz_lc_(cxstring str, size_t *output, int base, const char *groupsep); 1454 int cx_strtoz_lc_(cxstring str, size_t *output, int base, const char *groupsep);
1416 1455
1417 /** 1456 /**
1418 * Converts a string to a single precision floating point number. 1457 * Converts a string to a single precision floating point number.
1419 * 1458 *
1426 * @param decsep the decimal separator 1465 * @param decsep the decimal separator
1427 * @param groupsep each character in this string is treated as group separator and ignored during conversion 1466 * @param groupsep each character in this string is treated as group separator and ignored during conversion
1428 * @retval zero success 1467 * @retval zero success
1429 * @retval non-zero conversion was not possible 1468 * @retval non-zero conversion was not possible
1430 */ 1469 */
1431 cx_attr_access_w(2) cx_attr_nonnull_arg(2) 1470 cx_attr_access_w(2) cx_attr_nonnull_arg(2) cx_attr_export
1432 int cx_strtof_lc_(cxstring str, float *output, char decsep, const char *groupsep); 1471 int cx_strtof_lc_(cxstring str, float *output, char decsep, const char *groupsep);
1433 1472
1434 /** 1473 /**
1435 * Converts a string to a double precision floating point number. 1474 * Converts a string to a double precision floating point number.
1436 * 1475 *
1443 * @param decsep the decimal separator 1482 * @param decsep the decimal separator
1444 * @param groupsep each character in this string is treated as group separator and ignored during conversion 1483 * @param groupsep each character in this string is treated as group separator and ignored during conversion
1445 * @retval zero success 1484 * @retval zero success
1446 * @retval non-zero conversion was not possible 1485 * @retval non-zero conversion was not possible
1447 */ 1486 */
1448 cx_attr_access_w(2) cx_attr_nonnull_arg(2) 1487 cx_attr_access_w(2) cx_attr_nonnull_arg(2) cx_attr_export
1449 int cx_strtod_lc_(cxstring str, double *output, char decsep, const char *groupsep); 1488 int cx_strtod_lc_(cxstring str, double *output, char decsep, const char *groupsep);
1450 1489
1451 /** 1490 /**
1452 * Converts a string to a number. 1491 * Converts a string to a number.
1453 * 1492 *

mercurial