soui 5.0.0.1
Soui5 Doc
 
Loading...
Searching...
No Matches
sxml-i.h
1#ifndef __SXML_I__H__
2#define __SXML_I__H__
3
4#include <interface/obj-ref-i.h>
5#include <interface/sstring-i.h>
6#include <stdio.h>
7
8SNSBEGIN
9
10/**
11 * @interface IXmlAttr
12 * @brief Interface for XML attributes.
13 */
14#undef INTERFACE
15#define INTERFACE IXmlAttr
16DECLARE_INTERFACE(IXmlAttr)
17{
18 /**
19 * @brief Gets the private pointer associated with the attribute.
20 * @return Pointer to private data.
21 */
22 STDMETHOD_(LPVOID, GetPrivPtr)(CTHIS) SCONST PURE;
23
24 /**
25 * @brief Checks if the attribute is empty.
26 * @return TRUE if the attribute is empty, FALSE otherwise.
27 */
28 STDMETHOD_(BOOL, Empty)(CTHIS) SCONST PURE;
29
30 /**
31 * @brief Gets the name of the attribute.
32 * @return The name of the attribute, or an empty string if the attribute is empty.
33 */
34 STDMETHOD_(const wchar_t*, Name)(CTHIS) SCONST PURE;
35
36 /**
37 * @brief Gets the value of the attribute.
38 * @return The value of the attribute, or an empty string if the attribute is empty.
39 */
40 STDMETHOD_(const wchar_t*, Value)(CTHIS) SCONST PURE;
41
42 /**
43 * @brief Sets user-defined data associated with the attribute.
44 * @param data User-defined data.
45 * @return TRUE if successful, FALSE otherwise.
46 */
47 STDMETHOD_(BOOL, set_userdata)(THIS_ int data) PURE;
48
49 /**
50 * @brief Gets user-defined data associated with the attribute.
51 * @return User-defined data.
52 */
53 STDMETHOD_(int, get_userdata)(CTHIS) SCONST PURE;
54
55 /**
56 * @brief Gets the next attribute in the attribute list of the parent node.
57 * @return Pointer to the next attribute, or NULL if there is no next attribute.
58 */
59 STDMETHOD_(IXmlAttr*, Next)(THIS) PURE;
60
61 /**
62 * @brief Gets the previous attribute in the attribute list of the parent node.
63 * @return Pointer to the previous attribute, or NULL if there is no previous attribute.
64 */
65 STDMETHOD_(IXmlAttr*, Prev)(THIS) PURE;
66
67 /**
68 * @brief Converts the attribute value to an integer.
69 * @param def Default value to return if conversion fails.
70 * @return The integer value of the attribute, or the default value if conversion fails.
71 */
72 STDMETHOD_(int, AsInt)(THIS_ int def DEF_VAL(0)) PURE;
73
74 /**
75 * @brief Converts the attribute value to an unsigned integer.
76 * @param def Default value to return if conversion fails.
77 * @return The unsigned integer value of the attribute, or the default value if conversion fails.
78 */
79 STDMETHOD_(unsigned int, AsUint)(THIS_ int def DEF_VAL(0)) PURE;
80
81 /**
82 * @brief Converts the attribute value to a float.
83 * @param def Default value to return if conversion fails.
84 * @return The float value of the attribute, or the default value if conversion fails.
85 */
86 STDMETHOD_(float, AsFloat)(THIS_ float def DEF_VAL(0.0f)) PURE;
87
88 /**
89 * @brief Converts the attribute value to a double.
90 * @param def Default value to return if conversion fails.
91 * @return The double value of the attribute, or the default value if conversion fails.
92 */
93 STDMETHOD_(double, AsDouble)(THIS_ double def DEF_VAL(0.0)) PURE;
94
95 /**
96 * @brief Converts the attribute value to a boolean.
97 * @param def Default value to return if conversion fails.
98 * @return The boolean value of the attribute, or the default value if conversion fails.
99 */
100 STDMETHOD_(BOOL, AsBool)(THIS_ BOOL def DEF_VAL(FALSE)) PURE;
101};
102
103/**
104 * @enum _XmlNodeType
105 * @brief Enumerates the types of XML nodes.
106 */
107typedef enum _XmlNodeType
108{
109 node_null, /**< Empty (null) node handle. */
110 node_document, /**< A document tree's absolute root. */
111 node_element, /**< Element tag, e.g., `<node/>`. */
112 node_pcdata, /**< Plain character data, e.g., `text`. */
113 node_cdata, /**< Character data, e.g., `<![CDATA[text]]>`. */
114 node_comment, /**< Comment tag, e.g., `<!-- text -->`. */
115 node_pi, /**< Processing instruction, e.g., `<?name?>`. */
116 node_declaration, /**< Document declaration, e.g., `<?xml version="1.0"?>`. */
117 node_doctype /**< Document type declaration, e.g., `<!DOCTYPE doc>`. */
118} XmlNodeType;
119
120
121/**
122 * @interface IXmlNode
123 * @brief Interface for XML nodes.
124 */
125#undef INTERFACE
126#define INTERFACE IXmlNode
127DECLARE_INTERFACE(IXmlNode)
128{
129 /**
130 * @brief Converts the node to a string representation.
131 * @param out Pointer to the output string.
132 */
133 STDMETHOD_(void, ToString)(CTHIS_ IStringW *out) SCONST PURE;
134
135 /**
136 * @brief Gets the private pointer associated with the node.
137 * @return Pointer to private data.
138 */
139 STDMETHOD_(LPVOID, GetPrivPtr)(CTHIS) SCONST PURE;
140
141 /**
142 * @brief Checks if the node is empty.
143 * @return TRUE if the node is empty, FALSE otherwise.
144 */
145 STDMETHOD_(BOOL, Empty)(CTHIS) SCONST PURE;
146
147 /**
148 * @brief Gets the name of the node.
149 * @return The name of the node.
150 */
151 STDMETHOD_(const wchar_t*, Name)(CTHIS) SCONST PURE;
152
153 /**
154 * @brief Gets the value of the node.
155 * @return The value of the node.
156 */
157 STDMETHOD_(const wchar_t*, Value)(CTHIS) SCONST PURE;
158
159 /**
160 * @brief Gets the text content of the node.
161 * @return The text content of the node.
162 */
163 STDMETHOD_(const wchar_t*, Text)(CTHIS) SCONST PURE;
164
165 /**
166 * @brief Sets user-defined data associated with the node.
167 * @param data User-defined data.
168 * @return TRUE if successful, FALSE otherwise.
169 */
170 STDMETHOD_(BOOL, set_userdata)(THIS_ int data) PURE;
171
172 /**
173 * @brief Gets user-defined data associated with the node.
174 * @return User-defined data.
175 */
176 STDMETHOD_(int, get_userdata)(CTHIS) SCONST PURE;
177
178 /**
179 * @brief Gets an attribute by name.
180 * @param name Name of the attribute.
181 * @param bCaseSensitive TRUE if the search is case-sensitive, FALSE otherwise.
182 * @return Pointer to the attribute, or NULL if not found.
183 */
184 STDMETHOD_(IXmlAttr*, Attribute)(CTHIS_ const wchar_t* name, BOOL bCaseSensitive) SCONST PURE;
185
186 /**
187 * @brief Gets the first attribute in the attribute list.
188 * @return Pointer to the first attribute, or NULL if there are no attributes.
189 */
190 STDMETHOD_(IXmlAttr*, FirstAttribute)(CTHIS) SCONST PURE;
191
192 /**
193 * @brief Gets the last attribute in the attribute list.
194 * @return Pointer to the last attribute, or NULL if there are no attributes.
195 */
196 STDMETHOD_(IXmlAttr*, LastAttribute)(CTHIS) SCONST PURE;
197
198 /**
199 * @brief Gets a child node by name.
200 * @param name Name of the child node.
201 * @param bCaseSensitive TRUE if the search is case-sensitive, FALSE otherwise.
202 * @return Pointer to the child node, or NULL if not found.
203 */
204 STDMETHOD_(IXmlNode*, Child)(CTHIS_ const wchar_t* name, BOOL bCaseSensitive) SCONST PURE;
205
206 /**
207 * @brief Gets the first child node.
208 * @return Pointer to the first child node, or NULL if there are no child nodes.
209 */
210 STDMETHOD_(IXmlNode*, FirstChild)(CTHIS) SCONST PURE;
211
212 /**
213 * @brief Gets the last child node.
214 * @return Pointer to the last child node, or NULL if there are no child nodes.
215 */
216 STDMETHOD_(IXmlNode*, LastChild)(CTHIS) SCONST PURE;
217
218 /**
219 * @brief Gets the next sibling node in the children list of the parent node.
220 * @return Pointer to the next sibling node, or NULL if there is no next sibling.
221 */
222 STDMETHOD_(IXmlNode *, NextSibling)(CTHIS) SCONST PURE;
223
224 /**
225 * @brief Gets the previous sibling node in the children list of the parent node.
226 * @return Pointer to the previous sibling node, or NULL if there is no previous sibling.
227 */
228 STDMETHOD_(IXmlNode *, PrevSibling)(CTHIS) SCONST PURE;
229
230 /**
231 * @brief Gets the next sibling node with the specified name.
232 * @param name Name of the sibling node.
233 * @param bCaseSensitive TRUE if the search is case-sensitive, FALSE otherwise.
234 * @return Pointer to the next sibling node with the specified name, or NULL if not found.
235 */
236 STDMETHOD_(IXmlNode *, NextSibling2)(CTHIS_ const wchar_t *name, BOOL bCaseSensitive) SCONST PURE;
237
238 /**
239 * @brief Gets the previous sibling node with the specified name.
240 * @param name Name of the sibling node.
241 * @param bCaseSensitive TRUE if the search is case-sensitive, FALSE otherwise.
242 * @return Pointer to the previous sibling node with the specified name, or NULL if not found.
243 */
244 STDMETHOD_(IXmlNode *, PrevSibling2)(CTHIS_ const wchar_t *name, BOOL bCaseSensitive) SCONST PURE;
245
246 /**
247 * @brief Appends a child node with the specified name.
248 * @param name Name of the child node.
249 * @return Pointer to the newly appended child node.
250 */
251 STDMETHOD_(IXmlNode*, AppendChild)(THIS_ const wchar_t* name) PURE;
252
253 /**
254 * @brief Prepends a child node with the specified name.
255 * @param name Name of the child node.
256 * @return Pointer to the newly prepended child node.
257 */
258 STDMETHOD_(IXmlNode*, PrependChild)(THIS_ const wchar_t* name) PURE;
259
260 /**
261 * @brief Appends a copy of the specified node as a child.
262 * @param proto Pointer to the node to copy.
263 * @return Pointer to the newly appended child node.
264 */
265 STDMETHOD_(IXmlNode*, AppendCopyNode)(THIS_ const IXmlNode* proto) PURE;
266
267 /**
268 * @brief Prepends a copy of the specified node as a child.
269 * @param proto Pointer to the node to copy.
270 * @return Pointer to the newly prepended child node.
271 */
272 STDMETHOD_(IXmlNode*, PrependCopyNode)(THIS_ const IXmlNode* proto) PURE;
273
274 /**
275 * @brief Appends an attribute with the specified name.
276 * @param name Name of the attribute.
277 * @return Pointer to the newly appended attribute.
278 */
279 STDMETHOD_(IXmlAttr*, AppendAttribute)(THIS_ const wchar_t* name) PURE;
280
281 /**
282 * @brief Prepends an attribute with the specified name.
283 * @param name Name of the attribute.
284 * @return Pointer to the newly prepended attribute.
285 */
286 STDMETHOD_(IXmlAttr*, PrependAttribute)(THIS_ const wchar_t* name) PURE;
287
288 /**
289 * @brief Appends a copy of the specified attribute.
290 * @param proto Pointer to the attribute to copy.
291 * @return Pointer to the newly appended attribute.
292 */
293 STDMETHOD_(IXmlAttr*, AppendCopyAttribute)(THIS_ const IXmlAttr* proto) PURE;
294
295 /**
296 * @brief Prepends a copy of the specified attribute.
297 * @param proto Pointer to the attribute to copy.
298 * @return Pointer to the newly prepended attribute.
299 */
300 STDMETHOD_(IXmlAttr*, PrependCopyAttribute)(THIS_ const IXmlAttr* proto) PURE;
301
302 /**
303 * @brief Removes an attribute by name.
304 * @param name Name of the attribute to remove.
305 * @return TRUE if the attribute was removed, FALSE otherwise.
306 */
307 STDMETHOD_(BOOL, RemoveAttribute)(THIS_ const wchar_t* name) PURE;
308
309 /**
310 * @brief Removes a child node by name.
311 * @param name Name of the child node to remove.
312 * @return TRUE if the child node was removed, FALSE otherwise.
313 */
314 STDMETHOD_(BOOL, RemoveChild)(THIS_ const wchar_t* name) PURE;
315
316 /**
317 * @brief Removes all child nodes.
318 * @return TRUE if all child nodes were removed, FALSE otherwise.
319 */
320 STDMETHOD_(BOOL, RemoveAllChilden)(THIS) PURE;
321};
322
323/**
324 * @enum _XmlStatus
325 * @brief Enumerates the possible parsing statuses.
326 */
327typedef enum _XmlStatus
328{
329 xml_ok = 0, /**< No error. */
330 xml_file_not_found, /**< File was not found during load_file(). */
331 xml_io_error, /**< Error reading from file/stream. */
332 xml_out_of_memory, /**< Could not allocate memory. */
333 xml_internal_error, /**< Internal error occurred. */
334 xml_unrecognized_tag, /**< Parser could not determine tag type. */
335 xml_bad_pi, /**< Parsing error occurred while parsing document declaration/processing instruction. */
336 xml_bad_comment, /**< Parsing error occurred while parsing comment. */
337 xml_bad_cdata, /**< Parsing error occurred while parsing CDATA section. */
338 xml_bad_doctype, /**< Parsing error occurred while parsing document type declaration. */
339 xml_bad_pcdata, /**< Parsing error occurred while parsing PCDATA section. */
340 xml_bad_start_element, /**< Parsing error occurred while parsing start element tag. */
341 xml_bad_attribute, /**< Parsing error occurred while parsing element attribute. */
342 xml_bad_end_element, /**< Parsing error occurred while parsing end element tag. */
343 xml_end_element_mismatch, /**< There was a mismatch of start-end tags (closing tag had incorrect name, some tag was not closed or there was an excessive closing tag). */
344 xml_append_invalid_root, /**< Unable to append nodes since root type is not node_element or node_document (exclusive to xml_node::append_buffer). */
345 xml_no_document_element /**< Parsing resulted in a document without element nodes. */
346} XmlStatus;
347
348/**
349 * @enum _XmlEncoding
350 * @brief Enumerates the possible XML encodings.
351 */
352typedef enum _XmlEncoding
353{
354 enc_auto, /**< Auto-detect input encoding using BOM or <? / < detection; use UTF8 if BOM is not found. */
355 enc_utf8, /**< UTF8 encoding. */
356 enc_utf16_le, /**< Little-endian UTF16. */
357 enc_utf16_be, /**< Big-endian UTF16. */
358 enc_utf16, /**< UTF16 with native endianness. */
359 enc_utf32_le, /**< Little-endian UTF32. */
360 enc_utf32_be, /**< Big-endian UTF32. */
361 enc_utf32, /**< UTF32 with native endianness. */
362 enc_wchar, /**< The same encoding wchar_t has (either UTF16 or UTF32). */
363 enc_latin1,
364 enc_bin /**< Binary XML. */
365} XmlEncoding;
366
367/**
368 * @enum _XmlParseOpt
369 * @brief Enumerates the parsing options.
370 */
371typedef enum _XmlParseOpt
372{
373 // Minimal parsing mode (equivalent to turning all other flags off).
374 // Only elements and PCDATA sections are added to the DOM tree, no text conversions are performed.
375 xml_parse_minimal = 0x0000,
376
377 // This flag determines if processing instructions (node_pi) are added to the DOM tree. This flag is off by default.
378 xml_parse_pi = 0x0001,
379
380 // This flag determines if comments (node_comment) are added to the DOM tree. This flag is off by default.
381 xml_parse_comments = 0x0002,
382
383 // This flag determines if CDATA sections (node_cdata) are added to the DOM tree. This flag is on by default.
384 xml_parse_cdata = 0x0004,
385
386 // This flag determines if plain character data (node_pcdata) that consist only of whitespace are added to the DOM tree.
387 // This flag is off by default; turning it on usually results in slower parsing and more memory consumption.
388 xml_parse_ws_pcdata = 0x0008,
389
390 // This flag determines if character and entity references are expanded during parsing. This flag is on by default.
391 xml_parse_escapes = 0x0010,
392
393 // This flag determines if EOL characters are normalized (converted to #xA) during parsing. This flag is on by default.
394 xml_parse_eol = 0x0020,
395
396 // This flag determines if attribute values are normalized using CDATA normalization rules during parsing. This flag is on by default.
397 xml_parse_wconv_attribute = 0x0040,
398
399 // This flag determines if attribute values are normalized using NMTOKENS normalization rules during parsing. This flag is off by default.
400 xml_parse_wnorm_attribute = 0x0080,
401
402 // This flag determines if document declaration (node_declaration) is added to the DOM tree. This flag is off by default.
403 xml_parse_declaration = 0x0100,
404
405 // This flag determines if document type declaration (node_doctype) is added to the DOM tree. This flag is off by default.
406 xml_parse_doctype = 0x0200,
407
408 // This flag determines if plain character data (node_pcdata) that is the only child of the parent node and that consists only
409 // of whitespace is added to the DOM tree.
410 // This flag is off by default; turning it on may result in slower parsing and more memory consumption.
411 xml_parse_ws_pcdata_single = 0x0400,
412
413 // This flag determines if leading and trailing whitespace is to be removed from plain character data. This flag is off by default.
414 xml_parse_trim_pcdata = 0x0800,
415 /**
416 * @brief This flag determines if plain character data that does not have a parent node is added to the DOM tree,
417 * and if an empty document is a valid document. This flag is off by default.
418 */
419 xml_parse_fragment = 0x1000,
420
421 /**
422 * @brief This flag determines if plain character data is stored in the parent element's value. This significantly changes
423 * the structure of the document; this flag is only recommended for parsing documents with many PCDATA nodes in
424 * memory-constrained environments. This flag is off by default.
425 */
426 xml_parse_embed_pcdata = 0x2000,
427
428 /**
429 * @brief The default parsing mode.
430 * Elements, PCDATA, and CDATA sections are added to the DOM tree, character/reference entities are expanded,
431 * End-of-Line characters are normalized, and attribute values are normalized using CDATA normalization rules.
432 */
433 xml_parse_default = xml_parse_cdata | xml_parse_escapes | xml_parse_wconv_attribute | xml_parse_eol,
434
435 /**
436 * @brief The full parsing mode.
437 * Nodes of all types are added to the DOM tree, character/reference entities are expanded,
438 * End-of-Line characters are normalized, and attribute values are normalized using CDATA normalization rules.
439 */
440 xml_parse_full = xml_parse_default | xml_parse_pi | xml_parse_comments | xml_parse_declaration | xml_parse_doctype,
441} XmlParseOpt;
442
443/**
444 * @struct _XmlParseResult
445 * @brief Structure containing the result of XML parsing.
446 */
447typedef struct _XmlParseResult
448{
449 /**
450 * @brief Parsing status (see XmlStatus).
451 */
452 XmlStatus status;
453
454 /**
455 * @brief Last parsed offset (in char_t units from the start of input data).
456 */
457 ptrdiff_t offset;
458
459 /**
460 * @brief Source document encoding.
461 */
462 XmlEncoding encoding;
463} XmlParseResult;
464
465#undef INTERFACE
466#define INTERFACE IXmlDoc
467/**
468 * @interface IXmlDoc
469 * @brief Interface for XML Document.
470 */
471DECLARE_INTERFACE_(IXmlDoc, IObjRef)
472{
473 /**
474 * @brief Adds a reference to the document.
475 * @return The new reference count.
476 */
477 STDMETHOD_(long, AddRef)(THIS) PURE;
478
479 /**
480 * @brief Releases a reference to the document.
481 * @return The new reference count.
482 */
483 STDMETHOD_(long, Release)(THIS) PURE;
484
485 /**
486 * @brief Releases the document object.
487 */
488 STDMETHOD_(void, OnFinalRelease)(THIS) PURE;
489
490 /**
491 * @brief Gets the private pointer associated with the document.
492 * @return Pointer to private data.
493 */
494 STDMETHOD_(LPVOID, GetPrivPtr)(CTHIS) SCONST PURE;
495
496 /**
497 * @brief Resets the document, removing all nodes.
498 */
499 STDMETHOD_(void, Reset)(THIS) PURE;
500
501 /**
502 * @brief Removes all nodes, then copies the entire contents of the specified document.
503 * @param proto Pointer to the document to copy.
504 */
505 STDMETHOD_(void, Copy)(THIS_ const IXmlDoc* proto) PURE;
506
507 /**
508 * @brief Loads the document from a zero-terminated string. No encoding conversions are applied.
509 * @param contents Zero-terminated string containing the XML data.
510 * @param options Parsing options.
511 * @return TRUE if successful, FALSE otherwise.
512 */
513 STDMETHOD_(BOOL, LoadString)(THIS_ const wchar_t* contents, unsigned int options) PURE;
514
515 /**
516 * @brief Loads the document from a file (ANSI version).
517 * @param path Path to the file.
518 * @param options Parsing options.
519 * @param encoding Document encoding.
520 * @return TRUE if successful, FALSE otherwise.
521 */
522 STDMETHOD_(BOOL, LoadFileA)(THIS_ const char* path, unsigned int options, XmlEncoding encoding) PURE;
523
524 /**
525 * @brief Loads the document from a file (Unicode version).
526 * @param path Path to the file.
527 * @param options Parsing options.
528 * @param encoding Document encoding.
529 * @return TRUE if successful, FALSE otherwise.
530 */
531 STDMETHOD_(BOOL, LoadFileW)(THIS_ const wchar_t* path, unsigned int options, XmlEncoding encoding) PURE;
532
533 /**
534 * @brief Loads the document from a buffer. Copies/converts the buffer, so it may be deleted or changed after the function returns.
535 * @param contents Pointer to the buffer containing the XML data.
536 * @param size Size of the buffer.
537 * @param options Parsing options.
538 * @param encoding Document encoding.
539 * @return TRUE if successful, FALSE otherwise.
540 */
541 STDMETHOD_(BOOL, LoadBuffer)(THIS_ const void* contents, size_t size, unsigned int options, XmlEncoding encoding) PURE;
542
543 /**
544 * @brief Loads the document from a buffer, using the buffer for in-place parsing (the buffer is modified and used for storage of document data).
545 * You should ensure that buffer data will persist throughout the document's lifetime, and free the buffer memory manually once the document is destroyed.
546 * @param contents Pointer to the buffer containing the XML data.
547 * @param size Size of the buffer.
548 * @param options Parsing options.
549 * @param encoding Document encoding.
550 * @return TRUE if successful, FALSE otherwise.
551 */
552 STDMETHOD_(BOOL, LoadBufferInplace)(THIS_ void* contents, size_t size, unsigned int options, XmlEncoding encoding) PURE;
553
554 /**
555 * @brief Loads the document from a buffer, using the buffer for in-place parsing (the buffer is modified and used for storage of document data).
556 * You should allocate the buffer with pugixml allocation function; the document will free the buffer when it is no longer needed (you can't use it anymore).
557 * @param contents Pointer to the buffer containing the XML data.
558 * @param size Size of the buffer.
559 * @param options Parsing options.
560 * @param encoding Document encoding.
561 * @return TRUE if successful, FALSE otherwise.
562 */
563 STDMETHOD_(BOOL, LoadBufferInplaceOwn)(THIS_ void* contents, size_t size, unsigned int options, XmlEncoding encoding) PURE;
564
565 /**
566 * @brief Gets the parsing result.
567 * @param pResult Pointer to the XmlParseResult structure to store the result.
568 */
569 STDMETHOD_(void, GetParseResult)(CTHIS_ XmlParseResult *pResult) SCONST PURE;
570
571 /**
572 * @brief Saves the XML document to a writer (semantics is slightly different from xml_node::print, see documentation for details).
573 * @param f Pointer to the file stream.
574 */
575 STDMETHOD_(void, SaveBinary)(CTHIS_ FILE *f) SCONST PURE;
576
577 /**
578 * @brief Saves the XML document to a file (ANSI version).
579 * @param path Path to the file.
580 * @param indent Indentation string.
581 * @param flags Saving flags.
582 * @param encoding Document encoding.
583 * @return TRUE if successful, FALSE otherwise.
584 */
585 STDMETHOD_(BOOL, SaveFileA)(CTHIS_ const char* path, const wchar_t* indent, unsigned int flags, XmlEncoding encoding) SCONST PURE;
586
587 /**
588 * @brief Saves the XML document to a file (Unicode version).
589 * @param path Path to the file.
590 * @param indent Indentation string.
591 * @param flags Saving flags.
592 * @param encoding Document encoding.
593 * @return TRUE if successful, FALSE otherwise.
594 */
595 STDMETHOD_(BOOL, SaveFileW)(CTHIS_ const wchar_t* path, const wchar_t* indent, unsigned int flags, XmlEncoding encoding) SCONST PURE;
596
597 /**
598 * @brief Gets the document element (root node).
599 * @return Pointer to the root node.
600 */
601 STDMETHOD_(IXmlNode *, Root)(CTHIS) SCONST PURE;
602};
603
604SNSEND
605
606#ifdef __cplusplus
607typedef SOUI::IXmlDoc * IXmlDocPtr;
608#else
609typedef IXmlDoc * IXmlDocPtr;
610#endif
611
612#endif // __SXML_I__H__
Structure containing the result of XML parsing.
Definition sxml-i.h:448
XmlStatus status
Parsing status (see XmlStatus).
Definition sxml-i.h:452
ptrdiff_t offset
Last parsed offset (in char_t units from the start of input data).
Definition sxml-i.h:457
XmlEncoding encoding
Source document encoding.
Definition sxml-i.h:462
Interface for reference counting.
Definition obj-ref-i.h:19
Interface for XML attributes.
Definition sxml-i.h:17
double AsDouble(double def=0.0) PURE
Converts the attribute value to a double.
IXmlAttr * Prev() PURE
Gets the previous attribute in the attribute list of the parent node.
BOOL Empty() SCONST PURE
Checks if the attribute is empty.
LPVOID GetPrivPtr() SCONST PURE
Gets the private pointer associated with the attribute.
IXmlAttr * Next() PURE
Gets the next attribute in the attribute list of the parent node.
int AsInt(int def=0) PURE
Converts the attribute value to an integer.
unsigned int AsUint(int def=0) PURE
Converts the attribute value to an unsigned integer.
int get_userdata() SCONST PURE
Gets user-defined data associated with the attribute.
const wchar_t * Value() SCONST PURE
Gets the value of the attribute.
const wchar_t * Name() SCONST PURE
Gets the name of the attribute.
BOOL AsBool(BOOL def=FALSE) PURE
Converts the attribute value to a boolean.
float AsFloat(float def=0.0f) PURE
Converts the attribute value to a float.
BOOL set_userdata(int data) PURE
Sets user-defined data associated with the attribute.
Interface for XML Document.
Definition sxml-i.h:472
BOOL SaveFileW(const wchar_t *path, const wchar_t *indent, unsigned int flags, XmlEncoding encoding) SCONST PURE
Saves the XML document to a file (Unicode version).
void Copy(const IXmlDoc *proto) PURE
Removes all nodes, then copies the entire contents of the specified document.
void GetParseResult(XmlParseResult *pResult) SCONST PURE
Gets the parsing result.
BOOL SaveFileA(const char *path, const wchar_t *indent, unsigned int flags, XmlEncoding encoding) SCONST PURE
Saves the XML document to a file (ANSI version).
void SaveBinary(FILE *f) SCONST PURE
Saves the XML document to a writer (semantics is slightly different from xml_node::print,...
void Reset() PURE
Resets the document, removing all nodes.
void OnFinalRelease() PURE
Releases the document object.
BOOL LoadBufferInplace(void *contents, size_t size, unsigned int options, XmlEncoding encoding) PURE
Loads the document from a buffer, using the buffer for in-place parsing (the buffer is modified and u...
BOOL LoadFileA(const char *path, unsigned int options, XmlEncoding encoding) PURE
Loads the document from a file (ANSI version).
long AddRef() PURE
Adds a reference to the document.
BOOL LoadFileW(const wchar_t *path, unsigned int options, XmlEncoding encoding) PURE
Loads the document from a file (Unicode version).
IXmlNode * Root() SCONST PURE
Gets the document element (root node).
BOOL LoadString(const wchar_t *contents, unsigned int options) PURE
Loads the document from a zero-terminated string. No encoding conversions are applied.
LPVOID GetPrivPtr() SCONST PURE
Gets the private pointer associated with the document.
BOOL LoadBuffer(const void *contents, size_t size, unsigned int options, XmlEncoding encoding) PURE
Loads the document from a buffer. Copies/converts the buffer, so it may be deleted or changed after t...
long Release() PURE
Releases a reference to the document.
BOOL LoadBufferInplaceOwn(void *contents, size_t size, unsigned int options, XmlEncoding encoding) PURE
Loads the document from a buffer, using the buffer for in-place parsing (the buffer is modified and u...
Interface for XML nodes.
Definition sxml-i.h:128
IXmlAttr * PrependCopyAttribute(const IXmlAttr *proto) PURE
Prepends a copy of the specified attribute.
const wchar_t * Name() SCONST PURE
Gets the name of the node.
BOOL RemoveAttribute(const wchar_t *name) PURE
Removes an attribute by name.
BOOL set_userdata(int data) PURE
Sets user-defined data associated with the node.
IXmlAttr * FirstAttribute() SCONST PURE
Gets the first attribute in the attribute list.
BOOL Empty() SCONST PURE
Checks if the node is empty.
BOOL RemoveChild(const wchar_t *name) PURE
Removes a child node by name.
LPVOID GetPrivPtr() SCONST PURE
Gets the private pointer associated with the node.
BOOL RemoveAllChilden() PURE
Removes all child nodes.
IXmlNode * FirstChild() SCONST PURE
Gets the first child node.
IXmlAttr * AppendCopyAttribute(const IXmlAttr *proto) PURE
Appends a copy of the specified attribute.
IXmlNode * LastChild() SCONST PURE
Gets the last child node.
IXmlNode * AppendCopyNode(const IXmlNode *proto) PURE
Appends a copy of the specified node as a child.
IXmlNode * Child(const wchar_t *name, BOOL bCaseSensitive) SCONST PURE
Gets a child node by name.
IXmlNode * AppendChild(const wchar_t *name) PURE
Appends a child node with the specified name.
const wchar_t * Value() SCONST PURE
Gets the value of the node.
IXmlAttr * AppendAttribute(const wchar_t *name) PURE
Appends an attribute with the specified name.
IXmlAttr * Attribute(const wchar_t *name, BOOL bCaseSensitive) SCONST PURE
Gets an attribute by name.
IXmlAttr * PrependAttribute(const wchar_t *name) PURE
Prepends an attribute with the specified name.
IXmlAttr * LastAttribute() SCONST PURE
Gets the last attribute in the attribute list.
IXmlNode * NextSibling2(const wchar_t *name, BOOL bCaseSensitive) SCONST PURE
Gets the next sibling node with the specified name.
IXmlNode * PrependCopyNode(const IXmlNode *proto) PURE
Prepends a copy of the specified node as a child.
const wchar_t * Text() SCONST PURE
Gets the text content of the node.
IXmlNode * NextSibling() SCONST PURE
Gets the next sibling node in the children list of the parent node.
IXmlNode * PrependChild(const wchar_t *name) PURE
Prepends a child node with the specified name.
IXmlNode * PrevSibling() SCONST PURE
Gets the previous sibling node in the children list of the parent node.
void ToString(IStringW *out) SCONST PURE
Converts the node to a string representation.
int get_userdata() SCONST PURE
Gets user-defined data associated with the node.
IXmlNode * PrevSibling2(const wchar_t *name, BOOL bCaseSensitive) SCONST PURE
Gets the previous sibling node with the specified name.