Move string-parsing code to where it can be reused
[alexxy/gromacs.git] / src / gromacs / utility / cstringutil.h
index eaa8bd97df56e30c0bbfddd55f89bb9b6b18588a..6d8f94b4e7472dc27b5d5703360aa278437f75b0 100644 (file)
@@ -205,6 +205,21 @@ gmx_int64_t str_to_int64_t(const char *str, char **endptr);
 #define snprintf _snprintf
 #endif
 
+/*! \brief Construct an array of digits found in the input string
+ *
+ * \param[in]  digitstring  String that must contain only digits
+ * \param[out] ndigits      Size of return array with the values of the digits
+ * \param[out] digitlist    Array of digits found in
+ *                          digitstring. Allocated by this function
+ *                          with size *ndigits. Calling code is
+ *                          responsible for deallocation.
+ *
+ * If digitstring is NULL, then ndigits is set to zero and digitlist
+ * to NULL. If digitstring contains a non-digit character, a fatal
+ * error results.
+ */
+void parse_digits_from_plain_string(const char *digitstring, int *ndigits, int **digitlist);
+
 #ifdef __cplusplus
 }
 #endif