IXMLWriter.h 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. // Copyright (C) 2002-2012 Nikolaus Gebhardt
  2. // This file is part of the "Irrlicht Engine".
  3. // For conditions of distribution and use, see copyright notice in irrlicht.h
  4. #ifndef __I_XML_WRITER_H_INCLUDED__
  5. #define __I_XML_WRITER_H_INCLUDED__
  6. #include "IReferenceCounted.h"
  7. #include "irrArray.h"
  8. #include "irrString.h"
  9. namespace irr
  10. {
  11. namespace io
  12. {
  13. //! Interface providing methods for making it easier to write XML files.
  14. /** This XML Writer writes xml files using in the platform dependent
  15. wchar_t format and sets the xml-encoding correspondingly. */
  16. class IXMLWriter : public virtual IReferenceCounted
  17. {
  18. public:
  19. //! Writes an xml 1.0 header.
  20. /** Looks like <?xml version="1.0"?>. This should always
  21. be called before writing anything other, because also the text
  22. file header for unicode texts is written out with this method. */
  23. virtual void writeXMLHeader() = 0;
  24. //! Writes an xml element with maximal 5 attributes like "<foo />" or
  25. //! &lt;foo optAttr="value" /&gt;.
  26. /** The element can be empty or not.
  27. \param name: Name of the element
  28. \param empty: Specifies if the element should be empty. Like
  29. "<foo />". If You set this to false, something like this is
  30. written instead: "<foo>".
  31. \param attr1Name: 1st attributes name
  32. \param attr1Value: 1st attributes value
  33. \param attr2Name: 2nd attributes name
  34. \param attr2Value: 2nd attributes value
  35. \param attr3Name: 3rd attributes name
  36. \param attr3Value: 3rd attributes value
  37. \param attr4Name: 4th attributes name
  38. \param attr4Value: 4th attributes value
  39. \param attr5Name: 5th attributes name
  40. \param attr5Value: 5th attributes value */
  41. virtual void writeElement(const wchar_t* name, bool empty=false,
  42. const wchar_t* attr1Name = 0, const wchar_t* attr1Value = 0,
  43. const wchar_t* attr2Name = 0, const wchar_t* attr2Value = 0,
  44. const wchar_t* attr3Name = 0, const wchar_t* attr3Value = 0,
  45. const wchar_t* attr4Name = 0, const wchar_t* attr4Value = 0,
  46. const wchar_t* attr5Name = 0, const wchar_t* attr5Value = 0) = 0;
  47. //! Writes an xml element with any number of attributes
  48. virtual void writeElement(const wchar_t* name, bool empty,
  49. core::array<core::stringw> &names, core::array<core::stringw> &values) = 0;
  50. //! Writes a comment into the xml file
  51. virtual void writeComment(const wchar_t* comment) = 0;
  52. //! Writes the closing tag for an element. Like "</foo>"
  53. virtual void writeClosingTag(const wchar_t* name) = 0;
  54. //! Writes a text into the file.
  55. /** All occurrences of special characters such as
  56. & (&amp;), < (&lt;), > (&gt;), and " (&quot;) are automaticly
  57. replaced. */
  58. virtual void writeText(const wchar_t* text) = 0;
  59. //! Writes a line break
  60. virtual void writeLineBreak() = 0;
  61. };
  62. } // end namespace io
  63. } // end namespace irr
  64. #endif