/** SGX

The   sss    gggg x   x   
     s      g      x x    Engine
      sss   g  gg   x
         s  g   g  x x          Copyright 1995-2009.
     ssss    gggg x   x         Steven Goodwin. All Rights Reserved.
    
This version has been released under the GNU Public License v2.0.

Please see the license files for details.

File: sgx/include/sgx/core/xml/xmltree.hpp

*/

#ifndef SGX_CORE_XML_TREE_HPP
#define SGX_CORE_XML_TREE_HPP	1

class sgxXMLTree;
typedef tBOOL (*cbfn_TreeTraverse)(sgxXMLTree *pTree, sgxXMLNode *pNode, tMEM_SIZE param);
typedef tBOOL (*cbfn_TreeTraverseConst)(const sgxXMLTree *pTree, const sgxXMLNode *pNode, tMEM_SIZE param);

class sgxXMLTreeTraverse {
public:
	sgxXMLTree	*m_pTree;
	sgxXMLNode	*m_pNode;
	tMEM_SIZE	m_Param;
};

class sgxXMLTree {
public:
	sgxXMLTree();
	~sgxXMLTree();

	void				clear();

	sgxXMLNode *		getRootNode() { return m_pRoot; }
	const sgxXMLNode *	getRootNode() const { return m_pRoot; }

	tBOOL	traverse(cbfn_TreeTraverse cb, tMEM_SIZE param);
	tBOOL	traverse(cbfn_TreeTraverseConst cb, tMEM_SIZE param) const;

protected:
	sgxXMLNode	*m_pRoot;

private:
	tBOOL	traverseFromNode(sgxXMLNode *pNode, cbfn_TreeTraverse cb, tMEM_SIZE param);
	tBOOL	traverseFromNode(const sgxXMLNode *pNode, cbfn_TreeTraverseConst cb, tMEM_SIZE param) const;
};

#endif /* SGX_CORE_XML_TREE_HPP */
