src/cx/string.h

changeset 1045
468c868cc8a8
parent 1044
776001e4cc96
child 1046
fe2c842fce4b
--- a/src/cx/string.h	Sun Dec 22 21:33:10 2024 +0100
+++ b/src/cx/string.h	Sun Dec 22 21:42:16 2024 +0100
@@ -1119,74 +1119,90 @@
  *                string to number conversion functions                      *
  * ------------------------------------------------------------------------- */
 
-
 /**
  * \copydoc cx_strtouz_lc()
  */
+cx_attr_access_w(2) cx_attr_nonnull_arg(2)
 int cx_strtos_lc(cxstring str, short *output, int base, const char *groupsep);
 /**
  * \copydoc cx_strtouz_lc()
  */
+cx_attr_access_w(2) cx_attr_nonnull_arg(2)
 int cx_strtoi_lc(cxstring str, int *output, int base, const char *groupsep);
 /**
  * \copydoc cx_strtouz_lc()
  */
+cx_attr_access_w(2) cx_attr_nonnull_arg(2)
 int cx_strtol_lc(cxstring str, long *output, int base, const char *groupsep);
 /**
  * \copydoc cx_strtouz_lc()
  */
+cx_attr_access_w(2) cx_attr_nonnull_arg(2)
 int cx_strtoll_lc(cxstring str, long int *output, int base, const char *groupsep);
 /**
  * \copydoc cx_strtouz_lc()
  */
+cx_attr_access_w(2) cx_attr_nonnull_arg(2)
 int cx_strtoi8_lc(cxstring str, int8_t *output, int base, const char *groupsep);
 /**
  * \copydoc cx_strtouz_lc()
  */
+cx_attr_access_w(2) cx_attr_nonnull_arg(2)
 int cx_strtoi16_lc(cxstring str, int16_t *output, int base, const char *groupsep);
 /**
  * \copydoc cx_strtouz_lc()
  */
+cx_attr_access_w(2) cx_attr_nonnull_arg(2)
 int cx_strtoi32_lc(cxstring str, int32_t *output, int base, const char *groupsep);
 /**
  * \copydoc cx_strtouz_lc()
  */
+cx_attr_access_w(2) cx_attr_nonnull_arg(2)
 int cx_strtoi64_lc(cxstring str, int64_t *output, int base, const char *groupsep);
 /**
  * \copydoc cx_strtouz_lc()
  */
+cx_attr_access_w(2) cx_attr_nonnull_arg(2)
 int cx_strtoz_lc(cxstring str, ssize_t *output, int base, const char *groupsep);
 /**
  * \copydoc cx_strtouz_lc()
  */
+cx_attr_access_w(2) cx_attr_nonnull_arg(2)
 int cx_strtous_lc(cxstring str, unsigned short *output, int base, const char *groupsep);
 /**
  * \copydoc cx_strtouz_lc()
  */
+cx_attr_access_w(2) cx_attr_nonnull_arg(2)
 int cx_strtou_lc(cxstring str, unsigned int *output, int base, const char *groupsep);
 /**
  * \copydoc cx_strtouz_lc()
  */
+cx_attr_access_w(2) cx_attr_nonnull_arg(2)
 int cx_strtoul_lc(cxstring str, unsigned long *output, int base, const char *groupsep);
 /**
  * \copydoc cx_strtouz_lc()
  */
+cx_attr_access_w(2) cx_attr_nonnull_arg(2)
 int cx_strtoull_lc(cxstring str, unsigned long int *output, int base, const char *groupsep);
 /**
  * \copydoc cx_strtouz_lc()
  */
+cx_attr_access_w(2) cx_attr_nonnull_arg(2)
 int cx_strtou8_lc(cxstring str, uint8_t *output, int base, const char *groupsep);
 /**
  * \copydoc cx_strtouz_lc()
  */
+cx_attr_access_w(2) cx_attr_nonnull_arg(2)
 int cx_strtou16_lc(cxstring str, uint16_t *output, int base, const char *groupsep);
 /**
  * \copydoc cx_strtouz_lc()
  */
+cx_attr_access_w(2) cx_attr_nonnull_arg(2)
 int cx_strtou32_lc(cxstring str, uint32_t *output, int base, const char *groupsep);
 /**
  * \copydoc cx_strtouz_lc()
  */
+cx_attr_access_w(2) cx_attr_nonnull_arg(2)
 int cx_strtou64_lc(cxstring str, uint64_t *output, int base, const char *groupsep);
 
 /**
@@ -1202,9 +1218,51 @@
  * @param groupsep each character in this string is treated as group separator and ignored during conversion
  * @return zero on success, non-zero if conversion was not possible
  */
+cx_attr_access_w(2) cx_attr_nonnull_arg(2)
 int cx_strtouz_lc(cxstring str, size_t *output, int base, const char *groupsep);
 
 /**
+ * Converts a string to a single precision floating point number.
+ *
+ * The function returns non-zero when conversion is not possible.
+ * In that case the function sets errno to EINVAL when the reason is an invalid character.
+ * It sets errno to ERANGE when the necessary representation would exceed the limits defined in libc's float.h.
+ *
+ * The decimal separator is assumed to be a dot character.
+ * The comma character is treated as group separator and ignored during parsing.
+ * If you want to choose a different format, use cx_strtof_lc().
+ *
+ * @param str the string to convert
+ * @param output a pointer to the float variable where the result shall be stored
+ * @param decsep the decimal separator
+ * @param groupsep each character in this string is treated as group separator and ignored during conversion
+ * @return zero on success, non-zero if conversion was not possible
+ */
+cx_attr_access_w(2) cx_attr_nonnull_arg(2)
+int cx_strtof_lc(cxstring str, float *output, char decsep, const char *groupsep);
+
+/**
+ * Converts a string to a double precision floating point number.
+ *
+ * The function returns non-zero when conversion is not possible.
+ * In that case the function sets errno to EINVAL when the reason is an invalid character.
+ * It sets errno to ERANGE when the necessary representation would exceed the limits defined in libc's float.h.
+ *
+ * The decimal separator is assumed to be a dot character.
+ * The comma character is treated as group separator and ignored during parsing.
+ * If you want to choose a different format, use cx_strtof_lc().
+ *
+ * @param str the string to convert
+ * @param output a pointer to the float variable where the result shall be stored
+ * @param decsep the decimal separator
+ * @param groupsep each character in this string is treated as group separator and ignored during conversion
+ * @return zero on success, non-zero if conversion was not possible
+ */
+cx_attr_access_w(2) cx_attr_nonnull_arg(2)
+int cx_strtod_lc(cxstring str, double *output, char decsep, const char *groupsep);
+
+#ifndef CX_STR_IMPLEMENTATION
+/**
  * \copydoc cx_strtouz_lc()
  */
 #define cx_strtos_lc(str, output, base, groupsep) cx_strtos_lc(cx_strcast(str), output, base, groupsep)
@@ -1287,7 +1345,6 @@
  */
 #define cx_strtouz_lc(str, output, base, groupsep) cx_strtouz_lc(cx_strcast(str), output, base, groupsep)
 
-
 /**
  * \copydoc cx_strtouz()
  */
@@ -1390,43 +1447,6 @@
  * @param groupsep each character in this string is treated as group separator and ignored during conversion
  * @return zero on success, non-zero if conversion was not possible
  */
-int cx_strtof_lc(cxstring str, float *output, char decsep, const char *groupsep);
-/**
- * Converts a string to a double precision floating point number.
- *
- * The function returns non-zero when conversion is not possible.
- * In that case the function sets errno to EINVAL when the reason is an invalid character.
- * It sets errno to ERANGE when the necessary representation would exceed the limits defined in libc's float.h.
- *
- * The decimal separator is assumed to be a dot character.
- * The comma character is treated as group separator and ignored during parsing.
- * If you want to choose a different format, use cx_strtof_lc().
- *
- * @param str the string to convert
- * @param output a pointer to the float variable where the result shall be stored
- * @param decsep the decimal separator
- * @param groupsep each character in this string is treated as group separator and ignored during conversion
- * @return zero on success, non-zero if conversion was not possible
- */
-int cx_strtod_lc(cxstring str, double *output, char decsep, const char *groupsep);
-
-/**
- * Converts a string to a single precision floating point number.
- *
- * The function returns non-zero when conversion is not possible.
- * In that case the function sets errno to EINVAL when the reason is an invalid character.
- * It sets errno to ERANGE when the necessary representation would exceed the limits defined in libc's float.h.
- *
- * The decimal separator is assumed to be a dot character.
- * The comma character is treated as group separator and ignored during parsing.
- * If you want to choose a different format, use cx_strtof_lc().
- *
- * @param str the string to convert
- * @param output a pointer to the float variable where the result shall be stored
- * @param decsep the decimal separator
- * @param groupsep each character in this string is treated as group separator and ignored during conversion
- * @return zero on success, non-zero if conversion was not possible
- */
 #define cx_strtof_lc(str, output, decsep, groupsep) cx_strtof_lc(cx_strcast(str), output, decsep, groupsep)
 /**
  * Converts a string to a double precision floating point number.
@@ -1480,6 +1500,8 @@
  */
 #define cx_strtod(str, output) cx_strtod_lc(str, output, '.', ",")
 
+#endif
+
 #ifdef __cplusplus
 } // extern "C"
 #endif

mercurial