/** 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/src/utils/core/xmlfileparser.cpp

*/

#include "sgx/core/core.hpp"
#include "sgx/filesystem/filesystem.hpp"
#include "utils/core/xmlfileparser.hpp"


class sgxXMLFileCallbackHandler : public sgxXMLStreamCallbackHandler {
public:
	sgxXMLFileCallbackHandler(CSGXFile &file) :
	m_File(file)
	{
	}

	virtual tUINT32	fillBuffer(tBYTE *pBuffer, const tUINT32 maxSize) {
		return m_File.read(pBuffer, maxSize);
	}

	CSGXFile &m_File;
};

tBOOL sgxXMLLoader::parseFile(sgxXMLTree &tree, CSGXFile &file) {
	sgxXMLFileCallbackHandler * pHandler = new sgxXMLFileCallbackHandler(file);
	tBOOL rt = CXMLParser::get()->parseStream(tree, pHandler);
	delete pHandler;
	return rt;
}
