IncredibleXMLParser  3.05
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
IXMLParser.h
Go to the documentation of this file.
1 /****************************************************************************/
262 #ifndef __INCLUDE_IXML_NODE__
263 #define __INCLUDE_IXML_NODE__
264 
265 #include <stdlib.h>
266 
267 #if defined(UNICODE) || defined(_UNICODE)
268 // If you comment the next "define" line then the library will never "switch to" _UNICODE (wchar_t*) mode (16/32 bits per characters).
269 // This is useful when you get error messages like:
270 // 'IXMLNode::openFileHelper' : cannot convert parameter 2 from 'const char [5]' to 'const wchar_t *'
271 // The _XMLWIDECHAR preprocessor variable force the IXMLParser library into either utf16/32-mode (the proprocessor variable
272 // must be defined) or utf8-mode(the pre-processor variable must be undefined).
273 #define _XMLWIDECHAR
274 #endif
275 
276 #if defined(WIN32) || defined(UNDER_CE) || defined(_WIN32) || defined(WIN64) || defined(__BORLANDC__)
277 // comment the next line if you are under windows and the compiler is not Microsoft Visual Studio (6.0 or .NET) or Borland
278 #define _XMLWINDOWS
279 #endif
280 
281 #ifdef XMLDLLENTRY
282 #undef XMLDLLENTRY
283 #endif
284 #ifdef _USE_XMLPARSER_DLL
285 #ifdef _DLL_EXPORTS_
286 #define XMLDLLENTRY __declspec(dllexport)
287 #else
288 #define XMLDLLENTRY __declspec(dllimport)
289 #endif
290 #else
291 #define XMLDLLENTRY
292 #endif
293 
294 // 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)
295 //#define XML_NO_WIDE_CHAR
296 
297 #ifdef XML_NO_WIDE_CHAR
298 #undef _XMLWINDOWS
299 #undef _XMLWIDECHAR
300 #endif
301 
302 #ifdef _XMLWINDOWS
303 #include <tchar.h>
304 #else
305 #define XMLDLLENTRY
306 #ifndef XML_NO_WIDE_CHAR
307 #include <wchar.h> // to have 'wcsrtombs' for ANSI version
308  // to have 'mbsrtowcs' for WIDECHAR version
309 #endif
310 #endif
311 
314 // Some common types for char set portable code
315 #ifdef _XMLWIDECHAR
316  #define _CXML(c) L ## c
317  typedef const wchar_t *IXMLCStr;
318  typedef wchar_t *IXMLStr;
319  typedef wchar_t IXMLChar;
320 #else
321  #define _CXML(c) c
322  typedef const char *IXMLCStr;
323  typedef char *IXMLStr;
324  typedef char IXMLChar;
325 #endif
326 
327 #ifndef FALSE
328 #define FALSE 0
329 #endif /* FALSE */
330 #ifndef TRUE
331 #define TRUE 1
332 #endif /* TRUE */
333 
335 typedef enum IXMLError
336 {
359 
364 } IXMLError;
365 
366 
368 typedef struct IXMLResults {
370  long long nLine;
371  int nColumn;
372 } IXMLResults;
373 
375 typedef struct IXMLClear {
377  int szValue;
378 } IXMLClear;
379 
381 typedef struct IXMLAttribute {
383  int szValue;
384 } IXMLAttribute;
385 
386 class ITCXMLNode;
387 class ICXMLNode;
388 
393 
395 public:
397  virtual ~IXMLReader(){}
398  virtual int read(unsigned char *buffer,int nbyte)=0;
399 
405  virtual void setNormalBufferSize(int nbyte){}
411  virtual void setSource(IXMLReader *source){}
412  virtual IXMLReader *getSource(){return NULL;}
413  virtual void reset(){}
414 };
415 
418 public:
419  IXMLReaderFile(IXMLCStr filename);
420  ~IXMLReaderFile();
421  int read(unsigned char *buffer,int nbyte);
422  void reset();
423  void *f;
424 };
425 
428 public:
430  int read(unsigned char *buffer,int nbyte);
431  unsigned char *b,*bend;
432 };
433 
448 
449 
452 {
453 public:
454  IPullParser(IXMLReader *_uReader,int _szByteBuffer);
455  virtual ~IPullParser(){}
456 
457  char setBufferSize(int _szByteBuffer);
458 
462  virtual void reset();
463 
465  virtual void clear()=0;
466 
469  typedef enum IXMLToken {
470  IXMLToken_StartDocument=0,
471  IXMLToken_StartTag=1,
472  IXMLToken_EndTag=2,
473  IXMLToken_Text=3,
474  IXMLToken_Clear=4,
475  IXMLToken_ProcessingInstruction=5,
476  IXMLToken_EndDocument=6,
477  IXMLToken_Warning=7,
478  IXMLToken_Error=8
479  } IXMLToken;
480  virtual IXMLToken nextToken()=0;
481  IXMLToken currentToken() const;
482 
483  bool findPath(IXMLCStr path, IXMLChar sep='/', IXMLResults *r=NULL);
484  bool findPathNonConst(IXMLStr path,IXMLChar sep='/', IXMLResults *r=NULL);
485 
486  IXMLCStr getName() const;
487  bool isEmptyNode() const;
488 
503  bool isArrayStart() const;
504 
507  int nAttribute() const;
508  IXMLAttribute *getAttribute(int i=0) const;
509  IXMLCStr getAttributeName(int i=0) const;
510  IXMLCStr getAttributeValue(int i=0) const;
511  int szAttributeValue(int i=0) const;
512 
513  IXMLCStr getText() const;
514  int szText() const;
515  bool isTextWhiteSpace() const;
516 
517  const IXMLClear *getClear() const;
518 
519  IXMLError getErrorCode() const;
520  long long getLineNumber() const;
521  virtual int getColumnNumber() const;
522  int getDepth() const;
523 
524  // setup
525  void setAutoDetectSourceEncoding(bool autoDetectSource=false);
526  bool getAutoDetectSourceEncoding();
539 
540  typedef enum IXMLCharEncoding
541  {
542  char_encoding_error=0,
543  char_encoding_UTF16=1,
544  char_encoding_UTF8=2,
545  char_encoding_System=3,
546  char_encoding_legacy=4,
547  char_encoding_ShiftJIS=5,
548  char_encoding_GB2312=6,
549  char_encoding_Big5=7,
550  char_encoding_GBK=8 // this is actually the same as Big5
551  } IXMLCharEncoding;
552 
553 #ifdef _XMLWIDECHAR
554  virtual char setSourceCharEncoding(IXMLCharEncoding e=char_encoding_UTF16);
560 #else
561  virtual char setCharEncoding(IXMLCharEncoding sourceEncoding=char_encoding_UTF8, IXMLCharEncoding destinationEncoding=char_encoding_UTF8);
562  virtual IXMLCharEncoding getCharEncodingDestination();
567 #endif
568 
569  IXMLCStr getVersion();
570  static IXMLCStr getErrorMessage(IXMLError error);
571 
572 protected:
573  // These are functions and structures used internally by the IXMLPullParser class (don't bother about them):
574  IXMLReader *uReader,*sourceUReader;
576  int szByteBuffer,_nAttribute;
578  int depth,_szText;
579  long long nLine;
580  bool _isEmptyNode,_isIgnorableSpace,_isInArray;
584 
587  const char *XML_ByteTable;
588 
589  bool skipBranch(int skipVar);
590 
592  public:
595  void setNormalBufferSize(int nbyte);
596  void setSource(IXMLReader *source);
597  IXMLReader *getSource();
598  int read(unsigned char *buffer,int nbyte);
599  void reset();
600  IXMLCharEncoding sourceEncoding; // system or utf8
602  int bufferSz,len,mbstate;
603  unsigned char *b;
604  };
606  public:
609  void setNormalBufferSize(int nbyte);
610  void setSource(IXMLReader *source);
611  IXMLReader *getSource();
612  int read(unsigned char *buffer,int nbyte);
613  void reset();
614  IXMLCharEncoding destEncoding; // system or utf8
616  int bufferSz,len,mbstate;
617  unsigned char *b;
618  };
620  public:
622  int read(unsigned char *buffer,int nbyte);
623  unsigned char b[512],*pos,*bEnd;
625  void skipBOM();
626  int nByteRead();
627  };
630 
631  unsigned char *bufferChar;
632  IXMLStr pCurrentPos,pEndPos,pStartOfLine;
634  char readData(IXMLStr *ptr,IXMLStr *pend,IXMLStr *ptrOut,IXMLStr *pStart);
635 };
636 
638 
659 {
660 public:
661  IXMLPullParser(IXMLReader *uReader,int _szByteBuffer=1024*1024);
662  ~IXMLPullParser();
663 
664  void reset();
665 
667  void clear();
671  IXMLToken nextToken();
672  int getColumnNumber() const;
673 
674  static IXMLCStr guessXMLCharEncoding(unsigned char *b,int l, IXMLChar out[200]);
675  static IXMLCharEncoding guessXMLCharEncodingCode(unsigned char *b,int l);
676 
677 private:
678 // These are functions and structures used internally by the IXMLPullParser class (don't bother about them):
679  int maxAttribute;
680  int nextChar,nextDepth;
681 
682  char parseNameAndAttributes(IXMLStr *_ptr, int *c);
683  inline char parseEndTag(IXMLStr *_ptr);
684  char processText(IXMLChar delim,IXMLStr *_ptr, int *nextChar, int *len);
685  char findClearTagEnd(IXMLStr *ptr,IXMLCStr closeTag,int closeTagLen);
686 };
687 
690 {
691 public:
692  IJSONPullParser(IXMLReader *uReader,int _szByteBuffer=1024*1024);
693  ~IJSONPullParser();
694 
695  void reset();
696 
698  void clear();
702  IXMLToken nextToken();
703 
704  void setTagNameForArrays(IXMLCStr arrayName);
705  IXMLCStr getTagNameForArrays();
706 
707  static IXMLCStr guessJSONCharEncoding(unsigned char *b,int l);
708  static IXMLCharEncoding guessJSONCharEncodingCode(unsigned char *b,int l);
709 
710 private:
711  IXMLStr *allCurrentTags;
712  IXMLStr tagNameForArray;
713  int nextChar,tagBufferSize;
714  char parseStartList(IXMLStr *ptr);
715  char parseString(IXMLStr *ptr);
716  char parseNumber(IXMLStr *ptr, int *nextChar);
717  void addToTagList(IXMLStr p,int l);
718 };
719 
722 {
723 public:
724  IXMLDomParser();
725  ~IXMLDomParser();
726  void clear();
736  void setDomMemoryBlockSize(int blockSize=1024*1024);
746  int getDomMemoryBlockSize();
747 
748  void setDomMaxMemorySize(size_t maxMem=0);
753  int getDomMaxMemorySize();
754 
755  void setDefaultPullParserWorkspaceMemorySize(int memSize=1024*1024);
761  int getDefaultPullParserWorkspaceMemorySize();
762 
763  void setSkipIgnorableSpaces(bool skipIgnorableSpaces=true);
773  bool getSkipIgnorableSpaces();
774 
775  void setTrimTexts(bool trimTexts=true);
782  bool getTrimTexts();
783 
784  void setTrimAttributes(bool trimAttributes=true);
791  bool getTrimAttributes();
792 
793  void setRemoveClears(bool removeClears=true);
799  bool getRemoveClears();
800 
801  void setRemoveProcessingInstructions(bool removeProcessingInstructions=true);
807  bool getRemoveProcessingInstructions();
808 
809  bool getAutoDetectSourceEncoding();
810  static IXMLCStr getErrorMessage(IXMLError error);
811 
813  ITCXMLNode parseString(IXMLCStr lpIXMLString, IXMLCStr tag=NULL, IXMLResults *pResults=NULL);
814  ICXMLNode parseStringNonT(IXMLCStr lpIXMLString, IXMLCStr tag=NULL, IXMLResults *pResults=NULL);
826 
827  ITCXMLNode parseFile(IXMLCStr filename, IXMLCStr tag=NULL, IXMLResults *pResults=NULL);
828  ICXMLNode parseFileNonT(IXMLCStr filename, IXMLCStr tag=NULL, IXMLResults *pResults=NULL);
840 
841  ITCXMLNode openFileHelper(IXMLCStr filename, IXMLCStr tag=NULL);
842  ICXMLNode openFileHelperNonT(IXMLCStr filename, IXMLCStr tag=NULL);
859  ITCXMLNode parse(IPullParser *pp, IXMLCStr tag=NULL, IXMLResults *pResults=NULL);
860  ICXMLNode parseNonT(IPullParser *pp, IXMLCStr tag=NULL, IXMLResults *pResults=NULL);
871  ITCXMLNode parseOneChild(IPullParser *pp, IXMLResults *pResults=NULL);
872  ICXMLNode parseOneChildNonT(IPullParser *pp, IXMLResults *pResults=NULL);
885 #ifdef _XMLWIDECHAR
886  void setAutoDetectSourceEncoding(bool autoDetectSource=true);
896 #else
897  void setAutoDetectSourceEncoding(bool autoDetectSource=false);
902  void setCharEncoding(IXMLPullParser::IXMLCharEncoding sourceEncoding=IXMLPullParser::char_encoding_UTF8,
909 private:
910  IXMLPullParser::IXMLCharEncoding destinationEncoding;
911 #endif
912 
913 private:
914 // These are functions and structures used internally by the IXMLDomParser class (don't bother about them):
915  IXMLPullParser::IXMLCharEncoding sourceEncoding;
916  int memBufferSz,pullParserMemSz;
917  bool autoDetectSource,skipIgnorableSpaces,requiresTrimText,trimAttribute,
918  removeClears,removeProcessingInstructions;
919  size_t maxMemDom;
920  ITCXMLNode genericParse(IXMLCStr tag);
921  ITCXMLNode genericParse2(bool getOneChild);
922  char genericParseRecur(int iChild,int iText, int iOrder, int iClear, void *td, bool getOneChild);
923  void *initNTD();
924 
925  IPullParser *pullParser;
926  IXMLResults *pResults,xmlRes;
927  ITCXMLNode *vChild; int nChild;
928  IXMLCStr *vText; int nText;
929  IXMLClear *vClear; int nClear;
930  int *vOrder; int nOrder;
931 
932  void *memoryManager;
933 };
943 class IXMLNode;
944 class ICXMLNode;
945 
947 
958 {
959 friend class IXMLDomParser;
960 friend class IXMLNode;
961 friend class ICXMLNode;
962 friend class IXMLRenderer;
963 public:
964  IXMLCStr getName() const;
965  IXMLCStr getText(int i=0) const;
966  int nText() const;
967  ITCXMLNode getParentNode() const;
968  ITCXMLNode getChildNode(int i=0) const;
969  ITCXMLNode getChildNode(IXMLCStr name, int i) const;
970  ITCXMLNode getChildNode(IXMLCStr name, int *i=NULL) const;
971  ITCXMLNode getChildNodeWithAttribute(IXMLCStr tagName,
972  IXMLCStr attributeName,
973  IXMLCStr attributeValue=NULL,
974  int *i=NULL) const;
975  ITCXMLNode getChildNodeByPath(IXMLCStr path, IXMLChar sep='/') const;
977  ITCXMLNode getChildNodeByPathNonConst(IXMLStr path,IXMLChar sep='/') const;
979  IXMLCStr getElementByPath(IXMLCStr xpath,IXMLChar sep='/') const;
981  IXMLCStr getElementByPathNonConst(IXMLStr xpath,IXMLChar sep='/') const;
983 
984  int nChildNode(IXMLCStr name) const;
985  int nChildNode() const;
986  IXMLAttribute getAttribute(int i=0) const;
987  IXMLCStr getAttributeName(int i=0) const;
988  IXMLCStr getAttributeValue(int i=0) const;
989  char isAttributeSet(IXMLCStr name) const;
990  IXMLCStr getAttribute(IXMLCStr name, int i) const;
991  IXMLCStr getAttribute(IXMLCStr name, int *i=NULL) const;
992  int nAttribute() const;
993  IXMLClear getClear(int i=0) const;
994  int nClear() const;
995  int nElement() const;
996  char isEmpty() const;
997  char isProcessInstruction() const;
998  IXMLNode deepCopy() const;
999  ICXMLNode deepCopyConstant() const;
1000  static ITCXMLNode emptyNode();
1001  static IXMLCStr getErrorMessage(IXMLError error);
1002 
1003  ITCXMLNode(const ITCXMLNode &A);
1004  ITCXMLNode& operator=( const ITCXMLNode& A );
1005  ITCXMLNode(): d(NULL){};
1006  static ITCXMLNode emptyITCXMLNode; // you should use ITCXMLNode::emptyNode(); instead
1009 
1010 private:
1011 // These are functions and structures used internally by the ITCXMLNode class (don't bother about them):
1012 
1013  typedef struct IXMLNodeData // to allow shallow copy and "intelligent/smart" pointers (automatic delete):
1014  {
1015  IXMLCStr pName; // Element name (=NULL if root)
1016  int nChild, // Number of child nodes
1017  nText, // Number of text fields
1018  nClear, // Number of Clear fields (comments)
1019  nAttribute; // Number of attributes
1020  char isProcessInstruction; // Whether node is an XML Process Instruction - '<?xml ?>'
1021  struct IXMLNodeData *pParent; // Pointer to parent element (=NULL if root)
1022  ITCXMLNode *pChild; // Array of child nodes
1023  IXMLCStr *pText; // Array of text fields
1024  IXMLClear *pClear; // Array of clear fields
1025  IXMLAttribute *pAttribute; // Array of attributes
1026  int *pOrder; // order of the child_nodes,text_fields,clear_fields
1027  union
1028  {
1029  int ref_count; // for garbage collection in IXMLNode (smart pointers)
1030  int *memBuffer; // for garbage collection in ICXMLNode(smart pointers)
1031  };
1032  inline void init(struct IXMLNodeData *pParent, char isDeclaration);
1033  } IXMLNodeData;
1034  IXMLNodeData *d;
1035 
1036  typedef enum IXMLElementType
1037  {
1038  eNodeChild=0,
1039  eNodeText=1,
1040  eNodeClear=2
1041  } IXMLElementType;
1042 
1043  int deepCopyConstantR1()const;
1044  ICXMLNode deepCopyConstantR2(int *nref, unsigned char **_p) const;
1045 
1046  ITCXMLNode(IXMLNodeData *p);
1047  ITCXMLNode(const ICXMLNode &A);
1048  ITCXMLNode& operator=( const ICXMLNode& A );
1049  ITCXMLNode(const IXMLNode &A);
1050  ITCXMLNode& operator=( const IXMLNode& A );
1051 };
1052 
1054 
1068 {
1069 friend class IXMLRenderer;
1070 public:
1071  ICXMLNode getParentNode() const;
1072  ICXMLNode getChildNode(int i=0) const;
1073  ICXMLNode getChildNode(IXMLCStr name, int i) const;
1074  ICXMLNode getChildNode(IXMLCStr name, int *i=NULL) const;
1076  IXMLCStr attributeName,
1077  IXMLCStr attributeValue=NULL,
1078  int *i=NULL) const;
1079  ICXMLNode getChildNodeByPath(IXMLCStr path, IXMLChar sep='/') const;
1081  static ICXMLNode emptyNode();
1082 
1083  ~ICXMLNode();
1084  ICXMLNode(const ICXMLNode &A);
1085  ICXMLNode& operator=( const ICXMLNode& A );
1087  static ICXMLNode emptyICXMLNode;
1088 
1089 private:
1090  inline void emptyTheNode();
1091 };
1092 
1106 
1108 
1122 {
1123 friend class IXMLRenderer;
1124 friend class ITCXMLNode;
1125 public:
1126  IXMLNode getParentNode() const;
1127  IXMLNode getChildNode(int i=0) const;
1128  IXMLNode getChildNode(IXMLCStr name, int i) const;
1129  IXMLNode getChildNode(IXMLCStr name, int *i=NULL) const;
1131  IXMLCStr attributeName,
1132  IXMLCStr attributeValue=NULL,
1133  int *i=NULL) const;
1134  IXMLNode getChildNodeByPath(IXMLCStr path, IXMLChar sep='/')const;
1136  static IXMLNode emptyNode();
1137 
1138  ~IXMLNode();
1139  IXMLNode(const IXMLNode &A);
1140  IXMLNode& operator=( const IXMLNode& A );
1142  static IXMLNode emptyIXMLNode;
1143 
1148  static IXMLNode createXMLTopNode(IXMLCStr pName=NULL, char isDeclaration=FALSE);
1149  IXMLNode addChild(IXMLCStr pName, char isDeclaration=FALSE, IXMLElementPosition pos=-1);
1150  IXMLNode addChild(IXMLNode nodeToAdd, IXMLElementPosition pos=-1);
1151  IXMLAttribute *addAttribute(IXMLCStr pName, IXMLCStr pValuev);
1152  IXMLCStr addText(IXMLCStr pValue, IXMLElementPosition pos=-1);
1153  IXMLClear *addClear(IXMLCStr pValue, IXMLCStr lpcOpen=NULL, IXMLCStr lpcClose=NULL, IXMLElementPosition pos=-1);
1165  IXMLCStr updateName(IXMLCStr pName);
1166  IXMLAttribute *updateAttribute(IXMLAttribute *newAttribute, IXMLAttribute *oldAttribute);
1167  IXMLAttribute *updateAttribute(IXMLCStr lpcNewValue, IXMLCStr lpcNewName=NULL,int i=0);
1168  IXMLAttribute *updateAttribute(IXMLCStr lpcNewValue, IXMLCStr lpcNewName,IXMLCStr lpcOldName);
1169  IXMLCStr updateText(IXMLCStr lpcNewValue, int i=0);
1170  IXMLCStr updateText(IXMLCStr lpcNewValue, IXMLCStr lpcOldValue);
1171  IXMLClear *updateClear(IXMLCStr lpcNewContent, int i=0);
1172  IXMLClear *updateClear(IXMLClear *newP,IXMLClear *oldP);
1173  IXMLClear *updateClear(IXMLCStr lpcNewValue, IXMLCStr lpcOldValue);
1174 
1181 
1182  void deleteNodeContent();
1184  void deleteAttribute(int i=0);
1185  void deleteAttribute(IXMLCStr pName);
1186  void deleteAttribute(IXMLAttribute *anAttribute);
1187  void deleteText(int i=0);
1188  void deleteText(IXMLCStr pValue);
1189  void deleteClear(int i=0);
1190  void deleteClear(IXMLCStr pValue);
1191  void deleteClear(IXMLClear *p);
1192 
1223  static IXMLNode createXMLTopNode_WOSD(IXMLStr pName, char isDeclaration=FALSE);
1224  IXMLNode addChild_WOSD(IXMLStr pName, char isDeclaration=FALSE, IXMLElementPosition pos=-1);
1225  IXMLAttribute *addAttribute_WOSD(IXMLStr pName, IXMLStr pValue);
1226  IXMLCStr addText_WOSD(IXMLStr pValue, IXMLElementPosition pos=-1);
1227  IXMLClear *addClear_WOSD(IXMLStr pValue, IXMLCStr lpcOpen=NULL, IXMLCStr lpcClose=NULL, IXMLElementPosition pos=-1);
1228 
1229  IXMLCStr updateName_WOSD(IXMLStr pName);
1230  IXMLAttribute *updateAttribute_WOSD(IXMLAttribute *newAttribute, IXMLAttribute *oldAttribute);
1231  IXMLAttribute *updateAttribute_WOSD(IXMLStr lpcNewValue, IXMLStr lpcNewName=NULL,int i=0);
1232  IXMLAttribute *updateAttribute_WOSD(IXMLStr lpcNewValue, IXMLStr lpcNewName,IXMLCStr lpcOldName);
1233  IXMLCStr updateText_WOSD(IXMLStr lpcNewValue, int i=0);
1234  IXMLCStr updateText_WOSD(IXMLStr lpcNewValue, IXMLCStr lpcOldValue);
1235  IXMLClear *updateClear_WOSD(IXMLStr lpcNewContent, int i=0);
1236  IXMLClear *updateClear_WOSD(IXMLClear *newP,IXMLClear *oldP);
1237  IXMLClear *updateClear_WOSD(IXMLStr lpcNewValue, IXMLCStr lpcOldValue);
1238 
1246  IXMLElementPosition positionOfText(int i=0) const;
1247  IXMLElementPosition positionOfText(IXMLCStr pValue) const;
1248  IXMLElementPosition positionOfClear(int i=0) const;
1249  IXMLElementPosition positionOfClear(IXMLCStr pValue) const;
1250  IXMLElementPosition positionOfClear(IXMLClear *a) const;
1251  IXMLElementPosition positionOfChildNode(int i=0) const;
1252  IXMLElementPosition positionOfChildNode(IXMLNode x) const;
1253  IXMLElementPosition positionOfChildNode(IXMLCStr name, int i=0) const;
1254 
1256 private:
1257 // These are functions used internally by the IXMLNode class (don't bother about them):
1258  IXMLNode(IXMLNodeData *pParent, IXMLStr pName, char isDeclaration);
1259  void *addToOrder(int *_pos, int nc, void *p, int size, IXMLElementType xtype);
1260  int indexText(IXMLCStr pValue) const;
1261  int indexClear(IXMLCStr pValue) const;
1262  IXMLNode addChild_priv(IXMLStr,char,int);
1263  IXMLAttribute *addAttribute_priv(IXMLStr,IXMLStr);
1264  IXMLCStr addText_priv(IXMLStr,int);
1265  IXMLClear *addClear_priv(IXMLStr,IXMLCStr,IXMLCStr,int);
1266  void emptyTheNode(char force);
1267  static inline IXMLElementPosition findPosition(IXMLNodeData *d, int index, IXMLElementType xtype);
1268  static int removeOrderElement(IXMLNodeData *d, IXMLElementType t, int index);
1269  static int detachFromParent(IXMLNodeData *d);
1270 };
1271 
1277 
1278 
1288 {
1289 public:
1291  typedef enum IXMLStringLocation
1292  {
1293  IXMLStringLocation_unknown=0,
1294  IXMLStringLocation_inAttribute=1,
1295  IXMLStringLocation_inText=2
1296  } IXMLStringLocation;
1297 
1298  ToIXMLStringTool(IXMLStringLocation loc=IXMLStringLocation_unknown);
1299  ~ToIXMLStringTool();
1300  void clear();
1301  void setLocation(IXMLStringLocation loc=IXMLStringLocation_unknown);
1302  IXMLStringLocation getLocation();
1303 
1304  IXMLStr toXML(IXMLCStr source);
1305 
1309  IXMLStr toXMLUnSafe(IXMLStr dest,IXMLCStr source);
1310  int lengthXMLString(IXMLCStr source);
1311 
1312 #ifndef _XMLWIDECHAR
1314  IXMLPullParser::IXMLCharEncoding getCharEncoding();
1315 private:
1316 // These are functions and structures used internally by the ToIXMLStringTool class (don't bother about them):
1317  const char *XML_ByteTable;
1318  IXMLPullParser::IXMLCharEncoding characterEncoding;
1319 #endif
1320 
1321 private:
1322  IXMLStr buf;
1323  int buflen;
1324  IXMLStringLocation loc;
1325  void *curXMLEntities;
1326 };
1337 
1339 {
1340 public:
1341  IXMLRenderer();
1342  ~IXMLRenderer();
1343  static IXMLCStr getErrorMessage(IXMLError error);
1344 
1354  IXMLCStr getString(ITCXMLNode x, int nFormat=1, int *pnSize=NULL);
1355  IXMLCStr getString(ICXMLNode x, int nFormat=1, int *pnSize=NULL);
1356  IXMLCStr getString(IXMLNode x, int nFormat=1, int *pnSize=NULL);
1357  int szString();
1358  void clear();
1359 
1370  IXMLError writeToFile(ITCXMLNode x, IXMLCStr filename,IXMLCStr encoding=NULL,char nFormat=1);
1371  IXMLError writeToFile(ICXMLNode x, IXMLCStr filename,IXMLCStr encoding=NULL,char nFormat=1);
1372  IXMLError writeToFile(IXMLNode x, IXMLCStr filename,IXMLCStr encoding=NULL,char nFormat=1);
1373 
1375 #ifndef _XMLWIDECHAR
1377  IXMLPullParser::IXMLCharEncoding getCharEncoding();
1378 private:
1379  IXMLPullParser::IXMLCharEncoding characterEncoding;
1380 #endif
1381 
1382 private:
1383 // These are functions and structures used internally by the IXMLRenderer class (don't bother about them):
1384  IXMLStr buf;
1385  int maxStrLen,sz;
1386  ToIXMLStringTool txAtt,txTxt;
1387  int getStringR(ITCXMLNode::IXMLNodeData *pEntry, IXMLStr lpcMarker, int nFormat);
1388 };
1395 
1396 XMLDLLENTRY IXMLStr IXMLStringDup(IXMLCStr source, int cbData=-1);
1402 
1403 XMLDLLENTRY void freeIXMLString(IXMLStr t); // {free(t);}
1414 // XMLDLLENTRY char xmltob(IXMLCStr s,char defautValue=0);
1415 // XMLDLLENTRY int xmltoi(IXMLCStr s,int defautValue=0);
1416 // XMLDLLENTRY long long xmltol(IXMLCStr s,long long defautValue=0);
1417 // XMLDLLENTRY double xmltof(IXMLCStr s,double defautValue=.0);
1418 // XMLDLLENTRY IXMLCStr xmltoa(IXMLCStr s,IXMLCStr defautValue=_CXML(""));
1419 // XMLDLLENTRY IXMLChar xmltoc(IXMLCStr s,const IXMLChar defautValue=_CXML('\0'));
1426 
1427 
1437 {
1438 public:
1439  IXMLParserBase64Tool(): buf(NULL),buflen(0){}
1441  void clear();
1442 
1445  static int encodeLength(int inBufLen, char formatted=0);
1446 
1452  IXMLStr encode(unsigned char *inByteBuf, unsigned int inByteLen, char formatted=0);
1453 
1455  static unsigned int decodeSize(IXMLCStr inString, IXMLError *xe=NULL);
1456 
1462  unsigned char* decode(IXMLCStr inString, int *outByteLen=NULL, IXMLError *xe=NULL);
1463 
1468  static unsigned char decode(IXMLCStr inString, unsigned char *outByteBuf, int inMaxByteOutBuflen, IXMLError *xe=NULL);
1469 
1470 private:
1471  void *buf;
1472  int buflen;
1473  void alloc(int newsize);
1474 };
1477 #undef XMLDLLENTRY
1478 
1479 #endif