1
0

XMLReader.h 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. #ifndef NULLSOFT_XML_XMLREADER_H
  2. #define NULLSOFT_XML_XMLREADER_H
  3. #include "obj_xml.h"
  4. #include <vector>
  5. #include "expat.h"
  6. #include "../WAT/WAT.h"
  7. struct CallbackStruct
  8. {
  9. CallbackStruct(ifc_xmlreadercallback* _callback, const wchar_t* _match, bool doUpper);
  10. CallbackStruct();
  11. ~CallbackStruct();
  12. ifc_xmlreadercallback* callback;
  13. wchar_t* match;
  14. };
  15. class XMLReader : public obj_xml
  16. {
  17. public:
  18. XMLReader();
  19. ~XMLReader();
  20. void RegisterCallback(const wchar_t* matchstr, ifc_xmlreadercallback* callback);
  21. void UnregisterCallback(ifc_xmlreadercallback* callback);
  22. int Open();
  23. int OpenNamespace();
  24. void OldFeed(void* data, size_t dataSize);
  25. int Feed(void* data, size_t dataSize);
  26. void Close();
  27. void PushContext();
  28. void PopContext();
  29. void Reset();
  30. void SetEncoding(const wchar_t* encoding);
  31. int SetCaseSensitive();
  32. protected:
  33. RECVS_DISPATCH;
  34. public:
  35. void XMLCALL StartTag(const wchar_t* name, const wchar_t** atts);
  36. void XMLCALL EndTag(const wchar_t* name);
  37. void XMLCALL TextHandler(const wchar_t* s, int len);
  38. void XMLCALL StartTag(const char* name, const char** atts);
  39. void XMLCALL EndTag(const char* name);
  40. void XMLCALL TextHandler(const char* s, int len);
  41. private:
  42. const wchar_t* BuildPath();
  43. const wchar_t* AddPath(const wchar_t* node);
  44. const wchar_t* AddPath(const char* node);
  45. const wchar_t* RemovePath(const wchar_t* node);
  46. const wchar_t* RemovePath(const char* node);
  47. std::wstring pathString;//, pathUpper;
  48. std::wstring endPathString;//, endPathUpper;
  49. std::wstring currentNode;
  50. private:
  51. std::vector<CallbackStruct*> callbacks;
  52. std::vector<XML_Parser> context;
  53. XML_Parser parser;
  54. bool case_sensitive;
  55. std::wstring textCache;
  56. };
  57. #endif