#include <libxml/parser.h>

class ConfigNode
{
	private:
		list <ConfigNode*> _children;

	public:
		ConfigNode(xmlNodePtr node);
		void parseNodes(xmlNodePtr node);
		virtual void handleNode(xmlNodePtr child);
		virtual ~ConfigNode();
	
		const list<ConfigNode*> & children() { return _children; }	
		void append(ConfigNode* app)
		{
			if(app) _children.push_back(app);
		}

		virtual void dump() {}
		void dumpChildren();
};

class AppIconNode : public ConfigNode
{
	private:
		string _icon;
		string _name;
		string _command;
		
	public:
		AppIconNode(xmlNodePtr node);
	
		void handleNode(xmlNodePtr child);
		const string& icon() const { return _icon; }
		void setIcon(const string& x) { _icon = x; }
		const string& name() const { return _name; }
		void setName(const string& x) { _name = x; }
		const string& command() const { return _command; }
		void setCommand(const string& x) { _command = x; }

		void setCommand(xmlChar* x) { _command = (char*)x; }
		void setIcon(xmlChar* x) { _icon = (char*)x; }
		void setName(xmlChar* x) { _name = (char*)x; }

		
		void dump()
		{
			cerr << "AppIconNode: " << "name: " << _name << " command: "
				<< _command << " icon: " << _icon << endl;
		}
};

class LauncherTabNode : public ConfigNode
{
	private:
		string _title;

	public:
		LauncherTabNode(xmlNodePtr node);

		void handleNode(xmlNodePtr child);
		const string& title() const { return _title; }
		void setTitle(const string& x) { _title = x; }

		void setTitle(xmlChar* x) { _title = (char*)x; }

		void dump()
		{
			cerr << "LauncherTabNode: title: " << _title << endl;
		}
};

class LauncherNode : public ConfigNode
{
	private:
		bool _vertical;
		bool _withdrawn;
		
		unsigned int _xsize;
		unsigned int _ysize;
		unsigned int _width;
		unsigned int _bgcolor;
		int _xpos;
		int _ypos;
		
	public:
		LauncherNode(xmlNodePtr node);

		void handleNode(xmlNodePtr child);
		
		bool isVertical() const { return _vertical; }
		void setIsVertical(bool x) { _vertical = x; }
		bool isWithdrawn() const { return _withdrawn; }
		void setIsWithdrawn(bool x) { _withdrawn = x; }
		unsigned int xSize() const { return _xsize; }
		void setxSize(unsigned int x) { _xsize = x; }
		unsigned int ySize() const { return _ysize; }
		void setySize(unsigned int x) { _ysize = x; }
		unsigned int width() const { return _width; }
		void setWidth(unsigned int x) { _width = x; }
		unsigned int bgColor() const { return _bgcolor; }
		void setBgColor(unsigned int x) { _bgcolor = x; }
		unsigned int xPos() const { return _xpos; }
		void setxPos(unsigned int x) { _xpos = x; }
		unsigned int yPos() const { return _ypos; }
		void setyPos(unsigned int x) { _ypos = x; }
		
		void dump()
		{
			cerr << "LauncherNode: xsize: " << _xsize << " ysize: " << _ysize
				<< " xpos: " << _xpos << " ypos: " << _ypos
				<< " width: " << _width << " withdrawn: " << _withdrawn
				<< " vertical: " << _vertical << " bgcolor: " << _bgcolor << endl;
		}
};

class AcidLaunchNode : public ConfigNode
{
	public:
		AcidLaunchNode(xmlNodePtr node);
		void handleNode(xmlNodePtr child);
};

class ConfigTree
{
	private:
		ConfigNode* _tree;
	
	public:
		// create empty tree
		ConfigTree();
		// create tree from document
		ConfigTree(const string& filename);
		bool readFile(const string& filename);
		bool writeFile(const string& filename);
};



syntax highlighted by Code2HTML, v. 0.9.1