#include "CXMLReaderImpl.h"
#include "CXMLReader.h"
#include "IReadFile.h"
namespace irr
{
namespace io
{
class CIrrXMLFileReadCallBack : public IFileReadCallBack
{
public:
CIrrXMLFileReadCallBack(IReadFile* file)
: ReadFile(file)
{
ReadFile->grab();
}
virtual ~CIrrXMLFileReadCallBack()
{
ReadFile->drop();
}
virtual int read(void* buffer, int sizeToRead)
{
return ReadFile->read(buffer, sizeToRead);
}
virtual long getSize() const
{
return ReadFile->getSize();
}
private:
IReadFile* ReadFile;
};
IXMLReader* createIXMLReader(IReadFile* file)
{
if (!file)
return 0;
return new CXMLReaderImpl<wchar_t, IReferenceCounted>(new CIrrXMLFileReadCallBack(file));
}
IXMLReaderUTF8* createIXMLReaderUTF8(IReadFile* file)
{
if (!file)
return 0;
return new CXMLReaderImpl<char, IReferenceCounted>(new CIrrXMLFileReadCallBack(file));
}
}
}