diff options
author | David Walter Seikel | 2016-03-28 22:28:34 +1000 |
---|---|---|
committer | David Walter Seikel | 2016-03-28 22:28:34 +1000 |
commit | 7028cbe09c688437910a25623098762bf0fa592d (patch) | |
tree | 10b5af58277d9880380c2251f109325542c4e6eb /src/others/irrlicht-1.8.1/source/Irrlicht/CXMLReader.cpp | |
parent | Move lemon to the src/others directory. (diff) | |
download | SledjHamr-7028cbe09c688437910a25623098762bf0fa592d.zip SledjHamr-7028cbe09c688437910a25623098762bf0fa592d.tar.gz SledjHamr-7028cbe09c688437910a25623098762bf0fa592d.tar.bz2 SledjHamr-7028cbe09c688437910a25623098762bf0fa592d.tar.xz |
Move Irrlicht to src/others.
Diffstat (limited to 'src/others/irrlicht-1.8.1/source/Irrlicht/CXMLReader.cpp')
-rw-r--r-- | src/others/irrlicht-1.8.1/source/Irrlicht/CXMLReader.cpp | 70 |
1 files changed, 70 insertions, 0 deletions
diff --git a/src/others/irrlicht-1.8.1/source/Irrlicht/CXMLReader.cpp b/src/others/irrlicht-1.8.1/source/Irrlicht/CXMLReader.cpp new file mode 100644 index 0000000..bb42800 --- /dev/null +++ b/src/others/irrlicht-1.8.1/source/Irrlicht/CXMLReader.cpp | |||
@@ -0,0 +1,70 @@ | |||
1 | // Copyright (C) 2002-2012 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 | ||