parse: support 64 bits parsing
[aversive.git] / modules / ihm / parse / parse_num.h
1 #ifndef _PARSE_NUM_H_
2 #define _PARSE_NUM_H_
3
4 #include "parse.h"
5
6 enum numtype {
7         UINT8 = 0,
8         UINT16,
9         UINT32,
10         UINT64,
11         INT8,
12         INT16,
13         INT32,
14         INT64,
15 #ifndef CONFIG_MODULE_PARSE_NO_FLOAT
16         FLOAT,
17 #endif
18 };
19
20 struct token_num_data {
21         enum numtype type;
22 };
23
24 struct token_num {
25         struct token_hdr hdr;
26         struct token_num_data num_data;
27 };
28 typedef struct token_num parse_token_num_t;
29
30 extern struct token_ops token_num_ops;
31
32 int8_t parse_num(PGM_P tk, const char * srcbuf, void * res);
33 int8_t get_help_num(PGM_P tk, char * dstbuf, uint8_t size);
34
35 #define TOKEN_NUM_INITIALIZER(structure, field, numtype)   \
36 {                                                          \
37         .hdr = {                                           \
38                 .ops = &token_num_ops,                     \
39                 .offset = offsetof(structure, field),      \
40         },                                                 \
41         .num_data = {                                      \
42                 .type = numtype,                           \
43         },                                                 \
44 }
45
46 #endif /* _PARSE_NUM_H_ */