Add bc to CI common prerequisities (required to run examples)
[qpms.git] / qpms / parsing.h
blob3f60daaee38cab0ef35766ce994ccb668a235ee0
1 /*! \file parsing.h
2 * \brief Some custom string conversions.
3 */
4 #ifndef QPMS_PARSING_H
5 #define QPMS_PARSING_H
7 #include <stddef.h>
9 /** Parse a given number of doubles from a string.
11 * The doubles can be separated by whitespaces, comma or semicolon.
13 * \return If the string included up to n doubles, number of parsed doubles.
14 * If more, n+1.
16 size_t qpms_parse_ndoubles(
17 double *target,
18 size_t n,
19 const char *orig
22 /** Parse doubles from a string.
24 * The doubles can be separated by whitespaces, comma or semicolon.
25 * The parsed numbers are saved into an array specified by *target
26 * that has been preallocated with malloc() to contain at least start_index
27 * members. If start_index is nonzero, the newly parsed numbers are
28 * saved to the positions starting from start_index.
30 * If *target is NULL, the function allocates the necessary space.
32 * \return Number of newly parsed doubles + start_index.
34 size_t qpms_parse_doubles(
35 double **target,
36 size_t start_index,
37 const char *orig
40 /** Parse doubles from a file.
42 * The doubles can be separated by whitespaces, comma or semicolon.
43 * The parsed numbers are saved into an array specified by *target
44 * that has been preallocated with malloc() to contain at least start_index
45 * members. If start_index is nonzero, the newly parsed numbers are
46 * saved to the positions starting from start_index.
48 * If *target is NULL, the function allocates the necessary space.
50 * If filepath is NULL, "" or "-", read from stdin.
52 * \return Number of newly parsed doubles + start_index.
54 size_t qpms_parse_doubles_fromfile(
55 double **target,
56 size_t start_index, //< Starting index for writing the parsed values.
57 const char *filepath //< File to read from, or NULL, "", "-" to read from stdin.
60 #endif // QPMS_PARSING_H