navit 0.5.3-trunk
Loading...
Searching...
No Matches
attr.h
Go to the documentation of this file.
1
20#ifndef NAVIT_ATTR_H
21#define NAVIT_ATTR_H
22
23#ifdef __cplusplus
24extern "C" {
25#endif
26
27#include "projection.h"
28
29#include "item_type_def.h"
30
31#include "attr_type_def.h"
32
37
38#define AF_ONEWAY (1 << 0)
39#define AF_ONEWAYREV (1 << 1)
40#define AF_NOPASS (AF_ONEWAY | AF_ONEWAYREV)
41#define AF_ONEWAYMASK (AF_ONEWAY | AF_ONEWAYREV)
42#define AF_SEGMENTED (1 << 2)
43#define AF_ROUNDABOUT (1 << 3)
44#define AF_ROUNDABOUT_VALID (1 << 4)
45#define AF_ONEWAY_EXCEPTION (1 << 5)
46#define AF_SPEED_LIMIT (1 << 6)
47#define AF_RESERVED1 (1 << 7)
48#define AF_SIZE_OR_WEIGHT_LIMIT (1 << 8)
49#define AF_THROUGH_TRAFFIC_LIMIT (1 << 9)
50#define AF_TOLL (1 << 10)
51#define AF_SEASONAL (1 << 11)
52#define AF_UNPAVED (1 << 12)
53#define AF_FORD (1 << 13)
54#define AF_UNDERGROUND (1 << 14)
55#define AF_HIGH_OCCUPANCY_CAR_ONLY (1 << 18)
56#define AF_DANGEROUS_GOODS (1 << 19)
57#define AF_EMERGENCY_VEHICLES (1 << 20)
58#define AF_TRANSPORT_TRUCK (1 << 21)
59#define AF_DELIVERY_TRUCK (1 << 22)
60#define AF_PUBLIC_BUS (1 << 23)
61#define AF_TAXI (1 << 24)
62#define AF_HIGH_OCCUPANCY_CAR (1 << 25)
63#define AF_CAR (1 << 26)
64#define AF_MOTORCYCLE (1 << 27)
65#define AF_MOPED (1 << 28)
66#define AF_HORSE (1 << 29)
67#define AF_BIKE (1 << 30)
68#define AF_PEDESTRIAN (1 << 31)
69
70#define AF_PBH (AF_PEDESTRIAN | AF_BIKE | AF_HORSE)
71#define AF_MOTORIZED_FAST \
72 (AF_MOTORCYCLE | AF_CAR | AF_HIGH_OCCUPANCY_CAR | AF_TAXI | AF_PUBLIC_BUS | AF_DELIVERY_TRUCK | AF_TRANSPORT_TRUCK \
73 | AF_EMERGENCY_VEHICLES)
74#define AF_ALL (AF_PBH | AF_MOPED | AF_MOTORIZED_FAST)
75#define AF_DISTORTIONMASK (AF_ALL | AF_ONEWAYMASK)
76
77#define AF_DG_ANY (1 << 0)
78#define AF_DG_WATER_HARMFUL (1 << 1)
79#define AF_DG_EXPLOSIVE (1 << 2)
80#define AF_DG_FLAMMABLE (1 << 3)
81
82/*
83 * Values for attributes that could carry relative values.
84 * Some attributes allow both absolute and relative values. The value for these
85 * attributes is stored as an int. Absolute values are stored as-is, relative
86 * values are stored shifted by adding ATTR_REL_RELSHIFT.
87 */
89#define ATTR_REL_MINABS -0x40000000
91#define ATTR_REL_MAXABS 0x40000000
93#define ATTR_REL_MINREL -0x1FFFFFFF
95#define ATTR_REL_MAXREL 0x20000000
99#define ATTR_REL_RELSHIFT 0x60000000
100
118
119#define ATTR_IS_INT(x) ((x) >= attr_type_int_begin && (x) <= attr_type_int_end)
120#define ATTR_IS_DOUBLE(x) ((x) >= attr_type_double_begin && (x) <= attr_type_double_end)
121#define ATTR_IS_STRING(x) ((x) >= attr_type_string_begin && (x) <= attr_type_string_end)
122#define ATTR_IS_OBJECT(x) ((x) >= attr_type_object_begin && (x) <= attr_type_object_end)
123#define ATTR_IS_ITEM(x) ((x) >= attr_type_item_begin && (x) <= attr_type_item_end)
124#define ATTR_IS_COORD_GEO(x) ((x) >= attr_type_coord_geo_begin && (x) <= attr_type_coord_geo_end)
125#define ATTR_IS_NUMERIC(x) (ATTR_IS_INT(x) || ATTR_IS_DOUBLE(x))
126#define ATTR_IS_COLOR(x) ((x) >= attr_type_color_begin && (x) <= attr_type_color_end)
127#define ATTR_IS_PCOORD(x) ((x) >= attr_type_pcoord_begin && (x) <= attr_type_pcoord_end)
128#define ATTR_IS_COORD(x) ((x) >= attr_type_coord_begin && (x) <= attr_type_coord_end)
129#define ATTR_IS_GROUP(x) ((x) >= attr_type_group_begin && (x) <= attr_type_group_end)
130
131#define ATTR_INT(x, y) ((struct attr){attr_##x, {.num = y}})
132#define ATTR_OBJECT(x, y) ((struct attr){attr_##x, {.navit = y}})
133
134struct range {
135 short min, max;
136};
137
138struct attr {
140 union {
141 char *str;
142 void *data;
143 long num;
144 struct item *item;
147 double *numd;
148 struct color *color;
150 struct navit *navit;
154 struct layout *layout;
155 struct layer *layer;
156 struct map *map;
157 struct mapset *mapset;
158 struct log *log;
159 struct route *route;
161 struct coord *coord;
162 struct pcoord *pcoord;
163 struct gui *gui;
167 struct plugin *plugin;
171 struct circle *circle;
172 struct text *text;
173 struct icon *icon;
174 struct image *image;
175 struct arrows *arrows;
176 struct spikes *spikes;
178 struct speech *speech;
179 struct cursor *cursor;
185 struct config *config;
186 struct osd *osd;
187 struct range range;
190 int *dash;
193 long long *num64;
194 struct attr *attrs;
196 } u;
197};
198
199struct attr_iter;
200/* prototypes */
201void attr_create_hash(void);
202void attr_destroy_hash(void);
203enum attr_type attr_from_name(const char *name);
204char *attr_to_name(enum attr_type attr);
205struct attr *attr_new_from_text(const char *name, const char *value);
206char *attr_to_text_ext(struct attr *attr, char *sep, enum attr_format fmt, enum attr_format def_fmt, struct map *map);
207char *attr_to_text(struct attr *attr, struct map *map, int pretty);
208struct attr *attr_search(struct attr **attrs, enum attr_type attr);
209int attr_generic_get_attr(struct attr **attrs, struct attr **def_attrs, enum attr_type type, struct attr *attr,
210 struct attr_iter *iter);
211struct attr **attr_generic_set_attr(struct attr **attrs, struct attr *attr);
212struct attr **attr_generic_add_attr(struct attr **attrs, struct attr *attr);
213struct attr **attr_generic_add_attr_list(struct attr **attrs, struct attr **add);
214struct attr **attr_generic_prepend_attr(struct attr **attrs, struct attr *attr);
215struct attr **attr_generic_remove_attr(struct attr **attrs, struct attr *attr);
217int attr_data_size(struct attr *attr);
218void *attr_data_get(struct attr *attr);
219void attr_data_set(struct attr *attr, void *data);
220void attr_data_set_le(struct attr *attr, void *data);
221void attr_free_content(struct attr *attr);
222void attr_free(struct attr *attr);
223void attr_free_g(struct attr *attr, void *unused); /* to use as GFunc in glib context */
224void attr_dup_content(struct attr *src, struct attr *dst);
225struct attr *attr_dup(struct attr *attr);
226void attr_list_free(struct attr **attrs);
227struct attr **attr_list_dup(struct attr **attrs);
228struct attr **attr_list_append(struct attr **attrs, struct attr *attr);
229int attr_from_line(const char *line, const char *name, int *pos, char *val_ret, char *name_ret);
231int attr_types_contains_default(enum attr_type *types, enum attr_type type, int deflt);
232int attr_rel2real(int attrval, int whole, int treat_neg_as_rel);
233/* end of prototypes */
234#ifdef __cplusplus
235}
236#endif
237
238#endif
struct attr * attr_dup(struct attr *attr)
Definition attr.c:901
void attr_data_set_le(struct attr *attr, void *data)
Definition attr.c:835
char * attr_to_text(struct attr *attr, struct map *map, int pretty)
Converts an attribute to a string that can be displayed.
Definition attr.c:524
int attr_types_contains(enum attr_type *types, enum attr_type type)
Checks if an enumeration of attribute types contains a specific attribute.
Definition attr.c:1054
int attr_rel2real(int attrval, int whole, int treat_neg_as_rel)
Derive absolute value from relative attribute, given value of the whole range.
Definition attr.c:1091
struct attr ** attr_generic_prepend_attr(struct attr **attrs, struct attr *attr)
Definition attr.c:688
attr_position_valid
Definition attr.h:102
@ attr_position_valid_extrapolated_spatial
Definition attr.h:111
@ attr_position_valid_extrapolated_time
Definition attr.h:107
@ attr_position_valid_static
Definition attr.h:104
@ attr_position_valid_valid
Definition attr.h:116
@ attr_position_valid_invalid
Definition attr.h:103
void attr_dup_content(struct attr *src, struct attr *dst)
Definition attr.c:876
struct attr ** attr_generic_remove_attr(struct attr **attrs, struct attr *attr)
Removes an attribute from an attribute list.
Definition attr.c:721
struct attr ** attr_generic_add_attr_list(struct attr **attrs, struct attr **add)
Definition attr.c:680
void attr_destroy_hash(void)
Definition attr.c:79
int attr_data_size(struct attr *attr)
Definition attr.c:775
int attr_types_contains_default(enum attr_type *types, enum attr_type type, int deflt)
Check if an enumeration of attribute types contains a specific attribute.
Definition attr.c:1075
struct attr * attr_search(struct attr **attrs, enum attr_type attr)
Searches for an attribute of a given type.
Definition attr.c:539
attr_format
Definition attr.h:33
@ attr_format_default
Definition attr.h:34
@ attr_format_with_units
Definition attr.h:35
char * attr_to_text_ext(struct attr *attr, char *sep, enum attr_format fmt, enum attr_format def_fmt, struct map *map)
Converts attribute data to human-readable text.
Definition attr.c:396
void attr_list_free(struct attr **attrs)
Frees a list of attributes.
Definition attr.c:916
struct attr ** attr_list_append(struct attr **attrs, struct attr *attr)
void * attr_data_get(struct attr *attr)
Definition attr.c:818
struct attr ** attr_generic_set_attr(struct attr **attrs, struct attr *attr)
Generic set function.
Definition attr.c:632
void attr_free(struct attr *attr)
Definition attr.c:867
void attr_free_g(struct attr *attr, void *unused)
Definition attr.c:872
struct attr ** attr_list_dup(struct attr **attrs)
Duplicates a list of attributes.
Definition attr.c:935
struct attr ** attr_generic_add_attr(struct attr **attrs, struct attr *attr)
Generic add function.
Definition attr.c:663
void attr_free_content(struct attr *attr)
Definition attr.c:862
struct attr * attr_new_from_text(const char *name, const char *value)
Creates an attribute from text information.
Definition attr.c:135
char * attr_to_name(enum attr_type attr)
Converts an attr_type to a string.
Definition attr.c:115
enum attr_type attr_type_begin(enum attr_type type)
Definition attr.c:745
void attr_data_set(struct attr *attr, void *data)
Definition attr.c:827
int attr_generic_get_attr(struct attr **attrs, struct attr **def_attrs, enum attr_type type, struct attr *attr, struct attr_iter *iter)
Generic get function.
Definition attr.c:593
void attr_create_hash(void)
Definition attr.c:71
int attr_from_line(const char *line, const char *name, int *pos, char *val_ret, char *name_ret)
Retrieves an attribute from a line in textfile format.
Definition attr.c:976
enum attr_type attr_from_name(const char *name)
Converts a string to an attr_type.
Definition attr.c:93
attr_type
Definition attr_type_def.h:11
static GValue value
Definition datawindow.c:42
char data
Definition garmin_img.c:2
char type[3]
Definition garmin_img.c:2
unsigned char types
Definition garmin_img.c:1
item_type
Definition item_type_def.h:8
struct navit struct traffic_methods struct attr ** attrs
Definition plugin_def.h:36
projection
Definition projection.h:23
char name[0]
Definition street.c:3
Definition config_.c:45
Definition attr.h:138
struct config * config
Definition attr.h:185
enum item_type item_type
Definition attr.h:145
long long * num64
Definition attr.h:193
struct itemgra * itemgra
Definition attr.h:166
struct bookmarks * bookmarks
Definition attr.h:184
struct image * image
Definition attr.h:174
struct log * log
Definition attr.h:158
struct gui * gui
Definition attr.h:163
struct arrows * arrows
Definition attr.h:175
struct route * route
Definition attr.h:159
struct navit_object * navit_object
Definition attr.h:188
struct navigation * navigation
Definition attr.h:160
char * str
Definition attr.h:141
struct cursor * cursor
Definition attr.h:179
struct tracking * tracking
Definition attr.h:165
struct coord_geo * coord_geo
Definition attr.h:149
struct attr * attrs
Definition attr.h:194
struct plugin * plugin
Definition attr.h:167
struct spikes * spikes
Definition attr.h:176
struct navit * navit
Definition attr.h:150
struct color * color
Definition attr.h:148
struct vehicle * vehicle
Definition attr.h:153
struct element * element
Definition attr.h:177
struct poly_hole * poly_hole
Definition attr.h:195
enum projection projection
Definition attr.h:146
struct icon * icon
Definition attr.h:173
struct layout * layout
Definition attr.h:154
double * numd
Definition attr.h:147
struct transformation * transformation
Definition attr.h:181
struct traffic * traffic
Definition attr.h:189
struct pcoord * pcoord
Definition attr.h:162
struct plugins * plugins
Definition attr.h:168
union attr::@0 u
struct coord * coord
Definition attr.h:161
struct speech * speech
Definition attr.h:178
struct graphics * graphics
Definition attr.h:164
void * data
Definition attr.h:142
int * dash
Definition attr.h:190
enum item_type * item_types
Definition attr.h:191
struct polyline * polyline
Definition attr.h:170
struct callback_list * callback_list
Definition attr.h:152
struct vehicleprofile * vehicleprofile
Definition attr.h:182
struct text * text
Definition attr.h:172
struct circle * circle
Definition attr.h:171
struct callback * callback
Definition attr.h:151
struct mapset * mapset
Definition attr.h:157
struct map * map
Definition attr.h:156
struct osd * osd
Definition attr.h:186
enum attr_type type
Definition attr.h:139
struct layer * layer
Definition attr.h:155
struct displaylist * displaylist
Definition attr.h:180
struct item * item
Definition attr.h:144
enum attr_type * attr_types
Definition attr.h:192
long num
Definition attr.h:143
struct roadprofile * roadprofile
Definition attr.h:183
struct polygon * polygon
Definition attr.h:169
Definition bookmarks.c:53
Definition callback.c:35
Definition callback.c:26
Definition graphics.c:1776
Definition color.h:23
Definition config_.c:33
A WGS84 coordinate.
Definition coord.h:94
Definition coord.h:33
Definition layout.h:117
Definition graphics.c:122
Definition layout.h:38
graphics object A graphics object serves as the target for drawing operations. It encapsulates variou...
Definition graphics.c:78
Definition gui.c:30
Represents an object on a map.
Definition item.h:122
Definition layout.h:101
Definition layout.h:107
Definition layout.h:125
Definition log.c:58
Definition map.c:58
Definition mapset.c:38
Definition navigation.c:167
Definition xmlconfig.h:131
Definition navit.c:110
Definition osd.c:34
Definition coord.h:51
Definition plugin.c:120
Definition plugin.c:131
Definition layout.h:33
Definition attr.h:134
short min
Definition attr.h:135
short max
Definition attr.h:135
Definition roadprofile.h:29
A complete route.
Definition route.c:206
Definition speech.c:28
Definition track.c:83
A traffic plugin instance.
Definition traffic.c:117
The parameters needed to transform a map for display.
Definition transform.c:64
Definition vehicle.c:60
Definition vehicleprofile.h:27