CXMLWriter.h 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  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 __C_XML_WRITER_H_INCLUDED__
  5. #define __C_XML_WRITER_H_INCLUDED__
  6. #include <wchar.h>
  7. #include "IXMLWriter.h"
  8. #include "IWriteFile.h"
  9. namespace irr
  10. {
  11. namespace io
  12. {
  13. //! Interface providing methods for making it easier to write XML files.
  14. class CXMLWriter : public IXMLWriter
  15. {
  16. public:
  17. //! Constructor
  18. CXMLWriter(IWriteFile* file);
  19. //! Destructor
  20. virtual ~CXMLWriter();
  21. //! Writes a xml 1.0 header like <?xml version="1.0"?>
  22. virtual void writeXMLHeader();
  23. //! Writes an xml element with maximal 5 attributes
  24. virtual void writeElement(const wchar_t* name, bool empty=false,
  25. const wchar_t* attr1Name = 0, const wchar_t* attr1Value = 0,
  26. const wchar_t* attr2Name = 0, const wchar_t* attr2Value = 0,
  27. const wchar_t* attr3Name = 0, const wchar_t* attr3Value = 0,
  28. const wchar_t* attr4Name = 0, const wchar_t* attr4Value = 0,
  29. const wchar_t* attr5Name = 0, const wchar_t* attr5Value = 0);
  30. //! Writes an xml element with any number of attributes
  31. virtual void writeElement(const wchar_t* name, bool empty,
  32. core::array<core::stringw> &names, core::array<core::stringw> &values);
  33. //! Writes a comment into the xml file
  34. virtual void writeComment(const wchar_t* comment);
  35. //! Writes the closing tag for an element. Like </foo>
  36. virtual void writeClosingTag(const wchar_t* name);
  37. //! Writes a text into the file. All occurrences of special characters like
  38. //! & (&amp;), < (&lt;), > (&gt;), and " (&quot;) are automaticly replaced.
  39. virtual void writeText(const wchar_t* text);
  40. //! Writes a line break
  41. virtual void writeLineBreak();
  42. struct XMLSpecialCharacters
  43. {
  44. wchar_t Character;
  45. const wchar_t* Symbol;
  46. };
  47. private:
  48. void writeAttribute(const wchar_t* att, const wchar_t* name);
  49. IWriteFile* File;
  50. s32 Tabs;
  51. bool TextWrittenLast;
  52. };
  53. } // end namespace irr
  54. } // end namespace io
  55. #endif