de10e7dd55187f9f3934da5e0573b7581ac138a4
[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 struct token_num_pgm {
28         struct token_hdr hdr;
29         struct token_num_data num_data;
30 } PROGMEM;
31 typedef struct token_num_pgm parse_pgm_token_num_t;
32
33 extern struct token_ops token_num_ops;
34
35 int8_t parse_num(parse_pgm_token_hdr_t * tk, 
36                  const char * srcbuf, void * res);
37 int8_t get_help_num(parse_pgm_token_hdr_t * tk, 
38                     char * dstbuf, uint8_t size);
39
40 #define TOKEN_NUM_INITIALIZER(structure, field, numtype)   \
41 {                                                          \
42         .hdr = {                                           \
43                 .ops = &token_num_ops,                     \
44                 .offset = offsetof(structure, field),      \
45         },                                                 \
46         .num_data = {                                      \
47                 .type = numtype,                           \
48         },                                                 \
49 }
50
51 #endif /* _PARSE_NUM_H_ */