~baltix/+junk/irrlicht-test

« back to all changes in this revision

Viewing changes to source/Irrlicht/CXMLReader.cpp

  • Committer: Mantas Kriaučiūnas
  • Date: 2011-07-18 13:06:25 UTC
  • Revision ID: mantas@akl.lt-20110718130625-c5pvifp61e7kj1ol
Included whole irrlicht SVN libraries to work around launchpad recipe issue with quilt, see https://answers.launchpad.net/launchpad/+question/165193

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
// Copyright (C) 2002-2011 Nikolaus Gebhardt
 
2
// This file is part of the "Irrlicht Engine".
 
3
// For conditions of distribution and use, see copyright notice in irrlicht.h
 
4
 
 
5
#include "CXMLReaderImpl.h"
 
6
#include "CXMLReader.h"
 
7
#include "IReadFile.h"
 
8
 
 
9
namespace irr
 
10
{
 
11
namespace io
 
12
{
 
13
        //! Irrlicht implementation of the file read callback for the xml parser
 
14
        class CIrrXMLFileReadCallBack : public IFileReadCallBack
 
15
        {
 
16
        public:
 
17
 
 
18
                //! construct from FILE pointer
 
19
                CIrrXMLFileReadCallBack(IReadFile* file)
 
20
                        : ReadFile(file)
 
21
                {
 
22
                        ReadFile->grab();
 
23
                }
 
24
 
 
25
                //! destructor
 
26
                virtual ~CIrrXMLFileReadCallBack()
 
27
                {
 
28
                        ReadFile->drop();
 
29
                }
 
30
 
 
31
                //! Reads an amount of bytes from the file.
 
32
                virtual int read(void* buffer, int sizeToRead)
 
33
                {
 
34
                        return ReadFile->read(buffer, sizeToRead);
 
35
                }
 
36
 
 
37
                //! Returns size of file in bytes
 
38
                virtual long getSize() const
 
39
                {
 
40
                        return ReadFile->getSize();
 
41
                }
 
42
 
 
43
        private:
 
44
 
 
45
                IReadFile* ReadFile;
 
46
        }; // end class CMyXMLFileReadCallBack
 
47
 
 
48
 
 
49
        // now create an implementation for IXMLReader using irrXML.
 
50
 
 
51
        //! Creates an instance of a wide character xml parser. 
 
52
        IXMLReader* createIXMLReader(IReadFile* file)
 
53
        {
 
54
                if (!file)
 
55
                        return 0;
 
56
 
 
57
                return new CXMLReaderImpl<wchar_t, IReferenceCounted>(new CIrrXMLFileReadCallBack(file)); 
 
58
        }
 
59
 
 
60
        //! Creates an instance of an UFT-8 or ASCII character xml parser. 
 
61
        IXMLReaderUTF8* createIXMLReaderUTF8(IReadFile* file)
 
62
        {
 
63
                if (!file)
 
64
                        return 0;
 
65
 
 
66
                return new CXMLReaderImpl<char, IReferenceCounted>(new CIrrXMLFileReadCallBack(file)); 
 
67
        }
 
68
 
 
69
} // end namespace
 
70
} // end namespace