1#pragma once
2
3#include <pw.h>
4
5#ifdef __cplusplus
6extern "C" {
7#endif
8
9[[nodiscard]] bool _pw_parse_unsigned(PwValuePtr str, unsigned start_pos,
10 unsigned* end_pos, unsigned radix, PwValuePtr result);
11/*
12 * Parse `str` from `start_pos` as unsigned integer value.
13 *
14 * Return value and if `end_pos` is not null, write where conversion has stopped.
15 */
16
17[[nodiscard]] bool _pw_parse_number(PwValuePtr str, unsigned start_pos,
18 int sign, unsigned* end_pos, char32_t* allowed_terminators,
19 PwValuePtr result);
20/*
21 * `start_pos` points to the sign or first digit;
22 * `end_pos` (optional) receives position where conversion is stopped, regardless of result;
23 * `allowed_terminators` (optional) contains characters at which conversion may stop without returning error.
24 *
25 * Normally conversion stops at space character or at end of line. If wrong character is encountered,
26 * and it is not among allowed terminators, this function returns error.
27 *
28 * Return Signed if parsed number fits into its range.
29 * Return Unsigned if parsed number is beyond positive range of Signed value.
30 * Return Float if string contains float number.
31 * Return status on error.
32 */
33
34[[nodiscard]] bool pw_parse_number(PwValuePtr str, PwValuePtr result);
35/*
36 * Convert string to number.
37 * Simplified wrapper for _pw_parse_number.
38 */
39
40[[nodiscard]] bool _pw_parse_datetime(PwValuePtr str, unsigned start_pos, unsigned* end_pos,
41 char32_t* allowed_terminators, PwValuePtr result);
42/*
43 * Parse `str` as date/time in mutual formats of ISO-8601 and RFC 3339
44 * (see https://ijmacd.github.io/rfc3339-iso8601/).
45 *
46 * In addition, T or space separator between date and time and dashes in the date part are optional.
47 */
48
49[[nodiscard]] bool pw_parse_datetime(PwValuePtr str, PwValuePtr result);
50/*
51 * Convert string to date/time.
52 * Simplified wrapper for _pw_parse_datetime.
53 */
54
55[[nodiscard]] bool _pw_parse_timestamp(PwValuePtr str, unsigned start_pos, unsigned* end_pos,
56 char32_t* allowed_terminators, PwValuePtr result);
57/*
58 * Parse `str` as timestamp in the form seconds\[.frac\], up to nanosecond resolution.
59 */
60
61[[nodiscard]] bool pw_parse_timestamp(PwValuePtr str, PwValuePtr result);
62/*
63 * Convert string to timestamp.
64 * Simplified wrapper for _pw_parse_timestamp.
65 */
66
67#ifdef __cplusplus
68}
69#endif