#ifndef _clsXML_H_
#define _clsXML_H_
#include <boost/property_tree/ptree.hpp>
#include <boost/property_tree/xml_parser.hpp>
#include <boost/foreach.hpp>
#include <string>
#include "AppendBuffer.h"
using namespace std;
namespace DmapCore_30
{
	class Renderer;
	class clsXML
	{
	public:
		clsXML(AppendBuffer* f, string name);
		~clsXML();

		string m_sName;
		AppendBuffer* m_pF;
		bool m_bHaveCloseProperties;


		void closeProperties();//关闭属性
		void writeText(string s);  //写入文本
		static void _Append2(AppendBuffer *f,  string &a,  string &b);
		static void StringReplace(string &strBase, string strSrc, string strDes);
		static bool XMLHead(AppendBuffer * f);
		static string XMLGetPropByString(boost::property_tree::ptree &pt,const string& find);
		static bool XMLAttrParse(boost::property_tree::ptree &pt, AppendBuffer * f, string *value, string find);
		static bool XMLAttrParse(boost::property_tree::ptree &pt, AppendBuffer * f, double *value, string find);
		static bool XMLAttrParse(boost::property_tree::ptree &pt, AppendBuffer * f, long *value, string find);
		static bool XMLAttrParse(boost::property_tree::ptree &pt, AppendBuffer * f, float *value, string find);
		static bool XMLAttrParse(boost::property_tree::ptree &pt, AppendBuffer * f, bool *value, string find, bool defaultValue = false);

		static bool XMLAttrParseColor(boost::property_tree::ptree &pt, AppendBuffer * f, unsigned int * value, string find1, string find2 = "");//这里处理的 int 类型只有 color
		static bool ParseEnum(string find, boost::property_tree::ptree &pt, AppendBuffer * f, bool *v, string a1 = "", string a2 = "", string a3 = "", string a4 = "", string a5 = "", string a6 = "", string a7 = "", string a8 = "", string a9 = "", string a10 = "", string a11 = "", string a12 = "", string a13 = "", string a14 = "", string a15 = "", string a16 = "");
		static bool ParseEnum(string find, boost::property_tree::ptree &pt, AppendBuffer * f, int *v, string a1 = "", string a2 = "", string a3 = "", string a4 = "", string a5 = "", string a6 = "", string a7 = "", string a8 = "", string a9 = "", string a10 = "", string a11 = "", string a12 = "", string a13 = "", string a14 = "", string a15 = "", string a16 = "");
		static string ParseEnum(int v, string a1 = "", string a2 = "", string a3 = "", string a4 = "", string a5 = "", string a6 = "", string a7 = "", string a8 = "", string a9 = "", string a10 = "", string a11 = "", string a12 = "", string a13 = "", string a14 = "", string a15 = "", string a16 = "");
		static bool XMLParse(string ptreeName, boost::property_tree::ptree &pt,  Renderer** renderer);
		static bool XMLParseString( char*, AppendBuffer *f, Renderer** renderer);
	};
}
#endif