0d0b7df46607c46d2a81635f8c87e42d5faef29c
[navit-package] / src / attr.h
1 #ifndef NAVIT_ATTR_H
2 #define NAVIT_ATTR_H
3
4 #ifdef __cplusplus
5 extern "C" {
6 #endif
7 #ifndef ATTR_H
8 #define ATTR_H
9
10 enum item_type;
11
12 enum attr_type {
13 #define ATTR2(x,y) attr_##y=x,
14 #define ATTR(x) attr_##x,
15 #include "attr_def.h"
16 #undef ATTR2
17 #undef ATTR
18 };
19
20 #define AF_ONEWAY       (1<<0)
21 #define AF_ONEWAYREV    (1<<1)
22 #define AF_NOPASS       (AF_ONEWAY|AF_ONEWAYREV)
23 #define AF_ONEWAYMASK   (AF_ONEWAY|AF_ONEWAYREV)
24 #define AF_SEGMENTED    (1<<2)
25
26
27 struct attr {
28         enum attr_type type;
29         union {
30                 char *str;
31                 int num;
32                 struct item *item;
33                 enum item_type item_type;
34         } u;
35 };
36
37 /* prototypes */
38 enum attr_type;
39 struct attr;
40 enum attr_type attr_from_name(const char *name);
41 char *attr_to_name(enum attr_type attr);
42 struct attr *attr_new_from_text(const char *name, const char *value);
43 struct attr *attr_search(struct attr **attrs, struct attr *last, enum attr_type attr);
44 int attr_data_size(struct attr *attr);
45 void *attr_data_get(struct attr *attr);
46 void attr_data_set(struct attr *attr, void *data);
47 void attr_free(struct attr *attr);
48 /* end of prototypes */
49 #endif
50 #ifdef __cplusplus
51 }
52 #endif
53
54 #endif