|
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_Encoder |
|
21 |
|
22 @synopsis: default |
|
23 |
|
24 @description: default |
|
25 |
|
26 ** ----------------------------------------------------------------------- **/ |
|
27 |
|
28 #ifndef NW_WBXMLWRITER_H |
|
29 #define NW_WBXMLWRITER_H |
|
30 |
|
31 #include <xml/cxml/nw_wbxml_dictionary.h> |
|
32 |
|
33 #ifdef __cplusplus |
|
34 extern "C" { |
|
35 #endif /* __cplusplus */ |
|
36 |
|
37 |
|
38 struct NW_WBXML_Writer_s; |
|
39 |
|
40 /* ----------------------------------------------------------------------- ** |
|
41 If the string is in the table, set *pFound = NW_TRUE, else set |
|
42 *pFound = NW_FALSE. Return a failure code only if something else goes wrong |
|
43 (e.g., out of memory) |
|
44 ** ----------------------------------------------------------------------- **/ |
|
45 typedef |
|
46 NW_Status_t (*NW_WBXML_Writer_GetStringTableOffset_t)(void* pStringTableObject, |
|
47 NW_Uint32 byteCount, |
|
48 const NW_Uint8* pString, |
|
49 NW_Bool* pFound, |
|
50 NW_Uint32* pTableOffset); |
|
51 |
|
52 /* ----------------------------------------------------------------------- ** |
|
53 If for some reason the string can't be added to the table, |
|
54 return a failure status code. |
|
55 ** ----------------------------------------------------------------------- **/ |
|
56 typedef |
|
57 NW_Status_t (*NW_WBXML_Writer_AddToStringTable_t)(void* pStringTableObject, |
|
58 NW_Uint32 byteCount, |
|
59 const NW_Uint8* pString, |
|
60 NW_Uint32* pTableOffset); |
|
61 |
|
62 /* at end of string table return byteCount = 0 */ |
|
63 typedef |
|
64 NW_Status_t (*NW_WBXML_Writer_StringTableIterateInit_t)(void* pStringTableObject, |
|
65 void* pStringTableIterator); |
|
66 |
|
67 /* at end of string table return byteCount = 0 */ |
|
68 typedef |
|
69 NW_Status_t (*NW_WBXML_Writer_StringTableIterateNext_t)(void* pStringTableIterator, |
|
70 NW_Uint32* pByteCount, |
|
71 NW_Uint8** ppBuf); |
|
72 |
|
73 /* the callback is responsible for updating the writer structure |
|
74 byteCount and pBuf */ |
|
75 typedef |
|
76 NW_Status_t (*NW_WBXML_Writer_GrowBuf_t)(struct NW_WBXML_Writer_s*, |
|
77 NW_Uint32 writeLength); |
|
78 |
|
79 |
|
80 /** ----------------------------------------------------------------------- ** |
|
81 @struct: NW_WBXML_Writer |
|
82 |
|
83 @synopsis: The WBXML writer structure. |
|
84 |
|
85 @scope: public |
|
86 @variables: |
|
87 NW_Uint32 index |
|
88 Read/write position. |
|
89 |
|
90 NW_Uint32 byteCount |
|
91 Allocated length |
|
92 |
|
93 NW_Uint8* pBuf |
|
94 The buffer. |
|
95 |
|
96 NW_WBXML_Writer_GrowBuf_t growBufCallback |
|
97 Callback. |
|
98 |
|
99 NW_WBXML_Dictionary_t* pTagDictionary |
|
100 The tag dictionary. |
|
101 |
|
102 NW_WBXML_Dictionary_t* pAttributeDictionary |
|
103 The attribute dictionary. |
|
104 |
|
105 NW_WBXML_Writer_GetStringTableOffset_t getStringTableOffset |
|
106 Callback. |
|
107 |
|
108 NW_WBXML_Writer_AddToStringTable_t addToStringTable |
|
109 Callback |
|
110 |
|
111 void* pStringTableObject |
|
112 The string table. |
|
113 |
|
114 NW_WBXML_Writer_StringTableIterateInit_t stringTableIterateInit |
|
115 llback. |
|
116 |
|
117 NW_WBXML_Writer_StringTableIterateNext_t stringTableIterateNext |
|
118 Callback. |
|
119 |
|
120 NW_Uint8 tagCodePage |
|
121 The tag code page. |
|
122 |
|
123 NW_Uint8 attributeCodePage |
|
124 The attribute code page. |
|
125 |
|
126 NW_Bool sizing |
|
127 If sizing != 0 then don't write to buffer. Increment |
|
128 index as though writing so that final value of index |
|
129 indicates the required byteCount for allocating buffer. |
|
130 |
|
131 @description: The WBXML writer structure. Contains all the callbacks |
|
132 as well as cursor and dictionary data. |
|
133 ** ----------------------------------------------------------------------- **/ |
|
134 typedef struct NW_WBXML_Writer_s { |
|
135 NW_Uint32 index; /* a read/write position */ |
|
136 NW_Uint32 byteCount; /* allocated length */ |
|
137 NW_Uint8* pBuf; |
|
138 NW_WBXML_Writer_GrowBuf_t growBufCallback; |
|
139 |
|
140 NW_WBXML_Dictionary_t* pTagDictionary; |
|
141 NW_WBXML_Dictionary_t* pAttributeDictionary; |
|
142 |
|
143 NW_WBXML_Writer_GetStringTableOffset_t getStringTableOffset; |
|
144 NW_WBXML_Writer_AddToStringTable_t addToStringTable; |
|
145 void* pStringTableObject; |
|
146 |
|
147 NW_WBXML_Writer_StringTableIterateInit_t stringTableIterateInit; |
|
148 NW_WBXML_Writer_StringTableIterateNext_t stringTableIterateNext; |
|
149 |
|
150 NW_Uint8 tagCodePage; |
|
151 NW_Uint8 attributeCodePage; |
|
152 |
|
153 /* if sizing != 0 then don't write to buf, increment index as |
|
154 though writing so that final value of index indicates the |
|
155 required byteCount for allocating buf */ |
|
156 NW_Bool sizing; |
|
157 // WLIU_DEBUG: NW_Int32 cp_count; |
|
158 } NW_WBXML_Writer_t; |
|
159 |
|
160 |
|
161 /** ----------------------------------------------------------------------- ** |
|
162 @function: NW_WBXML_Writer_Initialize |
|
163 |
|
164 @synopsis: Initializes the writer for use. |
|
165 |
|
166 @scope: public |
|
167 |
|
168 @parameters: |
|
169 [in-out] NW_WBXML_Writer_t* pW |
|
170 The writer. |
|
171 |
|
172 [in] NW_Uint32 byteCount |
|
173 Allocated length. |
|
174 |
|
175 [in] NW_Uint8* pBuf |
|
176 The buffer. |
|
177 |
|
178 [in] NW_WBXML_Writer_GrowBuf_t growBufCallback |
|
179 Callback. |
|
180 |
|
181 [in] NW_WBXML_Dictionary_t* pTagDictionary |
|
182 Tag dictionary. |
|
183 [in] NW_WBXML_Dictionary_t* pAttributeDictionary |
|
184 Attribute dictionary. |
|
185 |
|
186 [in] NW_WBXML_Writer_GetStringTableOffset_t getStringTableOffset |
|
187 Callback. |
|
188 |
|
189 [in] NW_WBXML_Writer_AddToStringTable_t addToStringTable |
|
190 Callback. |
|
191 |
|
192 [in] void* pStringTableObject |
|
193 The string table. |
|
194 |
|
195 [in] NW_WBXML_Writer_StringTableIterateInit_t stringTableIterateStart |
|
196 Callback. |
|
197 |
|
198 [in] NW_WBXML_Writer_StringTableIterateNext_t stringTableIterateNext |
|
199 Callback. |
|
200 |
|
201 [in] NW_Bool sizing |
|
202 If sizing != 0 then don't write to buffer. Increment |
|
203 index as though writing so that final value of index |
|
204 indicates the required byteCount for allocating buffer. |
|
205 |
|
206 @description: It is OK to use byteCount==0 and pBuf==NULL if you |
|
207 have a growBufCallback or if no allocation is needed |
|
208 because sizing==1. If you do a sizing pass and then |
|
209 allocate and set pBuf you can also set |
|
210 growBufCallback==NULL as no additional memory should |
|
211 be required. No malloc's or free's are in the WBXML |
|
212 writer code. If you have no string table then null |
|
213 the various string table related pointers. |
|
214 Client should free the writer object when finished. |
|
215 |
|
216 ** ----------------------------------------------------------------------- **/ |
|
217 IMPORT_C |
|
218 void |
|
219 NW_WBXML_Writer_Initialize(NW_WBXML_Writer_t* pW, |
|
220 NW_Uint32 byteCount, NW_Uint8* pBuf, |
|
221 NW_WBXML_Writer_GrowBuf_t growBufCallback, |
|
222 NW_WBXML_Dictionary_t* pTagDictionary, |
|
223 NW_WBXML_Dictionary_t* pAttributeDictionary, |
|
224 NW_WBXML_Writer_GetStringTableOffset_t getStringTableOffset, |
|
225 NW_WBXML_Writer_AddToStringTable_t addToStringTable, |
|
226 void* pStringTableObject, |
|
227 NW_WBXML_Writer_StringTableIterateInit_t stringTableIterateStart, |
|
228 NW_WBXML_Writer_StringTableIterateNext_t stringTableIterateNext, |
|
229 NW_Bool sizing); |
|
230 |
|
231 #define NW_WBXML_Writer_GetSize(pW) ((pW)->index) |
|
232 |
|
233 /** ----------------------------------------------------------------------- ** |
|
234 @function: NW_WBXML_Writer_SetToSizing |
|
235 |
|
236 @synopsis: Initialize writer for sizing (no write). |
|
237 |
|
238 @scope: public |
|
239 |
|
240 @parameters: |
|
241 [in] NW_WBXML_Writer_t* pW |
|
242 The writer. |
|
243 |
|
244 @description: Initialize writer for sizing (no write). |
|
245 |
|
246 ** ----------------------------------------------------------------------- **/ |
|
247 void |
|
248 NW_WBXML_Writer_SetToSizing(NW_WBXML_Writer_t* pW); |
|
249 |
|
250 /** ----------------------------------------------------------------------- ** |
|
251 @function: NW_WBXML_Writer_SetToWrite |
|
252 |
|
253 @synopsis: Initialize writer for writing. |
|
254 |
|
255 @scope: public |
|
256 |
|
257 @parameters: |
|
258 [in] NW_WBXML_Writer_t* pW |
|
259 The writer. |
|
260 |
|
261 [in] NW_Uint32 byteCount |
|
262 Allocated buffer length |
|
263 |
|
264 [in] NW_Uint8* pBuf |
|
265 Allocated buffer. |
|
266 |
|
267 @description: Initialize writer for writing. |
|
268 |
|
269 ** ----------------------------------------------------------------------- **/ |
|
270 void |
|
271 NW_WBXML_Writer_SetToWrite(NW_WBXML_Writer_t* pW, |
|
272 NW_Uint32 byteCount, NW_Uint8* pBuf); |
|
273 |
|
274 |
|
275 /** ----------------------------------------------------------------------- ** |
|
276 @function: NW_WBXML_Writer_Header |
|
277 |
|
278 @synopsis: Write the document header. |
|
279 |
|
280 @scope: public |
|
281 |
|
282 @parameters: |
|
283 [in] NW_WBXML_Writer_t* pW |
|
284 The writer. |
|
285 |
|
286 [in] NW_Uint8 WBxmlVersion |
|
287 The version. |
|
288 |
|
289 [in] NW_Uint32 publicIdentifier |
|
290 The public identifier. |
|
291 |
|
292 [in] NW_Uint32 charsetMIBEnum |
|
293 The character set. |
|
294 |
|
295 [in] NW_Uint32 stringTableByteCount |
|
296 Size of string table. |
|
297 |
|
298 @description: Write the document header. The string table byte count |
|
299 will be 0 if there is no string table. |
|
300 |
|
301 @returns: NW_Status_t |
|
302 Status of operation. |
|
303 |
|
304 [NW_STAT_SUCCESS] |
|
305 Header written. |
|
306 |
|
307 [NW_STAT_FAILURE] |
|
308 General error. |
|
309 |
|
310 [NW_STAT_OUT_OF_MEMORY] |
|
311 Can't allocate memory to write header. |
|
312 |
|
313 ** ----------------------------------------------------------------------- **/ |
|
314 IMPORT_C |
|
315 NW_Status_t |
|
316 NW_WBXML_Writer_Header(NW_WBXML_Writer_t* pW, NW_Uint8 WBxmlVersion, |
|
317 NW_Uint32 publicIdentifier, NW_Uint32 charsetMIBEnum, |
|
318 NW_Uint32 stringTableByteCount); |
|
319 |
|
320 |
|
321 /** ----------------------------------------------------------------------- ** |
|
322 @function: NW_WBXML_Writer_TagSetContentFlag |
|
323 |
|
324 @synopsis: Set content flag. |
|
325 |
|
326 @scope: public |
|
327 |
|
328 @parameters: |
|
329 [in] NW_WBXML_Writer_t* pW |
|
330 The writer. |
|
331 |
|
332 [in] NW_Uint32 index |
|
333 Offset into buffer to find tag flag. |
|
334 |
|
335 @description: If "index" points to a tag token, then this will |
|
336 set content flags. Capture a tag index through the |
|
337 pTagIndex argument to NW_WBXML_Writer_Tag. |
|
338 |
|
339 @returns: NW_Status_t |
|
340 Status of operation. |
|
341 |
|
342 [NW_STAT_SUCCESS] |
|
343 Flag set. |
|
344 |
|
345 [NW_STAT_FAILURE] |
|
346 General error. |
|
347 |
|
348 ** ----------------------------------------------------------------------- **/ |
|
349 IMPORT_C |
|
350 NW_Status_t |
|
351 NW_WBXML_Writer_TagSetContentFlag(NW_WBXML_Writer_t* pW, NW_Uint32 index); |
|
352 |
|
353 |
|
354 /** ----------------------------------------------------------------------- ** |
|
355 @function: NW_WBXML_Writer_TagClearContentFlag |
|
356 |
|
357 @synopsis: Clear content flag. |
|
358 |
|
359 @scope: public |
|
360 |
|
361 @parameters: |
|
362 [in] NW_WBXML_Writer_t* pW |
|
363 The writer. |
|
364 |
|
365 [in] NW_Uint32 index |
|
366 Offset into buffer to find tag flag. |
|
367 |
|
368 @description: If "index" points to a tag token, then this will |
|
369 clear content flags. Capture a tag index through |
|
370 the pTagIndex argument to NW_WBXML_Writer_Tag. |
|
371 |
|
372 @description: Clear content flag. |
|
373 |
|
374 @returns: NW_Status_t |
|
375 Status of operation. |
|
376 |
|
377 [NW_STAT_SUCCESS] |
|
378 Flag set. |
|
379 |
|
380 [NW_STAT_FAILURE] |
|
381 General error. |
|
382 |
|
383 ** ----------------------------------------------------------------------- **/ |
|
384 IMPORT_C |
|
385 NW_Status_t |
|
386 NW_WBXML_Writer_TagClearContentFlag(NW_WBXML_Writer_t* pW, NW_Uint32 index); |
|
387 |
|
388 |
|
389 /** ----------------------------------------------------------------------- ** |
|
390 @function: NW_WBXML_Writer_TagSetAttributesFlag |
|
391 |
|
392 @synopsis: Set attribute flag. |
|
393 |
|
394 @scope: public |
|
395 |
|
396 @parameters: |
|
397 [in] NW_WBXML_Writer_t* pW |
|
398 The writer. |
|
399 |
|
400 [in] NW_Uint32 index |
|
401 Index into buffer to find flag. |
|
402 |
|
403 @description: If "index" points to a tag token, then this will |
|
404 set attribute flags. Capture a tag index through |
|
405 the pTagIndex argument to NW_WBXML_Writer_Tag. |
|
406 |
|
407 @description: Set attribute flag. |
|
408 |
|
409 @returns: NW_Status_t |
|
410 Status of operation. |
|
411 |
|
412 [NW_STAT_SUCCESS] |
|
413 Flag set. |
|
414 |
|
415 [NW_STAT_FAILURE] |
|
416 General error. |
|
417 |
|
418 ** ----------------------------------------------------------------------- **/ |
|
419 IMPORT_C |
|
420 NW_Status_t |
|
421 NW_WBXML_Writer_TagSetAttributesFlag(NW_WBXML_Writer_t* pW, NW_Uint32 index); |
|
422 |
|
423 |
|
424 /** ----------------------------------------------------------------------- ** |
|
425 @function: NW_WBXML_Writer_TagClearAttributesFlag |
|
426 |
|
427 @synopsis: Clear attributes flag. |
|
428 |
|
429 @scope: public |
|
430 |
|
431 @parameters: |
|
432 [in] NW_WBXML_Writer_t* pW |
|
433 Thw writer. |
|
434 |
|
435 [in] NW_Uint32 index |
|
436 Offset into buffer to find flag. |
|
437 |
|
438 @description: If "index" points to a tag token, then this will |
|
439 clear attribute flags. Capture a tag index through |
|
440 the pTagIndex argument to NW_WBXML_Writer_Tag. |
|
441 |
|
442 @description: Clear attributes flag. |
|
443 |
|
444 @returns: NW_Status_t |
|
445 Status of operation. |
|
446 |
|
447 [NW_STAT_SUCCESS] |
|
448 Flag cleared. |
|
449 |
|
450 [NW_STAT_FAILURE] |
|
451 General error. |
|
452 |
|
453 ** ----------------------------------------------------------------------- **/ |
|
454 NW_Status_t |
|
455 NW_WBXML_Writer_TagClearAttributesFlag(NW_WBXML_Writer_t* pW, NW_Uint32 index); |
|
456 |
|
457 |
|
458 /** ----------------------------------------------------------------------- ** |
|
459 @function: NW_WBXML_Writer_TagToken |
|
460 |
|
461 @synopsis: Extracts token and writes it to buffer. |
|
462 |
|
463 @scope: public |
|
464 |
|
465 @parameters: |
|
466 [in] NW_WBXML_Writer_t* pW |
|
467 The writer. |
|
468 |
|
469 [in] NW_Uint16 fqToken |
|
470 The fully qualified token. |
|
471 |
|
472 [in] NW_Uint32* pTagIndex |
|
473 Index of tag into buffer. |
|
474 |
|
475 @description: Extracts token and writes it to buffer. |
|
476 |
|
477 @returns: NW_Status_t |
|
478 Status of operation. |
|
479 |
|
480 [NW_STAT_SUCCESS] |
|
481 Flag cleared. |
|
482 |
|
483 [NW_STAT_FAILURE] |
|
484 General error. |
|
485 |
|
486 ** ----------------------------------------------------------------------- **/ |
|
487 NW_Status_t |
|
488 NW_WBXML_Writer_TagToken(NW_WBXML_Writer_t* pW, NW_Uint16 fqToken, |
|
489 NW_Uint32* pTagIndex); |
|
490 |
|
491 |
|
492 /** ----------------------------------------------------------------------- ** |
|
493 @function: NW_WBXML_Writer_TagString |
|
494 |
|
495 @synopsis: Writes tag string. |
|
496 |
|
497 @scope: public |
|
498 |
|
499 @parameters: |
|
500 [in] NW_WBXML_Writer_t* pW |
|
501 The writer. |
|
502 |
|
503 [in] NW_Uint32 encoding |
|
504 The encoding. |
|
505 |
|
506 [in] NW_Uint32 charCount |
|
507 Character count. It should not include null termination |
|
508 character if any exists. |
|
509 |
|
510 [in] NW_Uint32 byteCount |
|
511 Byte count. |
|
512 |
|
513 [in] NW_Uint8* pBuf |
|
514 Buffer containing characters. |
|
515 |
|
516 [out] NW_Uint32* pTagIndex |
|
517 Contains the index to the tag token in the WBXML |
|
518 |
|
519 @description: This function tries the following in sequence as required: |
|
520 A. look in the dictionary for the string's token |
|
521 B. look in the string table |
|
522 C. look for reserved name "zzzunknown" token in the tag dictionary |
|
523 If all fail, then the function returns NW_STAT_FAILURE. |
|
524 On return, *pTagIndex contains the index to the tag token in the WBXML so |
|
525 you can subsequently toggle the content and attribute flags. |
|
526 |
|
527 @returns: NW_Status_t |
|
528 Status of operation. |
|
529 |
|
530 [NW_STAT_SUCCESS] |
|
531 Token found. |
|
532 |
|
533 [NW_STAT_FAILURE] |
|
534 Could not find token. |
|
535 |
|
536 ** ----------------------------------------------------------------------- **/ |
|
537 IMPORT_C |
|
538 NW_Status_t |
|
539 NW_WBXML_Writer_TagString(NW_WBXML_Writer_t* pW, NW_Uint32 encoding, |
|
540 NW_Uint32 charCount, NW_Uint32 byteCount, |
|
541 NW_Uint8* pBuf, NW_Uint32* pTagIndex); |
|
542 |
|
543 |
|
544 /** ----------------------------------------------------------------------- ** |
|
545 @function: NW_WBXML_Writer_AttributeAndValue |
|
546 |
|
547 @synopsis: Write attrbute and value. |
|
548 |
|
549 @scope: public |
|
550 |
|
551 @parameters: |
|
552 [in] NW_WBXML_Writer_t* pW |
|
553 The writer. |
|
554 |
|
555 [in] NW_Uint32 encoding |
|
556 The encoding. |
|
557 |
|
558 [in] NW_Uint32 nameCharCount |
|
559 Name character count. |
|
560 |
|
561 [in] NW_Uint8* pName |
|
562 Attribute name. |
|
563 |
|
564 [in] NW_Uint32 valueCharCount |
|
565 Value character count. |
|
566 |
|
567 [in] NW_Uint32 valueByteCount |
|
568 Value byte count. |
|
569 |
|
570 [in] NW_Uint8* pValue |
|
571 Value name. |
|
572 |
|
573 @description: A convenience function for when attribute name and |
|
574 value are given as text. The character count should not |
|
575 include NULL termination character if any exists If there |
|
576 is an attribute name but no value use valueCharCount==0, |
|
577 valueByteCount==0 and pValue==NULL |
|
578 |
|
579 @returns: NW_Status_t |
|
580 Status of operation. |
|
581 |
|
582 [NW_STAT_SUCCESS] |
|
583 Attribute and value written. |
|
584 |
|
585 [NW_STAT_FAILURE] |
|
586 General error. |
|
587 |
|
588 [NW_STAT_OUT_OF_MEMORY] |
|
589 Couldn't allocate memory for write. |
|
590 |
|
591 ** ----------------------------------------------------------------------- **/ |
|
592 IMPORT_C |
|
593 NW_Status_t |
|
594 NW_WBXML_Writer_AttributeAndValue(NW_WBXML_Writer_t* pW, NW_Uint32 encoding, |
|
595 NW_Uint32 nameCharCount, NW_Uint8* pName, |
|
596 NW_Uint32 valueCharCount, |
|
597 NW_Uint32 valueByteCount, |
|
598 NW_Uint8* pValue); |
|
599 |
|
600 IMPORT_C |
|
601 NW_Status_t |
|
602 NW_WBXML_Writer_AttributeAndValue2(NW_WBXML_Writer_t* pW, NW_Uint32 encoding, |
|
603 NW_Uint32 nameCharCount, NW_Uint8* pName, |
|
604 NW_Uint32 valueCharCount, |
|
605 NW_Uint32 valueByteCount, |
|
606 NW_Uint8* pValue, |
|
607 NW_Uint32* cp_count); |
|
608 |
|
609 |
|
610 /** ----------------------------------------------------------------------- ** |
|
611 @function: NW_WBXML_Writer_AttributeToken |
|
612 |
|
613 @synopsis: Write attribute token. |
|
614 |
|
615 @scope: public |
|
616 |
|
617 @parameters: |
|
618 [in] NW_WBXML_Writer_t* pW |
|
619 The writer. |
|
620 |
|
621 [in] NW_Uint16 fqToken |
|
622 The fully qualified token. |
|
623 |
|
624 @description: Write attribute token. |
|
625 |
|
626 @returns: NW_Status_t |
|
627 Status of operation. |
|
628 |
|
629 [NW_STAT_SUCCESS] |
|
630 Attribute and value written. |
|
631 |
|
632 [NW_STAT_FAILURE] |
|
633 General error. |
|
634 |
|
635 [NW_STAT_OUT_OF_MEMORY] |
|
636 Couldn't allocate memory for write. |
|
637 |
|
638 ** ----------------------------------------------------------------------- **/ |
|
639 NW_Status_t |
|
640 NW_WBXML_Writer_AttributeToken(NW_WBXML_Writer_t* pW, NW_Uint16 fqToken); |
|
641 |
|
642 |
|
643 /** ----------------------------------------------------------------------- ** |
|
644 @function: NW_WBXML_Writer_AttributeNameString |
|
645 |
|
646 @synopsis: Write attribute name token using string. |
|
647 |
|
648 @scope: public |
|
649 |
|
650 @parameters: |
|
651 [in] NW_WBXML_Writer_t* pW |
|
652 The writer. |
|
653 |
|
654 [in] NW_Uint32 encoding |
|
655 The encoding. |
|
656 |
|
657 [in] NW_Uint32 nameCharCount |
|
658 Character count of name. Should not include null termination |
|
659 character if any exists. |
|
660 |
|
661 [in] NW_Uint32 nameByteCount |
|
662 Byte count of name. |
|
663 |
|
664 [in] NW_Uint8* pName |
|
665 The name. |
|
666 |
|
667 @description: Write attribute name token using string. |
|
668 This function tries the following in sequence as required: |
|
669 A. look in the dictionary for the string's token |
|
670 B. look in the string table |
|
671 C. look for reserved name "zzzunknown" token in the attribute dictionary |
|
672 If all fail, then the function returns NW_STAT_FAILURE. |
|
673 |
|
674 @returns: NW_Status_t |
|
675 Status of operation. |
|
676 |
|
677 [NW_STAT_SUCCESS] |
|
678 Attribute and value written. |
|
679 |
|
680 [NW_STAT_FAILURE] |
|
681 General error. |
|
682 |
|
683 [NW_STAT_OUT_OF_MEMORY] |
|
684 Couldn't allocate memory for write. |
|
685 |
|
686 ** ----------------------------------------------------------------------- **/ |
|
687 NW_Status_t |
|
688 NW_WBXML_Writer_AttributeNameString(NW_WBXML_Writer_t* pW, NW_Uint32 encoding, |
|
689 NW_Uint32 nameCharCount, |
|
690 NW_Uint32 nameByteCount, NW_Uint8* pName); |
|
691 |
|
692 |
|
693 /** ----------------------------------------------------------------------- ** |
|
694 @function: NW_WBXML_Writer_Entity |
|
695 |
|
696 @synopsis: Writes entity and its token. |
|
697 |
|
698 @scope: public |
|
699 |
|
700 @parameters: |
|
701 [in] NW_WBXML_Writer_t* pW |
|
702 The writer. |
|
703 |
|
704 [in] NW_Uint32 entity |
|
705 The entity. |
|
706 |
|
707 @description: Writes entity and its token. |
|
708 |
|
709 @returns: NW_Status_t |
|
710 Status of operation. |
|
711 |
|
712 [NW_STAT_SUCCESS] |
|
713 Attribute and value written. |
|
714 |
|
715 [NW_STAT_FAILURE] |
|
716 General error. |
|
717 |
|
718 [NW_STAT_OUT_OF_MEMORY] |
|
719 Couldn't allocate memory for write. |
|
720 |
|
721 ** ----------------------------------------------------------------------- **/ |
|
722 NW_Status_t |
|
723 NW_WBXML_Writer_Entity(NW_WBXML_Writer_t* pW, |
|
724 NW_Uint32 entity); |
|
725 |
|
726 /** ----------------------------------------------------------------------- ** |
|
727 @function: NW_WBXML_Writer_ExtensionUseStringTable |
|
728 |
|
729 @synopsis: Writes EXT_T_[0,1,2] extension forms only and uses |
|
730 the string table to hold the string. |
|
731 |
|
732 @scope: public |
|
733 |
|
734 @parameters: |
|
735 [in] NW_WBXML_Writer_t* pW |
|
736 The writer. |
|
737 |
|
738 [in] NW_Uint16 fqToken |
|
739 The fully qualified token. |
|
740 |
|
741 [in] NW_Uint32 byteCount |
|
742 byte count for string buffer including null termination |
|
743 |
|
744 [in] NW_Uint8* pBuf |
|
745 pointer to the null terminated string data |
|
746 |
|
747 @description: This is a helper function for the basic extension writing |
|
748 function for the particular case of EXT_T_[0,1,2] tokens |
|
749 where the string must be put in the string table. |
|
750 |
|
751 @returns: NW_Status_t |
|
752 Status of operation. |
|
753 |
|
754 [NW_STAT_SUCCESS] |
|
755 Entity written. |
|
756 |
|
757 [NW_STAT_FAILURE] |
|
758 General error. |
|
759 |
|
760 [NW_STAT_OUT_OF_MEMORY] |
|
761 Couldn't allocate memory for write. |
|
762 |
|
763 ** ----------------------------------------------------------------------- **/ |
|
764 NW_Status_t |
|
765 NW_WBXML_Writer_ExtensionUseStringTable(NW_WBXML_Writer_t* pW, |
|
766 NW_Uint16 fqToken, |
|
767 NW_Uint32 byteCount, |
|
768 NW_Uint8* pBuf); |
|
769 |
|
770 /** ----------------------------------------------------------------------- ** |
|
771 @function: NW_WBXML_Writer_Extension |
|
772 |
|
773 @synopsis: Writes extension. |
|
774 |
|
775 @scope: public |
|
776 |
|
777 @parameters: |
|
778 [in] NW_WBXML_Writer_t* pW |
|
779 The writer. |
|
780 |
|
781 [in] NW_Uint16 fqToken |
|
782 The fully qualified token. |
|
783 |
|
784 [in] NW_Uint32 anonymousValue |
|
785 Optional extension value. |
|
786 |
|
787 [in] NW_Uint32 byteCount |
|
788 Optional extension byte count. |
|
789 |
|
790 [in] NW_Uint8* pBuf |
|
791 Optional extension text. |
|
792 |
|
793 @description: There are three type of extensions: |
|
794 1. one of three possible single byte tokens |
|
795 NW_WBXML_EXT_[0,1,2] |
|
796 2. an extension token followed by a multibyte encoded NW_Uint32 value |
|
797 NW_WBXML_EXT_T_[0,1,2] multibyte(anonymousValue) |
|
798 3. an extension token followed by an in-line string |
|
799 NW_WBXML_EXT_I_[0,1,2] null-terminated-string |
|
800 |
|
801 This function handles all three cases so you have to pass the |
|
802 appropriate arguments for each case. For each fqToken should be |
|
803 one of NW_WBXML_EXT_[0,1,2] (with any page value): |
|
804 |
|
805 1. anonymousValue, byteCount and pBuf should be 0 or NULL |
|
806 |
|
807 2. anonymousValue should be the value to multibyte encode |
|
808 and byteCount and pBuf should be 0 and NULL |
|
809 |
|
810 3. byteCount should be the byte length of the null terminated string |
|
811 pointed to by pBuf and anonymousValue is ignored |
|
812 |
|
813 @returns: NW_Status_t |
|
814 Status of operation. |
|
815 |
|
816 [NW_STAT_SUCCESS] |
|
817 Entity written. |
|
818 |
|
819 [NW_STAT_FAILURE] |
|
820 General error. |
|
821 |
|
822 [NW_STAT_OUT_OF_MEMORY] |
|
823 Couldn't allocate memory for write. |
|
824 |
|
825 ** ----------------------------------------------------------------------- **/ |
|
826 NW_Status_t |
|
827 NW_WBXML_Writer_Extension(NW_WBXML_Writer_t* pW, |
|
828 NW_Uint16 fqToken, |
|
829 NW_Uint32 anonymousValue, |
|
830 NW_Uint32 byteCount, |
|
831 NW_Uint8* pBuf); |
|
832 |
|
833 |
|
834 /** ----------------------------------------------------------------------- ** |
|
835 @function: NW_WBXML_Writer_Opaque |
|
836 |
|
837 @synopsis: Writes opaque data. |
|
838 |
|
839 @scope: public |
|
840 |
|
841 @parameters: |
|
842 [in] NW_WBXML_Writer_t* pW |
|
843 The writer. |
|
844 |
|
845 [in] NW_Uint32 byteCount |
|
846 Length of opaque. |
|
847 |
|
848 [in] NW_Uint8* pBuf |
|
849 Opaque data. |
|
850 |
|
851 @description: Writes opaque data. |
|
852 |
|
853 @returns: NW_Status_t |
|
854 Status of operation. |
|
855 |
|
856 [NW_STAT_SUCCESS] |
|
857 Opaque written. |
|
858 |
|
859 [NW_STAT_FAILURE] |
|
860 General error. |
|
861 |
|
862 [NW_STAT_OUT_OF_MEMORY] |
|
863 Couldn't allocate memory for write. |
|
864 |
|
865 ** ----------------------------------------------------------------------- **/ |
|
866 IMPORT_C |
|
867 NW_Status_t |
|
868 NW_WBXML_Writer_Opaque(NW_WBXML_Writer_t* pW, NW_Uint32 byteCount, |
|
869 NW_Uint8* pBuf); |
|
870 |
|
871 |
|
872 /** ----------------------------------------------------------------------- ** |
|
873 @function: NW_WBXML_Writer_Text |
|
874 |
|
875 @synopsis: Write text or reference. |
|
876 |
|
877 @scope: public |
|
878 |
|
879 @parameters: |
|
880 [in] NW_WBXML_Writer_t* pW |
|
881 The writer. |
|
882 |
|
883 [in] NW_Uint32 encoding |
|
884 The encoding. |
|
885 |
|
886 [in] NW_Uint32 byteCount |
|
887 The text byte count. |
|
888 |
|
889 [in] const NW_Uint8* pText |
|
890 The text. |
|
891 |
|
892 @description: If string is already in the string table, this writes |
|
893 a reference otherwise it writes an in-line string. |
|
894 |
|
895 @returns: NW_Status_t |
|
896 Status of operation. |
|
897 |
|
898 [NW_STAT_SUCCESS] |
|
899 Text written. |
|
900 |
|
901 [NW_STAT_FAILURE] |
|
902 General error. |
|
903 |
|
904 [NW_STAT_OUT_OF_MEMORY] |
|
905 Couldn't allocate memory for write. |
|
906 |
|
907 ** ----------------------------------------------------------------------- **/ |
|
908 IMPORT_C |
|
909 NW_Status_t |
|
910 NW_WBXML_Writer_Text(NW_WBXML_Writer_t* pW, NW_Uint32 encoding, |
|
911 NW_Uint32 byteCount, const NW_Uint8* pText); |
|
912 |
|
913 /** ----------------------------------------------------------------------- ** |
|
914 @function: NW_WBXML_Writer_PI |
|
915 |
|
916 @synopsis: Writes the beginning PI token. |
|
917 |
|
918 @scope: public |
|
919 |
|
920 @parameters: |
|
921 [in] NW_WBXML_Writer_t* pW |
|
922 The writer. |
|
923 |
|
924 @description: Just writes the beginning PI token. The remainder of |
|
925 the PI must be written just like an attribute. |
|
926 The grammar is: |
|
927 PI attributeName [attributeValue...] END |
|
928 |
|
929 @returns: NW_Status_t |
|
930 Status of operation. |
|
931 |
|
932 [NW_STAT_SUCCESS] |
|
933 Process instruction written. |
|
934 |
|
935 [NW_STAT_FAILURE] |
|
936 General error. |
|
937 |
|
938 [NW_STAT_OUT_OF_MEMORY] |
|
939 Couldn't allocate memory for write. |
|
940 |
|
941 ** ----------------------------------------------------------------------- **/ |
|
942 IMPORT_C |
|
943 NW_Status_t |
|
944 NW_WBXML_Writer_PI(NW_WBXML_Writer_t* pW); |
|
945 |
|
946 |
|
947 /** ----------------------------------------------------------------------- ** |
|
948 @function: NW_WBXML_Writer_End |
|
949 |
|
950 @synopsis: Writes end of element, end of attribute list or end of PI |
|
951 |
|
952 @scope: public |
|
953 |
|
954 @parameters: |
|
955 [in] NW_WBXML_Writer_t* pW |
|
956 default |
|
957 |
|
958 @description: Writes end of element, end of attribute list or end of PI. |
|
959 |
|
960 @returns: NW_Status_t |
|
961 Status of operation. |
|
962 |
|
963 [NW_STAT_SUCCESS] |
|
964 End written. |
|
965 |
|
966 [NW_STAT_FAILURE] |
|
967 General error. |
|
968 |
|
969 [NW_STAT_OUT_OF_MEMORY] |
|
970 Couldn't allocate memory for write. |
|
971 |
|
972 ** ----------------------------------------------------------------------- **/ |
|
973 IMPORT_C |
|
974 NW_Status_t |
|
975 NW_WBXML_Writer_End(NW_WBXML_Writer_t* pW); |
|
976 |
|
977 |
|
978 #ifdef __cplusplus |
|
979 } /* extern "C" { */ |
|
980 #endif /* __cplusplus */ |
|
981 |
|
982 #endif /* NW_WBXMLWRITER_H */ |