|
1 /* |
|
2 * Copyright (c) 2000 - 2001 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of the License "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 /** ----------------------------------------------------------------------- ** |
|
20 @package: NW_TinyDom |
|
21 |
|
22 @synopsis: default |
|
23 |
|
24 @description: default |
|
25 |
|
26 ** ----------------------------------------------------------------------- **/ |
|
27 |
|
28 #ifndef TINY_DOM_UTILS_H |
|
29 #define TINY_DOM_UTILS_H |
|
30 |
|
31 #include <xml/cxml/nw_wbxml_parse.h> |
|
32 #include <xml/cxml/nw_tinydom.h> |
|
33 #include <xml/cxml/nw_encoder_wbxmlwriter.h> |
|
34 #include <xml/cxml/nw_dom_document.h> |
|
35 |
|
36 #ifdef __cplusplus |
|
37 extern "C" |
|
38 { |
|
39 #endif /* __cplusplus */ |
|
40 |
|
41 /** ----------------------------------------------------------------------- ** |
|
42 @struct: NW_TinyDom_Parser_Wrapper |
|
43 |
|
44 @synopsis: A wrapper to conceal messy parsing details. |
|
45 |
|
46 @scope: public |
|
47 @variables: |
|
48 NW_WBXML_Parser_t wbxmlParser |
|
49 The WBXMl Parser. |
|
50 |
|
51 NW_TinyDom_Parser_t tinyParser |
|
52 The tiny parser. |
|
53 |
|
54 NW_TinyDom_Tree_t tinyDOMTree |
|
55 The DOM Tree. |
|
56 |
|
57 NW_WBXML_Writer_t writer |
|
58 The writer. |
|
59 |
|
60 NW_WBXML_Document_t document |
|
61 The source document. |
|
62 |
|
63 @description: A wrapper to conceal messy parsing details. |
|
64 ** ----------------------------------------------------------------------- **/ |
|
65 typedef struct NW_TinyDom_Parser_Wrapper_s{ |
|
66 NW_WBXML_Parser_t wbxmlParser; |
|
67 NW_TinyDom_Parser_t tinyParser; |
|
68 NW_TinyDom_Tree_t tinyDOMTree; |
|
69 NW_WBXML_Writer_t writer; |
|
70 NW_WBXML_Document_t document; |
|
71 } NW_TinyDom_Parser_Wrapper_t; |
|
72 |
|
73 /* Deprecated - Left in for backwards copatibility */ |
|
74 typedef struct NW_TinyDom_Parser_Wrapper_s Parser_t; |
|
75 |
|
76 |
|
77 /** ----------------------------------------------------------------------- ** |
|
78 @function: NW_TinyDom_ParserInitialize |
|
79 |
|
80 @synopsis: Helper function to initialize the parser. |
|
81 |
|
82 @scope: public |
|
83 |
|
84 @parameters: |
|
85 [in] Parser_t* p |
|
86 Pointer to a Parser_t struct |
|
87 |
|
88 [in] NW_WBXML_Dictionary_t* dictionaries[] |
|
89 Pointer to the WBXML dictionaries. |
|
90 |
|
91 [in] NW_Int32 dictionaryCount |
|
92 Number of dictionaries. |
|
93 |
|
94 [in] NW_Uint32 default_public_id |
|
95 Default public (i.e.dictionary) ID. |
|
96 |
|
97 @description: Helper function to initialize the parser. |
|
98 |
|
99 @returns: NW_Status_t |
|
100 Status of operation. |
|
101 |
|
102 [NW_STAT_SUCCESS] |
|
103 Parser initialized. |
|
104 |
|
105 [NW_STAT_FAILURE] |
|
106 General error. |
|
107 |
|
108 [NW_STAT_OUT_OF_MEMORY] |
|
109 Out of memory. |
|
110 |
|
111 ** ----------------------------------------------------------------------- **/ |
|
112 IMPORT_C NW_Status_t NW_TinyDom_ParserInitialize(Parser_t* p, |
|
113 NW_WBXML_Dictionary_t* dictionaries[], |
|
114 NW_Int32 dictionaryCount, |
|
115 NW_Uint32 default_public_id); |
|
116 |
|
117 /** ----------------------------------------------------------------------- ** |
|
118 @function: NW_TinyDom_MakeDOMTree |
|
119 |
|
120 @synopsis: Helper function to parse the buffer, creating a tree. |
|
121 |
|
122 @scope: public |
|
123 |
|
124 @parameters: |
|
125 [in] Parser_t* p |
|
126 Pointer to parser struct. |
|
127 |
|
128 [in] NW_Byte* buffer |
|
129 Pointer to content. |
|
130 |
|
131 [in] NW_Uint32 length |
|
132 Number of bytes in buffer. |
|
133 |
|
134 [out] NW_DOM_DocumentNode_t** root |
|
135 Pointer to document root node |
|
136 |
|
137 @description: Helper function to parse the buffer, creating a tree. |
|
138 |
|
139 @returns: NW_Status_t |
|
140 Status of operation. |
|
141 |
|
142 [NW_STAT_SUCCESS] |
|
143 Made DOM tree. |
|
144 |
|
145 [NW_STAT_FAILURE] |
|
146 Failed to make tree. |
|
147 |
|
148 [NW_STAT_OUT_OF_MEMORY] |
|
149 Out of memory. |
|
150 |
|
151 ** ----------------------------------------------------------------------- **/ |
|
152 IMPORT_C NW_Status_t NW_TinyDom_MakeDOMTree (Parser_t* p, |
|
153 NW_Byte* buffer, |
|
154 NW_Uint32 length, |
|
155 NW_DOM_DocumentNode_t** root); |
|
156 |
|
157 /** ----------------------------------------------------------------------- ** |
|
158 @function: NW_TinyDom_AppendDOMTree |
|
159 |
|
160 @synopsis: Helper function to parse the buffer, appending new nodes to the tree. |
|
161 |
|
162 @scope: public |
|
163 |
|
164 @parameters: |
|
165 [in] Parser_t* p |
|
166 Pointer to parser struct. |
|
167 |
|
168 [in] NW_Byte* buffer |
|
169 Pointer to content. |
|
170 |
|
171 [in] NW_Uint32 length |
|
172 Number of bytes in buffer. |
|
173 |
|
174 [in] NW_Uint32 cp_count |
|
175 Number of code page switch count |
|
176 |
|
177 [in] NW_Int32 lastValid |
|
178 Index pointing to the position in buffer where last valid parse stopped at. |
|
179 |
|
180 [out] NW_DOM_DocumentNode_t** root |
|
181 Pointer to document root node |
|
182 |
|
183 @description: Helper function to parse the buffer, appending new nodes to the tree. |
|
184 |
|
185 @returns: NW_Status_t |
|
186 Status of operation. |
|
187 |
|
188 [NW_STAT_SUCCESS] |
|
189 Made DOM tree. |
|
190 |
|
191 [NW_STAT_FAILURE] |
|
192 Failed to make tree. |
|
193 |
|
194 [NW_STAT_OUT_OF_MEMORY] |
|
195 Out of memory. |
|
196 |
|
197 ** ----------------------------------------------------------------------- **/ |
|
198 IMPORT_C NW_Status_t NW_TinyDom_AppendDOMTree (Parser_t* p, |
|
199 NW_Byte* buffer, |
|
200 NW_Uint32 length, |
|
201 NW_Uint32 cp_count, |
|
202 NW_Int32 lastValid, |
|
203 NW_DOM_DocumentNode_t** root); |
|
204 |
|
205 /** ----------------------------------------------------------------------- ** |
|
206 @function: NW_TinyDom_ParserDelete |
|
207 |
|
208 @synopsis: Free the internal memory in allocated in |
|
209 NW_TinyDom_MakeDOMTree. |
|
210 |
|
211 @scope: public |
|
212 |
|
213 @parameters: |
|
214 [in] Parser_t* p |
|
215 Pointer to parser struct. |
|
216 |
|
217 @description: Free the internal memory in allocated in |
|
218 NW_TinyDom_MakeDOMTree. |
|
219 |
|
220 ** ----------------------------------------------------------------------- **/ |
|
221 IMPORT_C void NW_TinyDom_ParserDelete(Parser_t* p); |
|
222 |
|
223 #ifdef __cplusplus |
|
224 } /* extern "C" { */ |
|
225 #endif /* __cplusplus */ |
|
226 |
|
227 #endif /* TINY_DOM_UTILS_H */ |