Fix a crash
[framework/location/libdecarta.git] / decarta / xml_wrapper.h
1 /*
2  * libdecarta
3  *
4  * Copyright (c) 2010-2011 Samsung Electronics Co., Ltd. All rights reserved.
5  *
6  * Contact: Youngae Kang <youngae.kang@samsung.com>, Yunhan Kim <yhan.kim@samsung.com>,
7  *          Genie Kim <daejins.kim@samsung.com>, Minjune Kim <sena06.kim@samsung.com>
8  *
9  * Licensed under the Apache License, Version 2.0 (the "License");
10  * you may not use this file except in compliance with the License.
11  * You may obtain a copy of the License at
12  *
13  * http://www.apache.org/licenses/LICENSE-2.0
14  *
15  * Unless required by applicable law or agreed to in writing, software
16  * distributed under the License is distributed on an "AS IS" BASIS,
17  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18  * See the License for the specific language governing permissions and
19  * limitations under the License.
20  */
21
22 #ifndef XML_WRAPPER_H_
23 #define XML_WRAPPER_H_
24
25 #include <glib.h>
26
27 G_BEGIN_DECLS
28
29 typedef void* XmlWriterHandler;
30 typedef void* XmlReaderHandler;
31
32 /** used for SAX parse route response */
33 typedef struct{
34         char *description;
35         char *duration;
36         char *tour;
37         char *instruction;
38         char *distance;
39 } decarta_route_inst_str_s;
40
41 typedef struct{
42         char *description;
43         char *url;
44         char *pos1;
45         char *pos2;
46 } decarta_route_map_str_s;
47
48 typedef struct{
49         char *pos;
50         char *country_code;
51         char *lang_code;
52         int is_freeform;
53         char *freeform_addr;
54
55         char *building_num;
56         char *street;
57         char *country_subdivision;
58         char *country_2_subdivision;
59         char *municipality;
60         char *municipality_subdivision;
61         char *postcode;
62         char *landmark_type;
63         char *landmark_name;
64 } decarta_geo_addr_s;
65
66
67 typedef struct {
68
69         /** error */
70         int has_error;
71         char *error_code_str;
72         char *error_message_str;
73         char *error_severity_str;
74
75         /** route*/
76         int has_route_resp;
77
78         int route_geometry_state;
79         char *route_geometry_str;
80
81         int route_totaltime_state;
82         char *route_totaltime_str;
83
84         int route_totaldist_state;
85         char *route_totaldist_str;
86
87         int route_bbox_state;
88         char *route_bbox_pos1_str;
89         char *route_bbox_pos2_str;
90
91         int route_start_state;
92         GList *route_start_addr_list;
93         int route_end_state;
94         GList *route_end_addr_list;
95
96         int route_map_overview_state;
97         char *route_ov_tile_url_str;
98         char *route_ov_pos1_str;
99         char *route_ov_pos2_str;
100
101         int route_instruction_state;
102         GList *route_inst_str_list;
103
104         int route_map_state;
105         GList *route_map_str_list;
106 } sax_route_data_s;
107
108 XmlWriterHandler xml_writer_open(char* encoding);
109 gboolean xml_writer_close (XmlWriterHandler handle, char **content, unsigned int *size);
110 gboolean xml_writer_all_start (XmlWriterHandler handle, const char* element, const char* content, ...);
111 gboolean xml_writer_element_start (XmlWriterHandler handle, const char* element);
112 gboolean xml_writer_attribute_write (XmlWriterHandler handle, const gchar *name, const gchar *value);
113 gboolean xml_writer_end (XmlWriterHandler handle);
114
115 XmlReaderHandler xml_reader_open (const char* data, ...);
116 void xml_reader_close (XmlReaderHandler handle);
117 gboolean xml_reader_is_valid (XmlReaderHandler handle, const char *xpath_format, ...);
118 gboolean xml_reader_get_string (XmlReaderHandler handle, char **string, const char *xpath_format, ...);
119 int _xml_sax_read(const char* data, void *user_data);
120
121
122 G_END_DECLS
123
124 #endif