replicode
xml_parser.h
Go to the documentation of this file.
1 
38 #ifndef __INCLUDE_XML_NODE__
39 #define __INCLUDE_XML_NODE__
40 
41 #include <stdlib.h>
42 
43 #ifdef _UNICODE
44 // If you comment the next "define" line then the library will never "switch to" _UNICODE (wchar_t*) mode (16/32 bits per characters).
45 // This is useful when you get error messages like:
46 // 'XMLNode::openFileHelper' : cannot convert parameter 2 from 'const char [5]' to 'const wchar_t *'
47 // The _XMLWIDECHAR preprocessor variable force the XMLParser library into either utf16/32-mode (the proprocessor variable
48 // must be defined) or utf8-mode(the pre-processor variable must be undefined).
49 #define _XMLWIDECHAR
50 #endif
51 
52 #if defined(WIN32) || defined(UNDER_CE)
53 // comment the next line if you are under windows and the compiler is not Microsoft Visual Studio (6.0 or .NET)
54 #define _XMLWINDOWS
55 #endif
56 
57 #define _USE_XMLPARSER_DLL
58 
59 #ifdef XMLDLLENTRY
60 #undef XMLDLLENTRY
61 #endif
62 #ifdef _USE_XMLPARSER_DLL
63 #ifdef CORELIBRARY_EXPORTS
64 #define XMLDLLENTRY __declspec(dllexport)
65 #else
66 #define XMLDLLENTRY __declspec(dllimport)
67 #endif
68 #else
69 #define XMLDLLENTRY
70 #endif
71 
72 // uncomment the next line if you want no support for wchar_t* (no need for the <wchar.h> or <tchar.h> libraries anymore to compile)
73 //#define XML_NO_WIDE_CHAR
74 
75 #ifdef XML_NO_WIDE_CHAR
76 #undef _XMLWINDOWS
77 #undef _XMLWIDECHAR
78 #endif
79 
80 #ifdef _XMLWINDOWS
81 #include <tchar.h>
82 #else
83 #undef XMLDLLENTRY
84 #define XMLDLLENTRY
85 #ifndef XML_NO_WIDE_CHAR
86 #include <wchar.h> // to have 'wcsrtombs' for ANSI version
87 // to have 'mbsrtowcs' for WIDECHAR version
88 #endif
89 #endif
90 
91 // Some common types for char set portable code
92 #ifdef _XMLWIDECHAR
93 #ifndef _X
94 #define _X(c) L ## c
95 #endif
96 #define XMLCSTR const wchar_t *
97 #define XMLSTR wchar_t *
98 #define XMLCHAR wchar_t
99 #else
100 #ifndef _X
101 #define _X(c) c
102 #endif
103 #define XMLCSTR const char *
104 #define XMLSTR char *
105 #define XMLCHAR char
106 #endif
107 #ifndef FALSE
108 #define FALSE 0
109 #endif /* FALSE */
110 #ifndef TRUE
111 #define TRUE 1
112 #endif /* TRUE */
113 
114 namespace core
115 {
116 // Enumeration for XML parse errors.
117 typedef enum XMLError {
134 
139 } XMLError;
140 
141 
142 // Enumeration used to manage type of data. Use in conjunction with structure XMLNodeContents
143 typedef enum XMLElementType {
150 
151 // Structure used to obtain error details if the parse fails.
152 typedef struct XMLResults {
155 } XMLResults;
156 
157 // Structure for XML clear (unformatted) node (usually comments)
158 typedef struct XMLClear {
162 } XMLClear;
163 
164 // Structure for XML attribute.
165 typedef struct XMLAttribute {
168 } XMLAttribute;
169 
170 struct XMLNodeContents;
171 
172 typedef struct XMLDLLENTRY XMLNode {
173 private:
174 
175  struct XMLNodeDataTag;
176 
177  // protected constructors: use one of these four methods to get your first instance of XMLNode:
178  // - parseString
179  // - parseFile
180  // - openFileHelper
181  // - createXMLTopNode
182  XMLNode(struct XMLNodeDataTag *pParent, XMLSTR lpszName, char isDeclaration);
183  XMLNode(struct XMLNodeDataTag *p);
184 
185 public:
186 
187  // You can create your first instance of XMLNode with these 4 functions:
188  // (see complete explanation of parameters below)
189 
190  static XMLNode createXMLTopNode(XMLCSTR lpszName, char isDeclaration = FALSE);
191  static XMLNode parseString(XMLCSTR lpXMLString, XMLCSTR tag = NULL, XMLResults *pResults = NULL);
192  static XMLNode parseFile(XMLCSTR filename, XMLCSTR tag = NULL, XMLResults *pResults = NULL);
193  static XMLNode openFileHelper(XMLCSTR filename, XMLCSTR tag = NULL);
194 
195  // The tag parameter should be the name of the first tag inside the XML file.
196  // If the tag parameter is omitted, the 3 functions return a node that represents
197  // the head of the xml document including the declaration term (<? ... ?>).
198 
199  // The "openFileHelper" reports to the screen all the warnings & errors that occurred during
200  // parsing of the XML file. Since each application has its own way to report and deal with errors,
201  // you should rather use the "parseFile" function to parse XML files and program yourself thereafter
202  // an "error reporting" tailored for your needs (instead of using the very crude "error reporting"
203  // mechanism included inside the "openFileHelper" function).
204 
205  // If the XML document is corrupted:
206  // * The "openFileHelper" method will:
207  // - display an error message on the console (or inside a messageBox for windows).
208  // - stop execution (exit).
209  // I suggest that you write your own "openFileHelper" method tailored to your needs.
210  // * The 2 other methods will initialize the "pResults" variable with some information that
211  // can be used to trace the error.
212  // * If you still want to parse the file, you can use the APPROXIMATE_PARSING option as
213  // explained inside the note at the beginning of the "xmlParser.cpp" file.
214  // You can have a user-friendly explanation of the parsing error with this function:
215  static XMLCSTR getError(XMLError error);
216  static XMLCSTR getVersion();
217 
218  XMLCSTR getName() const; // name of the node
219  XMLCSTR getText(int i = 0) const; // return ith text field
220  int nText() const; // nbr of text field
221  XMLNode getParentNode() const; // return the parent node
222  XMLNode getChildNode(int i = 0) const; // return ith child node
223  XMLNode getChildNode(XMLCSTR name, int i) const; // return ith child node with specific name
224  // (return an empty node if failing)
225  XMLNode getChildNode(XMLCSTR name, int *i = NULL) const; // return next child node with specific name
226  // (return an empty node if failing)
227  XMLNode getChildNodeWithAttribute(XMLCSTR tagName, // return child node with specific name/attribute
228  XMLCSTR attributeName, // (return an empty node if failing)
229  XMLCSTR attributeValue = NULL, //
230  int *i = NULL) const; //
231  int nChildNode(XMLCSTR name) const; // return the number of child node with specific name
232  int nChildNode() const; // nbr of child node
233  XMLAttribute getAttribute(int i = 0) const; // return ith attribute
234  XMLCSTR getAttributeName(int i = 0) const; // return ith attribute name
235  XMLCSTR getAttributeValue(int i = 0) const; // return ith attribute value
236  char isAttributeSet(XMLCSTR name) const; // test if an attribute with a specific name is given
237  XMLCSTR getAttribute(XMLCSTR name, int i) const; // return ith attribute content with specific name
238  // (return a NULL if failing)
239  XMLCSTR getAttribute(XMLCSTR name, int *i = NULL) const; // return next attribute content with specific name
240  // (return a NULL if failing)
241  int nAttribute() const; // nbr of attribute
242  XMLClear getClear(int i = 0) const; // return ith clear field (comments)
243  int nClear() const; // nbr of clear field
244  XMLSTR createXMLString(int nFormat = 1, int *pnSize = NULL) const; // create XML string starting from current XMLNode
245  // if nFormat==0, no formatting is required
246  // otherwise this returns an user friendly XML string from a
247  // given element with appropriate white spaces and carriage returns.
248  // if pnSize is given it returns the size in character of the string.
249  XMLError writeToFile(XMLCSTR filename, const char *encoding = NULL, char nFormat = 1) const;
250  // Save the content of an xmlNode inside a file.
251  // The nFormat parameter has the same meaning as in the
252  // createXMLString function. If the global parameter
253  // "characterEncoding==encoding_UTF8", then the "encoding" parameter is
254  // ignored and always set to "utf-8". If the global parameter
255  // "characterEncoding==encoding_ShiftJIS", then the "encoding" parameter
256  // is ignored and always set to "SHIFT-JIS". If "_XMLWIDECHAR=1", then
257  // the "encoding" parameter is ignored and always set to "utf-16".
258  // If no "encoding" parameter is given the "ISO-8859-1" encoding is used.
259  XMLNodeContents enumContents(int i) const; // enumerate all the different contents (attribute,child,text,
260  // clear) of the current XMLNode. The order is reflecting
261  // the order of the original file/string.
262  // NOTE: 0 <= i < nElement();
263  int nElement() const; // nbr of different contents for current node
264  char isEmpty() const; // is this node Empty?
265  char isDeclaration() const; // is this node a declaration <? .... ?>
266  static XMLNode emptyNode(); // return XMLNode::emptyXMLNode;
267 
268 #pragma warning(disable: 4800) // warning: forcing value to bool
269  bool operator !()
270  {
271  return isEmpty();
272  }
273 
274 // to allow shallow/fast copy:
275  ~XMLNode();
276  XMLNode(const XMLNode &A);
277  XMLNode &operator=(const XMLNode &A);
278 
279  XMLNode(): d(NULL) {};
280  static XMLNode emptyXMLNode;
283 
284  // The following functions allows you to create from scratch (or update) a XMLNode structure
285  // Start by creating your top node with the "createXMLTopNode" function and then add new nodes with the "addChild" function.
286  // The parameter 'pos' gives the position where the childNode, the text or the XMLClearTag will be inserted.
287  // The default value (pos=-1) inserts at the end. The value (pos=0) insert at the beginning (Insertion at the beginning is slower than at the end).
288  // REMARK: 0 <= pos < nChild()+nText()+nClear()
289  XMLNode addChild(XMLCSTR lpszName, char isDeclaration = FALSE, int pos = -1);
290  XMLAttribute *addAttribute(XMLCSTR lpszName, XMLCSTR lpszValuev);
291  XMLCSTR addText(XMLCSTR lpszValue, int pos = -1);
292  XMLClear *addClear(XMLCSTR lpszValue, XMLCSTR lpszOpen = NULL, XMLCSTR lpszClose = NULL, int pos = -1);
293  // default values: lpszOpen ="<![CDATA["
294  // lpszClose="]]>"
295  XMLNode addChild(XMLNode nodeToAdd, int pos = -1); // If the "nodeToAdd" has some parents, it will be detached
296  // from it's parents before being attached to the current XMLNode
297  // Some update functions:
298  XMLCSTR updateName(XMLCSTR lpszName); // change node's name
299  XMLAttribute *updateAttribute(XMLAttribute *newAttribute, XMLAttribute *oldAttribute); // if the attribute to update is missing, a new one will be added
300  XMLAttribute *updateAttribute(XMLCSTR lpszNewValue, XMLCSTR lpszNewName = NULL, int i = 0); // if the attribute to update is missing, a new one will be added
301  XMLAttribute *updateAttribute(XMLCSTR lpszNewValue, XMLCSTR lpszNewName, XMLCSTR lpszOldName); // set lpszNewName=NULL if you don't want to change the name of the attribute
302  // if the attribute to update is missing, a new one will be added
303  XMLCSTR updateText(XMLCSTR lpszNewValue, int i = 0); // if the text to update is missing, a new one will be added
304  XMLCSTR updateText(XMLCSTR lpszNewValue, XMLCSTR lpszOldValue); // if the text to update is missing, a new one will be added
305  XMLClear *updateClear(XMLCSTR lpszNewContent, int i = 0); // if the clearTag to update is missing, a new one will be added
306  XMLClear *updateClear(XMLClear *newP, XMLClear *oldP); // if the clearTag to update is missing, a new one will be added
307  XMLClear *updateClear(XMLCSTR lpszNewValue, XMLCSTR lpszOldValue); // if the clearTag to update is missing, a new one will be added
308 
309  // Some deletion functions:
310  void deleteNodeContent(); // delete the content of this XMLNode and the subtree.
311  void deleteAttribute(XMLCSTR lpszName);
312  void deleteAttribute(int i = 0);
313  void deleteAttribute(XMLAttribute *anAttribute);
314  void deleteText(int i = 0);
315  void deleteText(XMLCSTR lpszValue);
316  void deleteClear(int i = 0);
317  void deleteClear(XMLClear *p);
318  void deleteClear(XMLCSTR lpszValue);
319 
320  // The strings given as parameters for the following add and update methods (all these methods have
321  // a name with the postfix "_WOSD" that means "WithOut String Duplication" ) will be free'd by the
322  // XMLNode class. For example, it means that this is incorrect:
323  // xNode.addText_WOSD("foo");
324  // xNode.updateAttribute_WOSD("#newcolor" ,NULL,"color");
325  // In opposition, this is correct:
326  // xNode.addText("foo");
327  // xNode.addText_WOSD(stringDup("foo"));
328  // xNode.updateAttribute("#newcolor" ,NULL,"color");
329  // xNode.updateAttribute_WOSD(stringDup("#newcolor"),NULL,"color");
330  // Typically, you will never do:
331  // char *b=(char*)malloc(...);
332  // xNode.addText(b);
333  // free(b);
334  // ... but rather:
335  // char *b=(char*)malloc(...);
336  // xNode.addText_WOSD(b);
337  // ('free(b)' is performed by the XMLNode class)
338 
339  static XMLNode createXMLTopNode_WOSD(XMLSTR lpszName, char isDeclaration = FALSE);
340  XMLNode addChild_WOSD(XMLSTR lpszName, char isDeclaration = FALSE, int pos = -1);
341  XMLAttribute *addAttribute_WOSD(XMLSTR lpszName, XMLSTR lpszValue);
342  XMLCSTR addText_WOSD(XMLSTR lpszValue, int pos = -1);
343  XMLClear *addClear_WOSD(XMLSTR lpszValue, XMLCSTR lpszOpen = NULL, XMLCSTR lpszClose = NULL, int pos = -1);
344 
345  XMLCSTR updateName_WOSD(XMLSTR lpszName);
346  XMLAttribute *updateAttribute_WOSD(XMLAttribute *newAttribute, XMLAttribute *oldAttribute);
347  XMLAttribute *updateAttribute_WOSD(XMLSTR lpszNewValue, XMLSTR lpszNewName = NULL, int i = 0);
348  XMLAttribute *updateAttribute_WOSD(XMLSTR lpszNewValue, XMLSTR lpszNewName, XMLCSTR lpszOldName);
349  XMLCSTR updateText_WOSD(XMLSTR lpszNewValue, int i = 0);
350  XMLCSTR updateText_WOSD(XMLSTR lpszNewValue, XMLCSTR lpszOldValue);
351  XMLClear *updateClear_WOSD(XMLSTR lpszNewContent, int i = 0);
352  XMLClear *updateClear_WOSD(XMLClear *newP, XMLClear *oldP);
353  XMLClear *updateClear_WOSD(XMLSTR lpszNewValue, XMLCSTR lpszOldValue);
354 
355  // These are some useful functions when you want to insert a childNode, a text or a XMLClearTag in the
356  // middle (at a specified position) of a XMLNode tree already constructed. The value returned by these
357  // methods is to be used as last parameter (parameter 'pos') of addChild, addText or addClear.
358  int positionOfText(int i = 0) const;
359  int positionOfText(XMLCSTR lpszValue) const;
360  int positionOfClear(int i = 0) const;
361  int positionOfClear(XMLCSTR lpszValue) const;
362  int positionOfClear(XMLClear *a) const;
363  int positionOfChildNode(int i = 0) const;
364  int positionOfChildNode(XMLNode x) const;
365  int positionOfChildNode(XMLCSTR name, int i = 0) const; // return the position of the ith childNode with the specified name
366  // if (name==NULL) return the position of the ith childNode
367 
368  // The setGlobalOptions function allows you to change tree global parameters that affect string&file
369  // parsing. First of all, you most-probably will never have to change these 3 global parameters.
370  // The return value of the setGlobalOptions function is "0" when there are no errors. If you try to
371  // set an unrecognized encoding then the return value will be "1" to signal an error.
372  //
373  // About the "guessWideCharChars" parameter:
374  // If "guessWideCharChars=1" and if this library is compiled in WideChar mode, then the
375  // "parseFile" and "openFileHelper" functions will test if the file contains ASCII
376  // characters. If this is the case, then the file will be loaded and converted in memory to
377  // WideChar before being parsed. If "guessWideCharChars=0", no conversion will
378  // be performed.
379  //
380  // If "guessWideCharChars=1" and if this library is compiled in ASCII/UTF8/char* mode, then the
381  // "parseFile" and "openFileHelper" functions will test if the file contains WideChar
382  // characters. If this is the case, then the file will be loaded and converted in memory to
383  // ASCII/UTF8/char* before being parsed. If "guessWideCharChars=0", no conversion will
384  // be performed
385  //
386  // Sometime, it's useful to set "guessWideCharChars=0" to disable any conversion
387  // because the test to detect the file-type (ASCII/UTF8/char* or WideChar) may fail (rarely).
388  //
389  // About the "characterEncoding" parameter:
390  // This parameter is only meaningful when compiling in char* mode (multibyte character mode).
391  // In wchar_t* (wide char mode), this parameter is ignored. This parameter should be one of the
392  // three currently recognized encodings: XMLNode::encoding_UTF8, XMLNode::encoding_ascii,
393  // XMLNode::encoding_ShiftJIS.
394  //
395  // About the "dropWhiteSpace" parameter:
396  // In most situations, text fields containing only white spaces (and carriage returns)
397  // are useless. Even more, these "empty" text fields are annoying because they increase the
398  // complexity of the user's code for parsing. So, 99% of the time, it's better to drop
399  // the "empty" text fields. However The XML specification indicates that no white spaces
400  // should be lost when parsing the file. So to be perfectly XML-compliant, you should set
401  // dropWhiteSpace=0. A note of caution: if you set "dropWhiteSpace=0", the parser will be
402  // slower and your code will be more complex.
403 
404  // Enumeration for XML character encoding.
405  typedef enum XMLCharEncoding { encoding_UTF8 = 1, encoding_ascii = 2, encoding_ShiftJIS = 3 } XMLCharEncoding;
406 
407  static char setGlobalOptions(XMLCharEncoding characterEncoding = XMLNode::encoding_UTF8, char guessWideCharChars = 1, char dropWhiteSpace = 1);
408 
409  // The next function try to guess the character encoding. You most-probably will never
410  // have to use this function. It then returns the appropriate value of the global parameter
411  // "characterEncoding" described above. The guess is based on the content of a buffer of length
412  // "bufLen" bytes that contains the first bytes (minimum 25 bytes; 200 bytes is a good value) of the
413  // file to be parsed. The "openFileHelper" function is using this function to automatically compute
414  // the value of the "characterEncoding" global parameter. There are several heuristics used to do the
415  // guess. One of the heuristic is based on the "encoding" attribute. The original XML specifications
416  // forbids to use this attribute to do the guess but you can still use it if you set
417  // "useXMLEncodingAttribute" to 1 (this is the default behavior and the behavior of most parsers).
418  // If an inconsistency in the encoding is detected, then the return value is "0".
419 
420  static XMLCharEncoding guessCharEncoding(void *buffer, int bufLen, char useXMLEncodingAttribute = 1);
421 
422 private:
423 
424 // these are functions and structures used internally by the XMLNode class (don't bother about them):
425 
426  typedef struct XMLNodeDataTag { // to allow shallow copy and "intelligent/smart" pointers (automatic delete):
427  XMLCSTR lpszName; // Element name (=NULL if root)
428  int nChild, // Number of child nodes
429  nText, // Number of text fields
430  nClear, // Number of Clear fields (comments)
431  nAttribute; // Number of attributes
432  char isDeclaration; // Whether node is an XML declaration - '<?xml ?>'
433  struct XMLNodeDataTag *pParent; // Pointer to parent element (=NULL if root)
434  XMLNode *pChild; // Array of child nodes
435  XMLCSTR *pText; // Array of text fields
436  XMLClear *pClear; // Array of clear fields
437  XMLAttribute *pAttribute; // Array of attributes
438  int *pOrder; // order of the child_nodes,text_fields,clear_fields
439  int ref_count; // for garbage collection (smart pointers)
440  } XMLNodeData;
442 
443  char parseClearTag(void *px, void *pa);
444  char maybeAddTxT(void *pa, XMLCSTR tokenPStr);
445  int ParseXMLElement(void *pXML);
446  void *addToOrder(int memInc, int *_pos, int nc, void *p, int size, XMLElementType xtype);
447  int indexText(XMLCSTR lpszValue) const;
448  int indexClear(XMLCSTR lpszValue) const;
449  XMLNode addChild_priv(int, XMLSTR, char, int);
450  XMLAttribute *addAttribute_priv(int, XMLSTR, XMLSTR);
451  XMLCSTR addText_priv(int, XMLSTR, int);
452  XMLClear *addClear_priv(int, XMLSTR, XMLCSTR, XMLCSTR, int);
453  void deleteNodeContent_priv(char, char);
454  static inline int findPosition(XMLNodeData *d, int index, XMLElementType xtype);
455  static int CreateXMLStringR(XMLNodeData *pEntry, XMLSTR lpszMarker, int nFormat);
456  static int removeOrderElement(XMLNodeData *d, XMLElementType t, int index);
457  static void exactMemory(XMLNodeData *d);
458  static int detachFromParent(XMLNodeData *d);
459 } XMLNode;
460 
461 // This structure is given by the function "enumContents".
462 typedef struct XMLNodeContents {
463  // This dictates what's the content of the XMLNodeContent
465  // should be an union to access the appropriate data.
466  // compiler does not allow union of object with constructor... too bad.
471 
473 
474 XMLDLLENTRY void freeXMLString(XMLSTR t); // {free(t);}
475 
476 // Duplicate (copy in a new allocated buffer) the source string. This is
477 // a very handy function when used with all the "XMLNode::*_WOSD" functions.
478 // (If (cbData!=0) then cbData is the number of chars to duplicate)
479 XMLDLLENTRY XMLSTR stringDup(XMLCSTR source, int cbData = 0);
480 
481 // The following class is processing strings so that all the characters
482 // &,",',<,> are replaced by their XML equivalent: &amp;, &quot;, &apos;, &lt;, &gt;.
483 // This class is useful when creating from scratch an XML file using the
484 // "printf", "fprintf", "cout",... functions. If you are creating from scratch an
485 // XML file using the provided XMLNode class you must not use the "ToXMLStringTool"
486 // class (the "XMLNode" class does the processing job for you during rendering).
487 // Using the "ToXMLStringTool class" and the "fprintf function" is THE most efficient
488 // way to produce VERY large XML documents VERY fast.
489 typedef struct XMLDLLENTRY ToXMLStringTool {
490 public:
491  ToXMLStringTool(): buf(NULL), buflen(0) {}
492  ~ToXMLStringTool();
493  void freeBuffer();
494 
495  XMLSTR toXML(XMLCSTR source);
496 
497  // The next function is deprecated because there is a possibility of
498  // "destination-buffer-overflow". It converts the string
499  // "source" to the string "dest".
500  static XMLSTR toXMLUnSafe(XMLSTR dest, XMLCSTR source);
501 
502 private:
504  int buflen;
506 
507 // Below is a class that allows you to include any binary data (images, sounds,...)
508 // into an XML document using "Base64 encoding". This class is completely
509 // separated from the rest of the xmlParser library and can be removed without any problem.
510 // To include some binary data into an XML file, you must convert the binary data into
511 // standard text (using "encode"). To retrieve the original binary data from the
512 // b64-encoded text included inside the XML file use "decode". Alternatively, these
513 // functions can also be used to "encrypt/decrypt" some critical data contained inside
514 // the XML (it's not a strong encryption at all, but sometimes it can be useful).
515 
517 public:
518  XMLParserBase64Tool(): buf(NULL), buflen(0) {}
520  void freeBuffer();
521 
522  // returns the length of the base64 string that encodes a data buffer of size inBufLen bytes.
523  // If "formatted" parameter is true, some space will be reserved for a carriage-return every 72 chars.
524  static int encodeLength(int inBufLen, char formatted = 0);
525 
526  // The "base64Encode" function returns a string containing the base64 encoding of "inByteLen" bytes
527  // from "inByteBuf". If "formatted" parameter is true, then there will be a carriage-return every 72 chars.
528  // The string will be free'd when the XMLParserBase64Tool object is deleted.
529  // All returned strings are sharing the same memory space.
530  XMLSTR encode(unsigned char *inByteBuf, unsigned int inByteLen, char formatted = 0);
531 
532  // returns the number of bytes which will be decoded from "inString".
533  static unsigned int decodeSize(XMLCSTR inString, XMLError *xe = NULL);
534 
535  // returns a pointer to a buffer containing the binary data decoded from "inString"
536  // If "inString" is malformed NULL will be returned
537  // The output buffer will be free'd when the XMLParserBase64Tool object is deleted.
538  // All output buffer are sharing the same memory space.
539  unsigned char *decode(XMLCSTR inString, int *outByteLen = NULL, XMLError *xe = NULL);
540 
541  // The next function is deprecated.
542  // decodes data from "inString" to "outByteBuf". You need to provide the size (in byte) of "outByteBuf"
543  // in "inMaxByteOutBuflen". If "outByteBuf" is not large enough or if data is malformed, then "FALSE"
544  // will be returned; otherwise "TRUE".
545  static unsigned char decode(XMLCSTR inString, unsigned char *outByteBuf, int inMaxByteOutBuflen, XMLError *xe = NULL);
546 
547 private:
548  void *buf;
549  int buflen;
550  void alloc(int newsize);
552 }
553 #undef XMLDLLENTRY
554 
555 #endif
Definition: xml_parser.h:138
Definition: xml_parser.h:128
static char dropWhiteSpace
Definition: xml_parser.cpp:107
Definition: xml_parser.h:144
XMLCSTR lpszValue
Definition: xml_parser.h:167
ToXMLStringTool()
Definition: xml_parser.h:491
int buflen
Definition: xml_parser.h:549
Definition: xml_parser.h:165
XMLCSTR lpszOpenTag
Definition: xml_parser.h:160
XMLCSTR lpszName
Definition: xml_parser.h:166
Definition: xml_parser.h:125
#define XMLDLLENTRY
Definition: xml_parser.h:84
Definition: xml_parser.h:131
Definition: base.cpp:81
XMLNodeData * d
Definition: xml_parser.h:441
void freeXMLString(XMLSTR t)
Definition: xml_parser.cpp:101
XMLElementType
Definition: xml_parser.h:143
Definition: xml_parser.h:118
static XMLAttribute emptyXMLAttribute
Definition: xml_parser.h:282
Definition: xml_parser.h:405
Definition: xml_parser.h:489
XMLParserBase64Tool()
Definition: xml_parser.h:518
XMLAttribute attrib
Definition: xml_parser.h:468
XMLNode()
Definition: xml_parser.h:279
struct core::XMLClear XMLClear
void * buf
Definition: xml_parser.h:548
XMLCSTR text
Definition: xml_parser.h:469
Definition: xml_parser.h:126
Definition: xml_parser.h:129
struct XMLNodeDataTag * pParent
Definition: xml_parser.h:433
enum XMLError error
Definition: xml_parser.h:153
XMLCSTR lpszCloseTag
Definition: xml_parser.h:161
struct core::XMLAttribute XMLAttribute
Definition: xml_parser.h:124
static XMLClear emptyXMLClear
Definition: xml_parser.h:281
XMLCSTR lpszName
Definition: xml_parser.h:427
#define XMLSTR
Definition: xml_parser.h:104
XMLClear clear
Definition: xml_parser.h:470
XMLNode child
Definition: xml_parser.h:467
Definition: xml_parser.h:123
#define FALSE
Definition: xml_parser.h:108
XMLNode * pChild
Definition: xml_parser.h:434
int nLine
Definition: xml_parser.h:154
Definition: xml_parser.h:148
Definition: xml_parser.h:146
static char guessWideCharChars
Definition: xml_parser.cpp:107
Definition: xml_parser.h:137
Definition: xml_parser.h:120
Definition: xml_parser.h:172
XMLAttribute * pAttribute
Definition: xml_parser.h:437
Definition: xml_parser.h:152
Definition: xml_parser.h:121
Definition: xml_parser.h:158
Definition: xml_parser.h:147
int nColumn
Definition: xml_parser.h:154
Definition: xml_parser.h:122
enum XMLElementType type
Definition: xml_parser.h:464
XMLError
Definition: xml_parser.h:117
Definition: xml_parser.h:132
int * pOrder
Definition: xml_parser.h:438
Definition: xml_parser.h:130
int nText
Definition: xml_parser.h:428
XMLSTR stringDup(XMLCSTR lpszData, int cbData)
Definition: xml_parser.cpp:799
char isDeclaration
Definition: xml_parser.h:432
static XMLNode::XMLCharEncoding characterEncoding
Definition: xml_parser.cpp:106
struct core::XMLNodeContents XMLNodeContents
Definition: xml_parser.h:145
int buflen
Definition: xml_parser.h:504
struct XMLDLLENTRY core::XMLNode XMLNode
struct core::XMLNode::XMLNodeDataTag XMLNodeData
XMLCharEncoding
Definition: xml_parser.h:405
XMLCSTR lpszValue
Definition: xml_parser.h:159
struct core::XMLResults XMLResults
Definition: xml_parser.h:133
#define XMLCSTR
Definition: xml_parser.h:103
Definition: xml_parser.h:462
struct XMLDLLENTRY core::XMLParserBase64Tool XMLParserBase64Tool
struct XMLDLLENTRY core::ToXMLStringTool ToXMLStringTool
Definition: xml_parser.h:127
int ref_count
Definition: xml_parser.h:439
XMLClear * pClear
Definition: xml_parser.h:436
Definition: xml_parser.h:426
Definition: xml_parser.h:119
Definition: xml_parser.h:516
XMLCSTR * pText
Definition: xml_parser.h:435
XMLSTR buf
Definition: xml_parser.h:503