1
0

fileio.mi 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  1. //----------------------------------------------------------------------------------------------------------------
  2. // fileio.mi
  3. //
  4. // standard handles for file input and output (only xml parsing atm)
  5. //----------------------------------------------------------------------------------------------------------------
  6. #ifndef __FILEIO_MI
  7. #define __FILEIO_MI
  8. extern class @{836F8B2E-E0D1-4db4-937F-0D0A04C8DCD1}@ Object &File;
  9. extern class @{417FFB69-987F-4be8-8D87-D9965EEEC868}@ File &XmlDoc;
  10. //*****************************************************************************
  11. // File CLASS
  12. //*****************************************************************************
  13. /**
  14. File Class.
  15. @short Root Object for handling files
  16. @author Nullsoft Inc.
  17. @ver 1.0
  18. */
  19. extern File.load (String path); // !Always call this first!
  20. extern boolean File.exists ();
  21. extern int File.getSize ();
  22. //*****************************************************************************
  23. // XmlDoc CLASS
  24. //*****************************************************************************
  25. /**
  26. XmlDoc Class.
  27. @short Root Object for handling xml files
  28. @author Nullsoft Inc.
  29. @ver 1.0
  30. */
  31. /**
  32. parser_addCallback()
  33. Add a XML tag to the global callback list for this file. Ensure to load the file first!
  34. You can call this function more than once in order to add multiple callbacks (not implemented yet).
  35. Use / for subtags and * as wildchar.
  36. Example:
  37. <main>
  38. <cfg>
  39. <int id="a" value="1"/>
  40. <int id="b" value="2"/>
  41. <int id="c" value="3"/>
  42. <string id="d" value="bla" />
  43. </cfg>
  44. <otherstuff what="blabla"/>
  45. </main>
  46. in order to read all items listed under cfg add this callback:
  47. Global XmlDoc myDoc;
  48. System.onScriptLoaded()
  49. {
  50. myDoc = new XmlDoc;
  51. myDoc.load("C:\mycfg.xml");
  52. myDoc.parser_addCallback("main/cfg/*");
  53. myDoc.parser_addCallback("main/otherstuff");
  54. myDoc.parser_start();
  55. myDoc.parser_destroy();
  56. }
  57. Note: myDoc.parser_addCallback("*"); will parse everything.
  58. @param any XML tag you want a callback for
  59. */
  60. extern XmlDoc.parser_addCallback (String section);
  61. /**
  62. parser_start()
  63. Start parsing the XmlDoc.
  64. */
  65. extern XmlDoc.parser_start ();
  66. /**
  67. parser_onCallback()
  68. Hookable. Called everytime an opening XML tag with a added callback is found.
  69. opening XML tags: <sometag id="bla"> or <sometag id="bla"/>
  70. @param XML path to the XML tag that triggered the callback (uppercase!)
  71. @param name of the XML tag that triggered the callback
  72. @param List that holds the paramnames
  73. @param List that holds the paramvalues (sorted in the same way as List paramname)
  74. */
  75. extern String XmlDoc.parser_onCallback (String xmlpath, String xmltag, list paramname, list paramvalue);
  76. /**
  77. parser_onCloseCallback()
  78. Hookable. Called everytime a closing XML tag with an added callback is found.
  79. closing XML tag: </sometag> or <sometag id="bla"/>
  80. @param XML tag that triggered the callback
  81. */
  82. extern String XmlDoc.parser_onCloseCallback (String xmlpath, String xmltag);
  83. /**
  84. parser_onError()
  85. due to some API changes filename and incpath will hold an empty string since winamp 5.56
  86. */
  87. extern String XmlDoc.parser_onError (String filename, int linenum, String incpath, int errcode, String errstr);
  88. /**
  89. parser_destroy()
  90. Always call this if you are done with parsing, or if you want to reset your callbacks.
  91. */
  92. extern String XmlDoc.parser_destroy ();
  93. #endif