File: XMLWriter.h

package info (click to toggle)
libtuxcap 1.4.0.dfsg2-1.1
  • links: PTS, VCS
  • area: main
  • in suites: squeeze
  • size: 4,172 kB
  • ctags: 5,897
  • sloc: cpp: 43,203; ansic: 3,095; python: 774; objc: 242; makefile: 100; xml: 87
file content (70 lines) | stat: -rw-r--r-- 2,062 bytes parent folder | download | duplicates (3)
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
// XMLWriter.h: interface for the XMLWriter class by James Poag
//
//////////////////////////////////////////////////////////////////////

#if !defined(AFX_XMLWRITER_H__3DB6D22D_A120_4738_B622_06E90FAED4E4__INCLUDED_)
#define AFX_XMLWRITER_H__3DB6D22D_A120_4738_B622_06E90FAED4E4__INCLUDED_

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000

#pragma warning(disable:4786)
#pragma warning(disable:4503)


#include <stack>
#include "XMLParser.h"
#if 0
#include "../SexyAppFramework/PerfTimer.h"
#endif

namespace Sexy
{
	class XMLWriter  
	{
	protected:
		std::string				mFileName;
		std::string				mErrorText;
		int						mLineNum;
		FILE*					mFile;
		bool					mHasFailed;
		bool					mAllowComments;
		bool					mOpenAttributes;

		std::stack<std::string>	mSectionStack;
		std::stack<std::string> mWarningStack;
		
	protected:
		bool					CheckFileOpen();
		bool					ValidateElementNodeName(const std::string& theNodeName);
		void					Fail(const std::string& theErrorText);
		void					Warn(const std::string& theWarning);
		void					Init();
		
	public:
		XMLWriter();
		virtual ~XMLWriter();
		
static	bool					AddAttribute(XMLElement* theElement, const std::string& aAttributeKey, const std::string& aAttributeValue);
		bool					WriteAttribute(const std::string& aAttributeKey, const std::string& aAttributeValue);
		bool					WriteAttribute(const std::string& aAttributeKey, const float& aAttributeValue);
		bool					WriteAttribute(const std::string& aAttributeKey, const int& aAttributeValue);
		void					Comment(const std::string& theComment);
		bool					StartElement(const std::string &theElementName);
		bool					StartElement(XMLElement *theElement);
		bool					StopElement();
		bool					OpenFile(const std::string& theFilename);
		bool					CloseFile();
		std::string				GetErrorText();
		int						GetCurrentLineNum();
		std::string				GetFileName();
		
		inline void				AllowComments(bool doAllow) { mAllowComments = doAllow; }
		
		bool					HasFailed();
	};
};


#endif // !defined(AFX_XMLWRITER_H__3DB6D22D_A120_4738_B622_06E90FAED4E4__INCLUDED_)