navit  0.5.1-trunk
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Macros Groups
xmlconfig.h
Go to the documentation of this file.
1 
20 #ifndef NAVIT_XMLCONFIG_H
21 #define NAVIT_XMLCONFIG_H
22 
23 #ifdef __cplusplus
24 extern "C" {
25 #endif
26 
27 #include "config.h"
28 
29 #ifndef USE_EZXML
30 #ifdef HAVE_GLIB
31 #define USE_EZXML 0
32 #else
33 #define USE_EZXML 1
34 #endif
35 #endif
36 
37 #if !USE_EZXML
38 #define XML_ATTR_DISTANCE 1
39 typedef GMarkupParseContext xml_context;
40 #else
41 #include "ezxml.h"
42 #define XML_ATTR_DISTANCE 2
43 #undef G_MARKUP_ERROR
44 #undef G_MARKUP_ERROR_INVALID_CONTENT
45 #undef G_MARKUP_ERROR_PARSE
46 #undef G_MARKUP_ERROR_UNKNOWN_ELEMENT
47 #define G_MARKUP_ERROR 0
48 #define G_MARKUP_ERROR_INVALID_CONTENT 0
49 #define G_MARKUP_ERROR_PARSE 0
50 #define G_MARKUP_ERROR_UNKNOWN_ELEMENT 0
51 typedef void * xml_context;
52 #endif
53 
54 typedef void *(*object_func_new)(struct attr *parent, struct attr **attrs);
55 typedef int (*object_func_get_attr)(void *, enum attr_type type, struct attr *attr, struct attr_iter *iter);
56 typedef struct attr_iter *(*object_func_iter_new)(void *);
57 typedef void (*object_func_iter_destroy)(struct attr_iter *);
58 typedef int (*object_func_set_attr)(void *, struct attr *attr);
59 typedef int (*object_func_add_attr)(void *, struct attr *attr);
60 typedef int (*object_func_remove_attr)(void *, struct attr *attr);
61 typedef int (*object_func_init)(void *);
62 typedef void (*object_func_destroy)(void *);
63 typedef void *(*object_func_dup)(void *);
64 typedef void *(*object_func_ref)(void *);
65 typedef void *(*object_func_unref)(void *);
66 
67 
80 struct object_func {
81  enum attr_type type;
82  void *(*create)(struct attr *parent, struct attr **attrs);
83  int (*get_attr)(void *, enum attr_type type, struct attr *attr, struct attr_iter *iter);
86  struct attr_iter *(*iter_new)(void *);
89  void (*iter_destroy)(struct attr_iter *);
92  int (*set_attr)(void *, struct attr *attr);
95  int (*add_attr)(void *, struct attr *attr);
98  int (*remove_attr)(void *, struct attr *attr);
101  int (*init)(void *);
103  void (*destroy)(void *);
106  void *(*dup)(void *);
107  void *(*ref)(void *);
110  void *(*unref)(void *);
113 };
114 
116 
117 #define HAS_OBJECT_FUNC(x) ((x) == attr_map || (x) == attr_mapset || (x) == attr_navit || (x) == attr_osd || (x) == attr_trackingo || (x) == attr_vehicle || (x) == attr_maps || (x) == attr_layout || (x) == attr_roadprofile || (x) == attr_vehicleprofile || (x) == attr_layer || (x) == attr_config || (x) == attr_profile_option || (x) == attr_script || (x) == attr_log || (x) == attr_speech || (x) == attr_navigation || (x) == attr_route)
118 
119 #define NAVIT_OBJECT struct object_func *func; int refcount; struct attr **attrs;
120 struct navit_object {
122 };
123 
124 int navit_object_set_methods(void *in, int in_size, void *out, int out_size);
125 struct navit_object *navit_object_new(struct attr **attrs, struct object_func *func, int size);
126 struct navit_object *navit_object_ref(struct navit_object *obj);
127 void navit_object_unref(struct navit_object *obj);
130 int navit_object_get_attr(struct navit_object *obj, enum attr_type type, struct attr *attr, struct attr_iter *iter);
131 void navit_object_callbacks(struct navit_object *obj, struct attr *attr);
132 int navit_object_set_attr(struct navit_object *obj, struct attr *attr);
133 int navit_object_add_attr(struct navit_object *obj, struct attr *attr);
134 int navit_object_remove_attr(struct navit_object *obj, struct attr *attr);
135 void navit_object_destroy(struct navit_object *obj);
136 
137 typedef GError xmlerror;
138 
139 /* prototypes */
140 enum attr_type;
141 struct object_func *object_func_lookup(enum attr_type type);
142 void xml_parse_text(const char *document, void *data, void (*start)(xml_context *, const char *, const char **, const char **, void *, GError **), void (*end)(xml_context *, const char *, void *, GError **), void (*text)(xml_context*, const char *, gsize, void *, GError **));
143 gboolean config_load(const char *filename, xmlerror **error);
144 //static void xinclude(GMarkupParseContext *context, const gchar **attribute_names, const gchar **attribute_values, struct xmldocument *doc_old, xmlerror **error);
145 
146 /* end of prototypes */
147 
148 #ifdef __cplusplus
149 }
150 #endif
151 
152 #endif
gboolean config_load(const char *filename, xmlerror **error)
Definition: xmlconfig.c:1212
attr_type
Definition: attr.h:34
void(* object_func_destroy)(void *)
Definition: xmlconfig.h:62
struct object_func script_func
Definition: script.c:99
struct object_func vehicleprofile_func
Definition: vehicleprofile.c:310
void navit_object_callbacks(struct navit_object *obj, struct attr *attr)
Definition: xmlconfig.c:1330
Basic functions for Navit objects.
Definition: xmlconfig.h:80
tuple iter
Definition: eval.py:8
struct attr_iter * navit_object_attr_iter_new(void)
Definition: xmlconfig.c:1287
int size
Definition: garmin_img.c:131
void(* object_func_iter_destroy)(struct attr_iter *)
Definition: xmlconfig.h:57
int navit_object_set_methods(void *in, int in_size, void *out, int out_size)
Definition: xmlconfig.c:1238
int(* add_attr)(void *, struct attr *attr)
Definition: xmlconfig.h:95
int(* init)(void *)
Definition: xmlconfig.h:101
#define NAVIT_OBJECT
Definition: xmlconfig.h:119
struct object_func config_func
Definition: config_.c:170
int navit_object_add_attr(struct navit_object *obj, struct attr *attr)
Definition: xmlconfig.c:1346
struct navit_object * navit_object_ref(struct navit_object *obj)
Definition: xmlconfig.c:1264
void navit_object_destroy(struct navit_object *obj)
Definition: xmlconfig.c:1386
struct object_func map_func mapset_func navit_func osd_func tracking_func vehicle_func maps_func layout_func roadprofile_func vehicleprofile_func layer_func config_func profile_option_func script_func log_func speech_func navigation_func route_func
Definition: route.c:4259
enum attr_type type
Definition: xmlconfig.h:81
struct object_func mapset_func
Definition: mapset.c:402
int(* object_func_init)(void *)
Definition: xmlconfig.h:61
GError xmlerror
Definition: xmlconfig.h:137
struct object_func layout_func
Definition: layout.c:629
struct object_func log_func
Definition: log.c:573
struct parent parent
void navit_object_attr_iter_destroy(struct attr_iter *iter)
Definition: xmlconfig.c:1293
int navit_object_remove_attr(struct navit_object *obj, struct attr *attr)
Definition: xmlconfig.c:1370
void(* iter_destroy)(struct attr_iter *)
Definition: xmlconfig.h:89
char filename[8]
Definition: garmin_img.c:129
Definition: config_.c:48
struct object_func roadprofile_func
Definition: roadprofile.c:117
struct navit_object * navit_object_new(struct attr **attrs, struct object_func *func, int size)
Definition: xmlconfig.c:1254
void(* destroy)(void *)
Definition: xmlconfig.h:103
char data
Definition: garmin_img.c:354
Definition: attr.h:156
struct object_func * object_func_lookup(enum attr_type type)
Definition: xmlconfig.c:254
int(* remove_attr)(void *, struct attr *attr)
Definition: xmlconfig.h:98
int(* object_func_remove_attr)(void *, struct attr *attr)
Definition: xmlconfig.h:60
struct object_func layer_func
Definition: layout.c:646
int(* object_func_set_attr)(void *, struct attr *attr)
Definition: xmlconfig.h:58
void navit_object_unref(struct navit_object *obj)
Definition: xmlconfig.c:1272
int(* get_attr)(void *, enum attr_type type, struct attr *attr, struct attr_iter *iter)
Definition: xmlconfig.h:83
struct object_func map_func
Definition: map.c:735
struct object_func speech_func
Definition: speech.c:150
struct attr * attrs
Definition: attr.h:210
int navit_object_get_attr(struct navit_object *obj, enum attr_type type, struct attr *attr, struct attr_iter *iter)
Generic get function.
Definition: xmlconfig.c:1324
struct object_func navit_func
Definition: navit.c:205
int(* object_func_get_attr)(void *, enum attr_type type, struct attr *attr, struct attr_iter *iter)
Definition: xmlconfig.h:55
struct object_func tracking_func
Definition: track.c:43
typedef int(WINAPI *FP_SetStretchBltMode)(HDC dc
struct object_func maps_func
Definition: maps.c:88
void xml_parse_text(const char *document, void *data, void(*start)(xml_context *, const char *, const char **, const char **, void *, GError **), void(*end)(xml_context *, const char *, void *, GError **), void(*text)(xml_context *, const char *, gsize, void *, GError **))
Definition: xmlconfig.c:1059
char type[3]
Definition: garmin_img.c:130
struct object_func vehicle_func
Definition: vehicle.c:81
int(* object_func_add_attr)(void *, struct attr *attr)
Definition: xmlconfig.h:59
int navit_object_set_attr(struct navit_object *obj, struct attr *attr)
Definition: xmlconfig.c:1337
void * xml_context
Definition: xmlconfig.h:51
int(* set_attr)(void *, struct attr *attr)
Definition: xmlconfig.h:92
struct object_func osd_func
Definition: osd.c:501
Definition: xmlconfig.h:120
struct object_func profile_option_func
Definition: profile_option.c:48
error
Definition: command.c:94