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 * Wraps any string into an UCX string. |
307 * Wraps any string into an UCX string. |
310 * @return (@c cxstring) the string wrapped as UCX string |
310 * @return (@c cxstring) the string wrapped as UCX string |
311 */ |
311 */ |
312 #define cx_strcast(str) _Generic((str), \ |
312 #define cx_strcast(str) _Generic((str), \ |
313 cxmutstr: cx_strcast_m, \ |
313 cxmutstr: cx_strcast_m, \ |
314 cxstring: cx_strcast_c, \ |
314 cxstring: cx_strcast_c, \ |
315 const unsigned char*: cx_strcast_z, \ |
315 const unsigned char*: cx_strcast_u, \ |
316 unsigned char *: cx_strcast_z, \ |
316 unsigned char *: cx_strcast_u, \ |
317 const char*: cx_strcast_z, \ |
317 const char*: cx_strcast_z, \ |
318 char *: cx_strcast_z) (str) |
318 char *: cx_strcast_z) (str) |
319 #endif |
319 #endif |
320 |
320 |
321 /** |
321 /** |
432 * @param str the string the other strings shall be concatenated to |
418 * @param str the string the other strings shall be concatenated to |
433 * @param count the number of the other following strings to concatenate |
419 * @param count the number of the other following strings to concatenate |
434 * @param ... all other UCX strings |
420 * @param ... all other UCX strings |
435 * @return the concatenated string |
421 * @return the concatenated string |
436 */ |
422 */ |
437 cx_attr_nodiscard |
423 cx_attr_nodiscard cx_attr_nonnull |
438 cx_attr_nonnull |
424 CX_EXPORT cxmutstr cx_strcat_ma(const CxAllocator *alloc, |
439 cx_attr_export |
425 cxmutstr str, size_t count, ...); |
440 cxmutstr cx_strcat_ma( |
|
441 const CxAllocator *alloc, |
|
442 cxmutstr str, |
|
443 size_t count, |
|
444 ... |
|
445 ); |
|
446 |
426 |
447 /** |
427 /** |
448 * Concatenates strings and returns a new string. |
428 * Concatenates strings and returns a new string. |
449 * |
429 * |
450 * The resulting string will be allocated by the specified allocator. |
430 * The resulting string will be allocated by the specified allocator. |
461 * @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 |
462 * @param ... all other UCX strings |
442 * @param ... all other UCX strings |
463 * @return (@c cxmutstr) the concatenated string |
443 * @return (@c cxmutstr) the concatenated string |
464 */ |
444 */ |
465 #define cx_strcat_a(alloc, count, ...) \ |
445 #define cx_strcat_a(alloc, count, ...) \ |
466 cx_strcat_ma(alloc, cx_mutstrn(NULL, 0), count, __VA_ARGS__) |
446 cx_strcat_ma(alloc, cx_mutstrn(NULL, 0), count, __VA_ARGS__) |
467 |
447 |
468 /** |
448 /** |
469 * Concatenates strings and returns a new string. |
449 * Concatenates strings and returns a new string. |
470 * |
450 * |
471 * The resulting string will be allocated by the cxDefaultAllocator. |
451 * The resulting string will be allocated by the cxDefaultAllocator. |
481 * @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 |
482 * @param ... all other UCX strings |
462 * @param ... all other UCX strings |
483 * @return (@c cxmutstr) the concatenated string |
463 * @return (@c cxmutstr) the concatenated string |
484 */ |
464 */ |
485 #define cx_strcat(count, ...) \ |
465 #define cx_strcat(count, ...) \ |
486 cx_strcat_ma(cxDefaultAllocator, cx_mutstrn(NULL, 0), count, __VA_ARGS__) |
466 cx_strcat_ma(cxDefaultAllocator, cx_mutstrn(NULL, 0), count, __VA_ARGS__) |
487 |
467 |
488 /** |
468 /** |
489 * Concatenates strings. |
469 * Concatenates strings. |
490 * |
470 * |
491 * The resulting string will be allocated by the cxDefaultAllocator. |
471 * The resulting string will be allocated by the cxDefaultAllocator. |
505 * @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 |
506 * @param ... all other strings |
486 * @param ... all other strings |
507 * @return (@c cxmutstr) the concatenated string |
487 * @return (@c cxmutstr) the concatenated string |
508 */ |
488 */ |
509 #define cx_strcat_m(str, count, ...) \ |
489 #define cx_strcat_m(str, count, ...) \ |
510 cx_strcat_ma(cxDefaultAllocator, str, count, __VA_ARGS__) |
490 cx_strcat_ma(cxDefaultAllocator, str, count, __VA_ARGS__) |
511 |
491 |
512 /** |
492 /** |
513 * Returns a substring starting at the specified location. |
493 * Returns a substring starting at the specified location. |
514 * |
494 * |
515 * @attention the new string references the same memory area as the |
495 * @attention the new string references the same memory area as the |
739 * @param delim the delimiter |
677 * @param delim the delimiter |
740 * @param limit the maximum number of split items |
678 * @param limit the maximum number of split items |
741 * @param output a preallocated array of at least @p limit length |
679 * @param output a preallocated array of at least @p limit length |
742 * @return the actual number of split items |
680 * @return the actual number of split items |
743 */ |
681 */ |
744 cx_attr_nodiscard |
682 cx_attr_nodiscard cx_attr_nonnull cx_attr_access_w(4, 3) |
745 cx_attr_nonnull |
683 CX_EXPORT size_t cx_strsplit(cxstring string, cxstring delim, |
746 cx_attr_access_w(4, 3) |
684 size_t limit, cxstring *output); |
747 cx_attr_export |
|
748 size_t cx_strsplit( |
|
749 cxstring string, |
|
750 cxstring delim, |
|
751 size_t limit, |
|
752 cxstring *output |
|
753 ); |
|
754 |
685 |
755 /** |
686 /** |
756 * Splits a given string using a delimiter string. |
687 * Splits a given string using a delimiter string. |
757 * |
688 * |
758 * 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. |
794 * @param delim the delimiter |
718 * @param delim the delimiter |
795 * @param limit the maximum number of split items |
719 * @param limit the maximum number of split items |
796 * @param output a preallocated array of at least @p limit length |
720 * @param output a preallocated array of at least @p limit length |
797 * @return the actual number of split items |
721 * @return the actual number of split items |
798 */ |
722 */ |
799 cx_attr_nodiscard |
723 cx_attr_nodiscard cx_attr_nonnull cx_attr_access_w(4, 3) |
800 cx_attr_nonnull |
724 CX_EXPORT size_t cx_strsplit_m(cxmutstr string, cxstring delim, |
801 cx_attr_access_w(4, 3) |
725 size_t limit, cxmutstr *output); |
802 cx_attr_export |
|
803 size_t cx_strsplit_m( |
|
804 cxmutstr string, |
|
805 cxstring delim, |
|
806 size_t limit, |
|
807 cxmutstr *output |
|
808 ); |
|
809 |
726 |
810 /** |
727 /** |
811 * Splits a given string using a delimiter string. |
728 * Splits a given string using a delimiter string. |
812 * |
729 * |
813 * 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. |
824 * @param limit the maximum number of split items |
741 * @param limit the maximum number of split items |
825 * @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 |
826 * written to |
743 * written to |
827 * @return the actual number of split items |
744 * @return the actual number of split items |
828 */ |
745 */ |
829 cx_attr_nodiscard |
746 cx_attr_nodiscard cx_attr_nonnull cx_attr_access_w(5) |
830 cx_attr_nonnull |
747 CX_EXPORT size_t cx_strsplit_ma(const CxAllocator *allocator, |
831 cx_attr_access_w(5) |
748 cxmutstr string, cxstring delim, size_t limit, |
832 cx_attr_export |
749 cxmutstr **output); |
833 size_t cx_strsplit_ma( |
|
834 const CxAllocator *allocator, |
|
835 cxmutstr string, |
|
836 cxstring delim, |
|
837 size_t limit, |
|
838 cxmutstr **output |
|
839 ); |
|
840 |
750 |
841 /** |
751 /** |
842 * Compares two strings. |
752 * Compares two strings. |
843 * |
753 * |
844 * @param s1 the first string |
754 * @param s1 the first string |
845 * @param s2 the second string |
755 * @param s2 the second string |
846 * @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 |
847 * than @p s2, zero if both strings equal |
757 * than @p s2, zero if both strings equal |
848 */ |
758 */ |
849 cx_attr_nodiscard |
759 cx_attr_nodiscard |
850 cx_attr_export |
760 CX_EXPORT int cx_strcmp_(cxstring s1, cxstring s2); |
851 int cx_strcmp( |
761 |
852 cxstring s1, |
762 /** |
853 cxstring s2 |
763 * Compares two strings. |
854 ); |
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)) |
855 |
771 |
856 /** |
772 /** |
857 * Compares two strings ignoring case. |
773 * Compares two strings ignoring case. |
858 * |
774 * |
859 * @param s1 the first string |
775 * @param s1 the first string |
860 * @param s2 the second string |
776 * @param s2 the second string |
861 * @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 |
862 * than @p s2, zero if both strings equal ignoring case |
778 * than @p s2, zero if both strings equal ignoring case |
863 */ |
779 */ |
864 cx_attr_nodiscard |
780 cx_attr_nodiscard |
865 cx_attr_export |
781 CX_EXPORT int cx_strcasecmp_(cxstring s1, cxstring s2); |
866 int cx_strcasecmp( |
782 |
867 cxstring s1, |
783 /** |
868 cxstring s2 |
784 * Compares two strings ignoring case. |
869 ); |
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)) |
870 |
792 |
871 /** |
793 /** |
872 * Compares two strings. |
794 * Compares two strings. |
873 * |
795 * |
874 * 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. |
875 * |
800 * |
876 * @param s1 the first string |
801 * @param s1 the first string |
877 * @param s2 the second string |
802 * @param s2 the second string |
878 * @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 |
879 * than @p s2, zero if both strings equal |
804 * than @p s2, zero if both strings equal |
880 */ |
805 */ |
881 cx_attr_nodiscard |
806 cx_attr_nodiscard cx_attr_nonnull |
882 cx_attr_nonnull |
807 CX_EXPORT int cx_strcmp_p(const void *s1, const void *s2); |
883 cx_attr_export |
|
884 int cx_strcmp_p( |
|
885 const void *s1, |
|
886 const void *s2 |
|
887 ); |
|
888 |
808 |
889 /** |
809 /** |
890 * Compares two strings ignoring case. |
810 * Compares two strings ignoring case. |
891 * |
811 * |
892 * 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. |
977 * |
885 * |
978 * @param string the string that shall be trimmed |
886 * @param string the string that shall be trimmed |
979 * @return the trimmed string |
887 * @return the trimmed string |
980 */ |
888 */ |
981 cx_attr_nodiscard |
889 cx_attr_nodiscard |
982 cx_attr_export |
890 CX_EXPORT cxmutstr cx_strtrim_m(cxmutstr string); |
983 cxmutstr cx_strtrim_m(cxmutstr string); |
|
984 |
891 |
985 /** |
892 /** |
986 * Checks if a string has a specific prefix. |
893 * Checks if a string has a specific prefix. |
987 * |
894 * |
988 * @param string the string to check |
895 * @param string the string to check |
989 * @param prefix the prefix the string should have |
896 * @param prefix the prefix the string should have |
990 * @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, |
991 * @c false otherwise |
898 * @c false otherwise |
992 */ |
899 */ |
993 cx_attr_nodiscard |
900 cx_attr_nodiscard |
994 cx_attr_export |
901 CX_EXPORT bool cx_strprefix_(cxstring string, cxstring prefix); |
995 bool cx_strprefix( |
902 |
996 cxstring string, |
903 /** |
997 cxstring prefix |
904 * Checks if a string has a specific prefix. |
998 ); |
905 * |
|
906 * @param string the string to check |
|
907 * @param prefix the prefix the string should have |
|
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)) |
999 |
912 |
1000 /** |
913 /** |
1001 * Checks if a string has a specific suffix. |
914 * Checks if a string has a specific suffix. |
1002 * |
915 * |
1003 * @param string the string to check |
916 * @param string the string to check |
1004 * @param suffix the suffix the string should have |
917 * @param suffix the suffix the string should have |
1005 * @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, |
1006 * @c false otherwise |
919 * @c false otherwise |
1007 */ |
920 */ |
1008 cx_attr_nodiscard |
921 cx_attr_nodiscard |
1009 cx_attr_export |
922 CX_EXPORT bool cx_strsuffix_(cxstring string, cxstring suffix); |
1010 bool cx_strsuffix( |
923 |
1011 cxstring string, |
924 /** |
1012 cxstring suffix |
925 * Checks if a string has a specific suffix. |
1013 ); |
926 * |
|
927 * @param string the string to check |
|
928 * @param suffix the suffix the string should have |
|
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)) |
1014 |
933 |
1015 /** |
934 /** |
1016 * Checks if a string has a specific prefix, ignoring the case. |
935 * Checks if a string has a specific prefix, ignoring the case. |
1017 * |
936 * |
1018 * @param string the string to check |
937 * @param string the string to check |
1019 * @param prefix the prefix the string should have |
938 * @param prefix the prefix the string should have |
1020 * @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, |
1021 * @c false otherwise |
940 * @c false otherwise |
1022 */ |
941 */ |
1023 cx_attr_nodiscard |
942 cx_attr_nodiscard |
1024 cx_attr_export |
943 CX_EXPORT bool cx_strcaseprefix_(cxstring string, cxstring prefix); |
1025 bool cx_strcaseprefix( |
944 |
1026 cxstring string, |
945 /** |
1027 cxstring prefix |
946 * Checks if a string has a specific prefix, ignoring the case. |
1028 ); |
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)) |
1029 |
954 |
1030 /** |
955 /** |
1031 * Checks, if a string has a specific suffix, ignoring the case. |
956 * Checks, if a string has a specific suffix, ignoring the case. |
1032 * |
957 * |
1033 * @param string the string to check |
958 * @param string the string to check |
1034 * @param suffix the suffix the string should have |
959 * @param suffix the suffix the string should have |
1035 * @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, |
1036 * @c false otherwise |
961 * @c false otherwise |
1037 */ |
962 */ |
1038 cx_attr_nodiscard |
963 cx_attr_nodiscard |
1039 cx_attr_export |
964 CX_EXPORT bool cx_strcasesuffix_(cxstring string, cxstring suffix); |
1040 bool cx_strcasesuffix( |
965 |
1041 cxstring string, |
966 /** |
1042 cxstring suffix |
967 * Checks, if a string has a specific suffix, ignoring the case. |
1043 ); |
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)) |
1044 |
975 |
1045 /** |
976 /** |
1046 * Replaces a string with another string. |
977 * Replaces a string with another string. |
1047 * |
978 * |
1048 * The function replaces at most @p replmax occurrences. |
979 * The function replaces at most @p replmax occurrences. |
1058 * @param search the string to search for |
989 * @param search the string to search for |
1059 * @param replacement the replacement string |
990 * @param replacement the replacement string |
1060 * @param replmax maximum number of replacements |
991 * @param replmax maximum number of replacements |
1061 * @return the resulting string after applying the replacements |
992 * @return the resulting string after applying the replacements |
1062 */ |
993 */ |
1063 cx_attr_nodiscard |
994 cx_attr_nodiscard cx_attr_nonnull |
1064 cx_attr_nonnull |
995 CX_EXPORT cxmutstr cx_strreplacen_a(const CxAllocator *allocator, |
1065 cx_attr_export |
996 cxstring str, cxstring search, cxstring replacement, size_t replmax); |
1066 cxmutstr cx_strreplacen_a( |
|
1067 const CxAllocator *allocator, |
|
1068 cxstring str, |
|
1069 cxstring search, |
|
1070 cxstring replacement, |
|
1071 size_t replmax |
|
1072 ); |
|
1073 |
997 |
1074 /** |
998 /** |
1075 * Replaces a string with another string. |
999 * Replaces a string with another string. |
1076 * |
1000 * |
1077 * The function replaces at most @p replmax occurrences. |
1001 * The function replaces at most @p replmax occurrences. |
1087 * @param replacement (@c cxstring) the replacement string |
1011 * @param replacement (@c cxstring) the replacement string |
1088 * @param replmax (@c size_t) maximum number of replacements |
1012 * @param replmax (@c size_t) maximum number of replacements |
1089 * @return (@c cxmutstr) the resulting string after applying the replacements |
1013 * @return (@c cxmutstr) the resulting string after applying the replacements |
1090 */ |
1014 */ |
1091 #define cx_strreplacen(str, search, replacement, replmax) \ |
1015 #define cx_strreplacen(str, search, replacement, replmax) \ |
1092 cx_strreplacen_a(cxDefaultAllocator, str, search, replacement, replmax) |
1016 cx_strreplacen_a(cxDefaultAllocator, str, search, replacement, replmax) |
1093 |
1017 |
1094 /** |
1018 /** |
1095 * Replaces a string with another string. |
1019 * Replaces a string with another string. |
1096 * |
1020 * |
1097 * 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 |
1105 * @param search (@c cxstring) the string to search for |
1029 * @param search (@c cxstring) the string to search for |
1106 * @param replacement (@c cxstring) the replacement string |
1030 * @param replacement (@c cxstring) the replacement string |
1107 * @return (@c cxmutstr) the resulting string after applying the replacements |
1031 * @return (@c cxmutstr) the resulting string after applying the replacements |
1108 */ |
1032 */ |
1109 #define cx_strreplace_a(allocator, str, search, replacement) \ |
1033 #define cx_strreplace_a(allocator, str, search, replacement) \ |
1110 cx_strreplacen_a(allocator, str, search, replacement, SIZE_MAX) |
1034 cx_strreplacen_a(allocator, str, search, replacement, SIZE_MAX) |
1111 |
1035 |
1112 /** |
1036 /** |
1113 * Replaces a string with another string. |
1037 * Replaces a string with another string. |
1114 * |
1038 * |
1115 * 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 |
1122 * @param search (@c cxstring) the string to search for |
1046 * @param search (@c cxstring) the string to search for |
1123 * @param replacement (@c cxstring) the replacement string |
1047 * @param replacement (@c cxstring) the replacement string |
1124 * @return (@c cxmutstr) the resulting string after applying the replacements |
1048 * @return (@c cxmutstr) the resulting string after applying the replacements |
1125 */ |
1049 */ |
1126 #define cx_strreplace(str, search, replacement) \ |
1050 #define cx_strreplace(str, search, replacement) \ |
1127 cx_strreplacen_a(cxDefaultAllocator, str, search, replacement, SIZE_MAX) |
1051 cx_strreplacen_a(cxDefaultAllocator, str, search, replacement, SIZE_MAX) |
1128 |
1052 |
1129 /** |
1053 /** |
1130 * Creates a string tokenization context. |
1054 * Creates a string tokenization context. |
1131 * |
1055 * |
1132 * @param str the string to tokenize |
1056 * @param str the string to tokenize |
1133 * @param delim the delimiter (must not be empty) |
1057 * @param delim the delimiter (must not be empty) |
1134 * @param limit the maximum number of tokens that shall be returned |
1058 * @param limit the maximum number of tokens that shall be returned |
1135 * @return a new string tokenization context |
1059 * @return a new string tokenization context |
1136 */ |
1060 */ |
1137 cx_attr_nodiscard |
1061 cx_attr_nodiscard |
1138 cx_attr_export |
1062 CX_EXPORT CxStrtokCtx cx_strtok_(cxstring str, cxstring delim, size_t limit); |
1139 CxStrtokCtx cx_strtok_( |
|
1140 cxstring str, |
|
1141 cxstring delim, |
|
1142 size_t limit |
|
1143 ); |
|
1144 |
1063 |
1145 /** |
1064 /** |
1146 * Creates a string tokenization context. |
1065 * Creates a string tokenization context. |
1147 * |
1066 * |
1148 * @param str the string to tokenize |
1067 * @param str the string to tokenize |
1149 * @param delim the delimiter string (must not be empty) |
1068 * @param delim the delimiter string (must not be empty) |
1150 * @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 |
1151 * @return (@c CxStrtokCtx) a new string tokenization context |
1070 * @return (@c CxStrtokCtx) a new string tokenization context |
1152 */ |
1071 */ |
1153 #define cx_strtok(str, delim, limit) \ |
1072 #define cx_strtok(str, delim, limit) \ |
1154 cx_strtok_(cx_strcast(str), cx_strcast(delim), (limit)) |
1073 cx_strtok_(cx_strcast(str), cx_strcast(delim), (limit)) |
1155 |
1074 |
1156 /** |
1075 /** |
1157 * Returns the next token. |
1076 * Returns the next token. |
1158 * |
1077 * |
1159 * The token will point to the source string. |
1078 * The token will point to the source string. |
1184 * @param ctx the tokenization context |
1097 * @param ctx the tokenization context |
1185 * @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 |
1186 * @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 |
1187 * has been reached |
1100 * has been reached |
1188 */ |
1101 */ |
1189 cx_attr_nonnull |
1102 cx_attr_nonnull cx_attr_nodiscard cx_attr_access_w(2) |
1190 cx_attr_nodiscard |
1103 CX_EXPORT bool cx_strtok_next_m(CxStrtokCtx *ctx, cxmutstr *token); |
1191 cx_attr_access_w(2) |
|
1192 cx_attr_export |
|
1193 bool cx_strtok_next_m( |
|
1194 CxStrtokCtx *ctx, |
|
1195 cxmutstr *token |
|
1196 ); |
|
1197 |
1104 |
1198 /** |
1105 /** |
1199 * Defines an array of more delimiters for the specified tokenization context. |
1106 * Defines an array of more delimiters for the specified tokenization context. |
1200 * |
1107 * |
1201 * @param ctx the tokenization context |
1108 * @param ctx the tokenization context |
1202 * @param delim array of more delimiters |
1109 * @param delim array of more delimiters |
1203 * @param count number of elements in the array |
1110 * @param count number of elements in the array |
1204 */ |
1111 */ |
1205 cx_attr_nonnull |
1112 cx_attr_nonnull cx_attr_access_r(2, 3) |
1206 cx_attr_access_r(2, 3) |
1113 CX_EXPORT void cx_strtok_delim(CxStrtokCtx *ctx, const cxstring *delim, size_t count); |
1207 cx_attr_export |
|
1208 void cx_strtok_delim( |
|
1209 CxStrtokCtx *ctx, |
|
1210 const cxstring *delim, |
|
1211 size_t count |
|
1212 ); |
|
1213 |
1114 |
1214 /* ------------------------------------------------------------------------- * |
1115 /* ------------------------------------------------------------------------- * |
1215 * string to number conversion functions * |
1116 * string to number conversion functions * |
1216 * ------------------------------------------------------------------------- */ |
1117 * ------------------------------------------------------------------------- */ |
1217 |
1118 |
1227 * @param base 2, 8, 10, or 16 |
1128 * @param base 2, 8, 10, or 16 |
1228 * @param groupsep each character in this string is treated as a group separator and ignored during conversion |
1129 * @param groupsep each character in this string is treated as a group separator and ignored during conversion |
1229 * @retval zero success |
1130 * @retval zero success |
1230 * @retval non-zero conversion was not possible |
1131 * @retval non-zero conversion was not possible |
1231 */ |
1132 */ |
1232 cx_attr_access_w(2) cx_attr_nonnull_arg(2) cx_attr_export |
1133 cx_attr_access_w(2) cx_attr_nonnull_arg(2) |
1233 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); |
1234 |
1135 |
1235 /** |
1136 /** |
1236 * Converts a string to a number. |
1137 * Converts a string to a number. |
1237 * |
1138 * |
1238 * The function returns non-zero when conversion is not possible. |
1139 * The function returns non-zero when conversion is not possible. |
1244 * @param base 2, 8, 10, or 16 |
1145 * @param base 2, 8, 10, or 16 |
1245 * @param groupsep each character in this string is treated as a group separator and ignored during conversion |
1146 * @param groupsep each character in this string is treated as a group separator and ignored during conversion |
1246 * @retval zero success |
1147 * @retval zero success |
1247 * @retval non-zero conversion was not possible |
1148 * @retval non-zero conversion was not possible |
1248 */ |
1149 */ |
1249 cx_attr_access_w(2) cx_attr_nonnull_arg(2) cx_attr_export |
1150 cx_attr_access_w(2) cx_attr_nonnull_arg(2) |
1250 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); |
1251 |
1152 |
1252 /** |
1153 /** |
1253 * Converts a string to a number. |
1154 * Converts a string to a number. |
1254 * |
1155 * |
1255 * The function returns non-zero when conversion is not possible. |
1156 * The function returns non-zero when conversion is not possible. |
1261 * @param base 2, 8, 10, or 16 |
1162 * @param base 2, 8, 10, or 16 |
1262 * @param groupsep each character in this string is treated as a group separator and ignored during conversion |
1163 * @param groupsep each character in this string is treated as a group separator and ignored during conversion |
1263 * @retval zero success |
1164 * @retval zero success |
1264 * @retval non-zero conversion was not possible |
1165 * @retval non-zero conversion was not possible |
1265 */ |
1166 */ |
1266 cx_attr_access_w(2) cx_attr_nonnull_arg(2) cx_attr_export |
1167 cx_attr_access_w(2) cx_attr_nonnull_arg(2) |
1267 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); |
1268 |
1169 |
1269 /** |
1170 /** |
1270 * Converts a string to a number. |
1171 * Converts a string to a number. |
1271 * |
1172 * |
1272 * The function returns non-zero when conversion is not possible. |
1173 * The function returns non-zero when conversion is not possible. |
1278 * @param base 2, 8, 10, or 16 |
1179 * @param base 2, 8, 10, or 16 |
1279 * @param groupsep each character in this string is treated as a group separator and ignored during conversion |
1180 * @param groupsep each character in this string is treated as a group separator and ignored during conversion |
1280 * @retval zero success |
1181 * @retval zero success |
1281 * @retval non-zero conversion was not possible |
1182 * @retval non-zero conversion was not possible |
1282 */ |
1183 */ |
1283 cx_attr_access_w(2) cx_attr_nonnull_arg(2) cx_attr_export |
1184 cx_attr_access_w(2) cx_attr_nonnull_arg(2) |
1284 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); |
1285 |
1186 |
1286 /** |
1187 /** |
1287 * Converts a string to a number. |
1188 * Converts a string to a number. |
1288 * |
1189 * |
1289 * The function returns non-zero when conversion is not possible. |
1190 * The function returns non-zero when conversion is not possible. |
1295 * @param base 2, 8, 10, or 16 |
1196 * @param base 2, 8, 10, or 16 |
1296 * @param groupsep each character in this string is treated as a group separator and ignored during conversion |
1197 * @param groupsep each character in this string is treated as a group separator and ignored during conversion |
1297 * @retval zero success |
1198 * @retval zero success |
1298 * @retval non-zero conversion was not possible |
1199 * @retval non-zero conversion was not possible |
1299 */ |
1200 */ |
1300 cx_attr_access_w(2) cx_attr_nonnull_arg(2) cx_attr_export |
1201 cx_attr_access_w(2) cx_attr_nonnull_arg(2) |
1301 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); |
1302 |
1203 |
1303 /** |
1204 /** |
1304 * Converts a string to a number. |
1205 * Converts a string to a number. |
1305 * |
1206 * |
1306 * The function returns non-zero when conversion is not possible. |
1207 * The function returns non-zero when conversion is not possible. |
1312 * @param base 2, 8, 10, or 16 |
1213 * @param base 2, 8, 10, or 16 |
1313 * @param groupsep each character in this string is treated as a group separator and ignored during conversion |
1214 * @param groupsep each character in this string is treated as a group separator and ignored during conversion |
1314 * @retval zero success |
1215 * @retval zero success |
1315 * @retval non-zero conversion was not possible |
1216 * @retval non-zero conversion was not possible |
1316 */ |
1217 */ |
1317 cx_attr_access_w(2) cx_attr_nonnull_arg(2) cx_attr_export |
1218 cx_attr_access_w(2) cx_attr_nonnull_arg(2) |
1318 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); |
1319 |
1220 |
1320 /** |
1221 /** |
1321 * Converts a string to a number. |
1222 * Converts a string to a number. |
1322 * |
1223 * |
1323 * The function returns non-zero when conversion is not possible. |
1224 * The function returns non-zero when conversion is not possible. |
1329 * @param base 2, 8, 10, or 16 |
1230 * @param base 2, 8, 10, or 16 |
1330 * @param groupsep each character in this string is treated as a group separator and ignored during conversion |
1231 * @param groupsep each character in this string is treated as a group separator and ignored during conversion |
1331 * @retval zero success |
1232 * @retval zero success |
1332 * @retval non-zero conversion was not possible |
1233 * @retval non-zero conversion was not possible |
1333 */ |
1234 */ |
1334 cx_attr_access_w(2) cx_attr_nonnull_arg(2) cx_attr_export |
1235 cx_attr_access_w(2) cx_attr_nonnull_arg(2) |
1335 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); |
1336 |
1237 |
1337 /** |
1238 /** |
1338 * Converts a string to a number. |
1239 * Converts a string to a number. |
1339 * |
1240 * |
1340 * The function returns non-zero when conversion is not possible. |
1241 * The function returns non-zero when conversion is not possible. |
1346 * @param base 2, 8, 10, or 16 |
1247 * @param base 2, 8, 10, or 16 |
1347 * @param groupsep each character in this string is treated as a group separator and ignored during conversion |
1248 * @param groupsep each character in this string is treated as a group separator and ignored during conversion |
1348 * @retval zero success |
1249 * @retval zero success |
1349 * @retval non-zero conversion was not possible |
1250 * @retval non-zero conversion was not possible |
1350 */ |
1251 */ |
1351 cx_attr_access_w(2) cx_attr_nonnull_arg(2) cx_attr_export |
1252 cx_attr_access_w(2) cx_attr_nonnull_arg(2) |
1352 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); |
1353 |
1254 |
1354 /** |
1255 /** |
1355 * Converts a string to a number. |
1256 * Converts a string to a number. |
1356 * |
1257 * |
1357 * The function returns non-zero when conversion is not possible. |
1258 * The function returns non-zero when conversion is not possible. |
1363 * @param base 2, 8, 10, or 16 |
1264 * @param base 2, 8, 10, or 16 |
1364 * @param groupsep each character in this string is treated as a group separator and ignored during conversion |
1265 * @param groupsep each character in this string is treated as a group separator and ignored during conversion |
1365 * @retval zero success |
1266 * @retval zero success |
1366 * @retval non-zero conversion was not possible |
1267 * @retval non-zero conversion was not possible |
1367 */ |
1268 */ |
1368 cx_attr_access_w(2) cx_attr_nonnull_arg(2) cx_attr_export |
1269 cx_attr_access_w(2) cx_attr_nonnull_arg(2) |
1369 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); |
1370 |
1271 |
1371 /** |
1272 /** |
1372 * Converts a string to a number. |
1273 * Converts a string to a number. |
1373 * |
1274 * |
1374 * The function returns non-zero when conversion is not possible. |
1275 * The function returns non-zero when conversion is not possible. |
1380 * @param base 2, 8, 10, or 16 |
1281 * @param base 2, 8, 10, or 16 |
1381 * @param groupsep each character in this string is treated as a group separator and ignored during conversion |
1282 * @param groupsep each character in this string is treated as a group separator and ignored during conversion |
1382 * @retval zero success |
1283 * @retval zero success |
1383 * @retval non-zero conversion was not possible |
1284 * @retval non-zero conversion was not possible |
1384 */ |
1285 */ |
1385 cx_attr_access_w(2) cx_attr_nonnull_arg(2) cx_attr_export |
1286 cx_attr_access_w(2) cx_attr_nonnull_arg(2) |
1386 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); |
1387 |
1288 |
1388 /** |
1289 /** |
1389 * Converts a string to a number. |
1290 * Converts a string to a number. |
1390 * |
1291 * |
1391 * The function returns non-zero when conversion is not possible. |
1292 * The function returns non-zero when conversion is not possible. |
1397 * @param base 2, 8, 10, or 16 |
1298 * @param base 2, 8, 10, or 16 |
1398 * @param groupsep each character in this string is treated as a group separator and ignored during conversion |
1299 * @param groupsep each character in this string is treated as a group separator and ignored during conversion |
1399 * @retval zero success |
1300 * @retval zero success |
1400 * @retval non-zero conversion was not possible |
1301 * @retval non-zero conversion was not possible |
1401 */ |
1302 */ |
1402 cx_attr_access_w(2) cx_attr_nonnull_arg(2) cx_attr_export |
1303 cx_attr_access_w(2) cx_attr_nonnull_arg(2) |
1403 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); |
1404 |
1305 |
1405 /** |
1306 /** |
1406 * Converts a string to a number. |
1307 * Converts a string to a number. |
1407 * |
1308 * |
1408 * The function returns non-zero when conversion is not possible. |
1309 * The function returns non-zero when conversion is not possible. |
1414 * @param base 2, 8, 10, or 16 |
1315 * @param base 2, 8, 10, or 16 |
1415 * @param groupsep each character in this string is treated as a group separator and ignored during conversion |
1316 * @param groupsep each character in this string is treated as a group separator and ignored during conversion |
1416 * @retval zero success |
1317 * @retval zero success |
1417 * @retval non-zero conversion was not possible |
1318 * @retval non-zero conversion was not possible |
1418 */ |
1319 */ |
1419 cx_attr_access_w(2) cx_attr_nonnull_arg(2) cx_attr_export |
1320 cx_attr_access_w(2) cx_attr_nonnull_arg(2) |
1420 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); |
1421 |
1322 |
1422 /** |
1323 /** |
1423 * Converts a string to a number. |
1324 * Converts a string to a number. |
1424 * |
1325 * |
1425 * The function returns non-zero when conversion is not possible. |
1326 * The function returns non-zero when conversion is not possible. |
1431 * @param base 2, 8, 10, or 16 |
1332 * @param base 2, 8, 10, or 16 |
1432 * @param groupsep each character in this string is treated as a group separator and ignored during conversion |
1333 * @param groupsep each character in this string is treated as a group separator and ignored during conversion |
1433 * @retval zero success |
1334 * @retval zero success |
1434 * @retval non-zero conversion was not possible |
1335 * @retval non-zero conversion was not possible |
1435 */ |
1336 */ |
1436 cx_attr_access_w(2) cx_attr_nonnull_arg(2) cx_attr_export |
1337 cx_attr_access_w(2) cx_attr_nonnull_arg(2) |
1437 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); |
1438 |
1339 |
1439 /** |
1340 /** |
1440 * Converts a string to a number. |
1341 * Converts a string to a number. |
1441 * |
1342 * |
1442 * The function returns non-zero when conversion is not possible. |
1343 * The function returns non-zero when conversion is not possible. |
1448 * @param base 2, 8, 10, or 16 |
1349 * @param base 2, 8, 10, or 16 |
1449 * @param groupsep each character in this string is treated as a group separator and ignored during conversion |
1350 * @param groupsep each character in this string is treated as a group separator and ignored during conversion |
1450 * @retval zero success |
1351 * @retval zero success |
1451 * @retval non-zero conversion was not possible |
1352 * @retval non-zero conversion was not possible |
1452 */ |
1353 */ |
1453 cx_attr_access_w(2) cx_attr_nonnull_arg(2) cx_attr_export |
1354 cx_attr_access_w(2) cx_attr_nonnull_arg(2) |
1454 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); |
1455 |
1356 |
1456 /** |
1357 /** |
1457 * Converts a string to a number. |
1358 * Converts a string to a number. |
1458 * |
1359 * |
1459 * The function returns non-zero when conversion is not possible. |
1360 * The function returns non-zero when conversion is not possible. |
1465 * @param base 2, 8, 10, or 16 |
1366 * @param base 2, 8, 10, or 16 |
1466 * @param groupsep each character in this string is treated as a group separator and ignored during conversion |
1367 * @param groupsep each character in this string is treated as a group separator and ignored during conversion |
1467 * @retval zero success |
1368 * @retval zero success |
1468 * @retval non-zero conversion was not possible |
1369 * @retval non-zero conversion was not possible |
1469 */ |
1370 */ |
1470 cx_attr_access_w(2) cx_attr_nonnull_arg(2) cx_attr_export |
1371 cx_attr_access_w(2) cx_attr_nonnull_arg(2) |
1471 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); |
1472 |
1373 |
1473 /** |
1374 /** |
1474 * Converts a string to a number. |
1375 * Converts a string to a number. |
1475 * |
1376 * |
1476 * The function returns non-zero when conversion is not possible. |
1377 * The function returns non-zero when conversion is not possible. |
1482 * @param base 2, 8, 10, or 16 |
1383 * @param base 2, 8, 10, or 16 |
1483 * @param groupsep each character in this string is treated as a group separator and ignored during conversion |
1384 * @param groupsep each character in this string is treated as a group separator and ignored during conversion |
1484 * @retval zero success |
1385 * @retval zero success |
1485 * @retval non-zero conversion was not possible |
1386 * @retval non-zero conversion was not possible |
1486 */ |
1387 */ |
1487 cx_attr_access_w(2) cx_attr_nonnull_arg(2) cx_attr_export |
1388 cx_attr_access_w(2) cx_attr_nonnull_arg(2) |
1488 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); |
1489 |
1390 |
1490 /** |
1391 /** |
1491 * Converts a string to a number. |
1392 * Converts a string to a number. |
1492 * |
1393 * |
1493 * The function returns non-zero when conversion is not possible. |
1394 * The function returns non-zero when conversion is not possible. |
1499 * @param base 2, 8, 10, or 16 |
1400 * @param base 2, 8, 10, or 16 |
1500 * @param groupsep each character in this string is treated as a group separator and ignored during conversion |
1401 * @param groupsep each character in this string is treated as a group separator and ignored during conversion |
1501 * @retval zero success |
1402 * @retval zero success |
1502 * @retval non-zero conversion was not possible |
1403 * @retval non-zero conversion was not possible |
1503 */ |
1404 */ |
1504 cx_attr_access_w(2) cx_attr_nonnull_arg(2) cx_attr_export |
1405 cx_attr_access_w(2) cx_attr_nonnull_arg(2) |
1505 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); |
1506 |
1407 |
1507 /** |
1408 /** |
1508 * Converts a string to a single precision floating-point number. |
1409 * Converts a string to a single precision floating-point number. |
1509 * |
1410 * |
1510 * The function returns non-zero when conversion is not possible. |
1411 * The function returns non-zero when conversion is not possible. |
1516 * @param decsep the decimal separator |
1417 * @param decsep the decimal separator |
1517 * @param groupsep each character in this string is treated as a group separator and ignored during conversion |
1418 * @param groupsep each character in this string is treated as a group separator and ignored during conversion |
1518 * @retval zero success |
1419 * @retval zero success |
1519 * @retval non-zero conversion was not possible |
1420 * @retval non-zero conversion was not possible |
1520 */ |
1421 */ |
1521 cx_attr_access_w(2) cx_attr_nonnull_arg(2) cx_attr_export |
1422 cx_attr_access_w(2) cx_attr_nonnull_arg(2) |
1522 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); |
1523 |
1424 |
1524 /** |
1425 /** |
1525 * Converts a string to a double precision floating-point number. |
1426 * Converts a string to a double precision floating-point number. |
1526 * |
1427 * |
1527 * The function returns non-zero when conversion is not possible. |
1428 * The function returns non-zero when conversion is not possible. |
1533 * @param decsep the decimal separator |
1434 * @param decsep the decimal separator |
1534 * @param groupsep each character in this string is treated as a group separator and ignored during conversion |
1435 * @param groupsep each character in this string is treated as a group separator and ignored during conversion |
1535 * @retval zero success |
1436 * @retval zero success |
1536 * @retval non-zero conversion was not possible |
1437 * @retval non-zero conversion was not possible |
1537 */ |
1438 */ |
1538 cx_attr_access_w(2) cx_attr_nonnull_arg(2) cx_attr_export |
1439 cx_attr_access_w(2) cx_attr_nonnull_arg(2) |
1539 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); |
1540 |
1441 |
1541 /** |
1442 /** |
1542 * Converts a string to a number. |
1443 * Converts a string to a number. |
1543 * |
1444 * |
1544 * The function returns non-zero when conversion is not possible. |
1445 * The function returns non-zero when conversion is not possible. |