Fix:Core:Further cleanup of xmlconfig
[navit-package] / navit / attr.h
1 /**
2  * Navit, a modular navigation system.
3  * Copyright (C) 2005-2008 Navit Team
4  *
5  * This program is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU Library General Public License
7  * version 2 as published by the Free Software Foundation.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12  * GNU Library General Public License for more details.
13  *
14  * You should have received a copy of the GNU Library General Public
15  * License along with this program; if not, write to the
16  * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17  * Boston, MA  02110-1301, USA.
18  */
19
20 #ifndef NAVIT_ATTR_H
21 #define NAVIT_ATTR_H
22
23 #ifdef __cplusplus
24 extern "C" {
25 #endif
26 #ifndef ATTR_H
27 #define ATTR_H
28
29 #include "projection.h"
30
31 enum item_type;
32
33 enum attr_type {
34 #define ATTR2(x,y) attr_##y=x,
35 #define ATTR(x) attr_##x,
36 #include "attr_def.h"
37 #undef ATTR2
38 #undef ATTR
39 };
40
41 #define AF_ONEWAY       (1<<0)
42 #define AF_ONEWAYREV    (1<<1)
43 #define AF_NOPASS       (AF_ONEWAY|AF_ONEWAYREV)
44 #define AF_ONEWAYMASK   (AF_ONEWAY|AF_ONEWAYREV)
45 #define AF_SEGMENTED    (1<<2)
46
47
48 struct attr {
49         enum attr_type type;
50         union {
51                 char *str;
52                 void *data;
53                 int num;
54                 struct item *item;
55                 enum item_type item_type;
56                 enum projection projection;
57                 double * numd;
58                 struct color *color;
59                 struct coord_geo *coord_geo;
60                 struct navit *navit;
61                 struct callback *callback;
62                 struct vehicle *vehicle;
63                 struct layout *layout;
64                 struct layer *layer;
65                 struct map *map;
66                 struct mapset *mapset;
67                 struct log *log;
68                 struct route *route;
69                 struct navigation *navigation;
70                 struct coord *coord;
71                 struct pcoord *pcoord;
72                 struct gui *gui;
73                 struct graphics *graphics;
74                 struct tracking *tracking;
75                 struct itemgra *itemgra;
76                 struct polygon *polygon;
77                 struct polyline *polyline;
78                 struct circle *circle;
79                 struct text *text;
80                 struct icon *icon;
81                 struct image *image;
82                 struct arrows *arrows;
83                 struct element *element;
84                 struct order {
85                         short min, max;
86                 } order;
87                 int *dash;
88                 enum item_type *item_types;
89         } u;
90 };
91
92 /* prototypes */
93 enum attr_type;
94 struct attr;
95 struct attr_iter;
96 struct map;
97 enum attr_type attr_from_name(const char *name);
98 char *attr_to_name(enum attr_type attr);
99 struct attr *attr_new_from_text(const char *name, const char *value);
100 char *attr_to_text(struct attr *attr, struct map *map, int pretty);
101 struct attr *attr_search(struct attr **attrs, struct attr *last, enum attr_type attr);
102 int attr_generic_get_attr(struct attr **attrs, struct attr **def_attrs, enum attr_type type, struct attr *attr, struct attr_iter *iter);
103 struct attr **attr_generic_set_attr(struct attr **attrs, struct attr *attr);
104 int attr_data_size(struct attr *attr);
105 void *attr_data_get(struct attr *attr);
106 void attr_data_set(struct attr *attr, void *data);
107 void attr_free(struct attr *attr);
108 struct attr *attr_dup(struct attr *attr);
109 void attr_list_free(struct attr **attrs);
110 struct attr **attr_list_dup(struct attr **attrs);
111 /* end of prototypes */
112 #endif
113 #ifdef __cplusplus
114 }
115 #endif
116
117 #endif