fd13ee4a7c9b209a5d21e65ab6e66f8975db6ae3
[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         INT8,
11         INT16,
12         INT32,
13 #ifndef CONFIG_MODULE_PARSE_NO_FLOAT
14         FLOAT,
15 #endif
16 };
17
18 struct token_num_data {
19         enum numtype type;
20 };
21
22 struct token_num {
23         struct token_hdr hdr;
24         struct token_num_data num_data;
25 };
26 typedef struct token_num parse_token_num_t;
27
28 extern struct token_ops token_num_ops;
29
30 int8_t parse_num(PGM_P tk, const char * srcbuf, void * res);
31 int8_t get_help_num(PGM_P tk, char * dstbuf, uint8_t size);
32
33 #define TOKEN_NUM_INITIALIZER(structure, field, numtype)   \
34 {                                                          \
35         .hdr = {                                           \
36                 .ops = &token_num_ops,                     \
37                 .offset = offsetof(structure, field),      \
38         },                                                 \
39         .num_data = {                                      \
40                 .type = numtype,                           \
41         },                                                 \
42 }
43
44 #endif /* _PARSE_NUM_H_ */