aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/libraries/irrlicht-1.8.1/source/Irrlicht/CXMLWriter.h
blob: 9a69e71f16715e856ae8fc5fc2d14a2b8968f035 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
// Copyright (C) 2002-2012 Nikolaus Gebhardt
// This file is part of the "Irrlicht Engine".
// For conditions of distribution and use, see copyright notice in irrlicht.h

#ifndef __C_XML_WRITER_H_INCLUDED__
#define __C_XML_WRITER_H_INCLUDED__

#include <wchar.h>
#include "IXMLWriter.h"
#include "IWriteFile.h"

namespace irr
{
namespace io
{

	//! Interface providing methods for making it easier to write XML files.
	class CXMLWriter : public IXMLWriter
	{
	public:

		//! Constructor
		CXMLWriter(IWriteFile* file);

		//! Destructor
		virtual ~CXMLWriter();

		//! Writes a xml 1.0 header like <?xml version="1.0"?>
		virtual void writeXMLHeader();

		//! Writes an xml element with maximal 5 attributes
		virtual void writeElement(const wchar_t* name, bool empty=false,
			const wchar_t* attr1Name = 0, const wchar_t* attr1Value = 0,
			const wchar_t* attr2Name = 0, const wchar_t* attr2Value = 0,
			const wchar_t* attr3Name = 0, const wchar_t* attr3Value = 0,
			const wchar_t* attr4Name = 0, const wchar_t* attr4Value = 0,
			const wchar_t* attr5Name = 0, const wchar_t* attr5Value = 0);

		//! Writes an xml element with any number of attributes
		virtual void writeElement(const wchar_t* name, bool empty,
				core::array<core::stringw> &names, core::array<core::stringw> &values);

		//! Writes a comment into the xml file
		virtual void writeComment(const wchar_t* comment);

		//! Writes the closing tag for an element. Like </foo>
		virtual void writeClosingTag(const wchar_t* name);

		//! Writes a text into the file. All occurrences of special characters like
		//! & (&amp;), < (&lt;), > (&gt;), and " (&quot;) are automaticly replaced.
		virtual void writeText(const wchar_t* text);

		//! Writes a line break
		virtual void writeLineBreak();

		struct XMLSpecialCharacters
		{
			wchar_t Character;
			const wchar_t* Symbol;
		};

	private:

		void writeAttribute(const wchar_t* att, const wchar_t* name);

		IWriteFile* File;
		s32 Tabs;

		bool TextWrittenLast;
	};

} // end namespace irr
} // end namespace io

#endif