1
0

sxmldoc.h 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. #ifndef __SXMLDOC_H
  2. #define __SXMLDOC_H
  3. class SXmlDoc;
  4. #include <api/script/objects/sfile.h>
  5. #include <api/script/script.h>
  6. #include <api/script/objcontroller.h>
  7. #include <api/script/objects/rootobj.h>
  8. #include <api/script/objects/rootobject.h>
  9. #include <api/xml/XMLAutoInclude.h>
  10. #define SXMLDOC_SCRIPTPARENT SFile
  11. class XmlDocScriptController : public fileScriptController {
  12. public:
  13. virtual const wchar_t *getClassName();
  14. virtual const wchar_t *getAncestorClassName();
  15. virtual ScriptObjectController *getAncestorController();
  16. virtual int getNumFunctions();
  17. virtual const function_descriptor_struct *getExportedFunctions();
  18. virtual GUID getClassGuid();
  19. virtual ScriptObject *instantiate();
  20. virtual void destroy(ScriptObject *o);
  21. virtual void *encapsulate(ScriptObject *o);
  22. virtual void deencapsulate(void *o);
  23. private:
  24. static function_descriptor_struct exportedFunction[];
  25. };
  26. class SXmlDocParserCallback : public ifc_xmlreadercallbackI
  27. {
  28. void xmlReaderOnStartElementCallback(const wchar_t *xmlpath, const wchar_t *xmltag, ifc_xmlreaderparams *params);
  29. void xmlReaderOnEndElementCallback(const wchar_t *xmlpath, const wchar_t *xmltag);
  30. void xmlReaderOnError(int linenum, int errcode, const wchar_t *errstr);
  31. public: SXmlDoc *parent; // reference to the xmldoc that triggered this callback
  32. };
  33. extern XmlDocScriptController *xmlDocController;
  34. class SXmlDoc : public SXMLDOC_SCRIPTPARENT
  35. {
  36. public:
  37. SXmlDoc();
  38. virtual ~SXmlDoc();
  39. void addParserCallback(const wchar_t *b);
  40. void startParsing();
  41. void destroyParser();
  42. void elementCallback(const wchar_t *xmltag);
  43. private:
  44. obj_xml *myXmlParser;
  45. SXmlDocParserCallback myXmlParserCallback;
  46. waServiceFactory *myXmlParserFactory;
  47. void createParser();
  48. public:
  49. static scriptVar script_vcpu_addParserCallback(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar fn);
  50. static scriptVar script_vcpu_parse(SCRIPT_FUNCTION_PARAMS, ScriptObject *o);
  51. static scriptVar script_vcpu_destroyParser(SCRIPT_FUNCTION_PARAMS, ScriptObject *o);
  52. static scriptVar script_vcpu_onXmlParserCallback(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar xmlpath, scriptVar xmltag, scriptVar param, scriptVar paramvalue);
  53. static scriptVar script_vcpu_onXmlParserError(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar filename, scriptVar linenum, scriptVar incpath, scriptVar errcode, scriptVar errstr);
  54. static scriptVar script_vcpu_onXmlParserEndCallback(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar xmlpath, scriptVar xmltag);
  55. };
  56. #endif