stk-code_catmod/lib/irrlicht/source/Irrlicht/CXMLReader.cpp
hikerstk 974deca5e1 Added our own irrlicht version - not used atm.
git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/trunk@11846 178a84e3-b1eb-0310-8ba1-8eac791a3b58
2012-11-01 02:00:02 +00:00

71 lines
1.6 KiB
C++

// Copyright (C) 2002-2012 Nikolaus Gebhardt
// This file is part of the "Irrlicht Engine".
// For conditions of distribution and use, see copyright notice in irrlicht.h
#include "CXMLReaderImpl.h"
#include "CXMLReader.h"
#include "IReadFile.h"
namespace irr
{
namespace io
{
//! Irrlicht implementation of the file read callback for the xml parser
class CIrrXMLFileReadCallBack : public IFileReadCallBack
{
public:
//! construct from FILE pointer
CIrrXMLFileReadCallBack(IReadFile* file)
: ReadFile(file)
{
ReadFile->grab();
}
//! destructor
virtual ~CIrrXMLFileReadCallBack()
{
ReadFile->drop();
}
//! Reads an amount of bytes from the file.
virtual int read(void* buffer, int sizeToRead)
{
return ReadFile->read(buffer, sizeToRead);
}
//! Returns size of file in bytes
virtual long getSize() const
{
return ReadFile->getSize();
}
private:
IReadFile* ReadFile;
}; // end class CMyXMLFileReadCallBack
// now create an implementation for IXMLReader using irrXML.
//! Creates an instance of a wide character xml parser.
IXMLReader* createIXMLReader(IReadFile* file)
{
if (!file)
return 0;
return new CXMLReaderImpl<wchar_t, IReferenceCounted>(new CIrrXMLFileReadCallBack(file));
}
//! Creates an instance of an UFT-8 or ASCII character xml parser.
IXMLReaderUTF8* createIXMLReaderUTF8(IReadFile* file)
{
if (!file)
return 0;
return new CXMLReaderImpl<char, IReferenceCounted>(new CIrrXMLFileReadCallBack(file));
}
} // end namespace
} // end namespace