aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/libraries/irrlicht-1.8/source/Irrlicht/irrXML.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'libraries/irrlicht-1.8/source/Irrlicht/irrXML.cpp')
-rw-r--r--libraries/irrlicht-1.8/source/Irrlicht/irrXML.cpp180
1 files changed, 0 insertions, 180 deletions
diff --git a/libraries/irrlicht-1.8/source/Irrlicht/irrXML.cpp b/libraries/irrlicht-1.8/source/Irrlicht/irrXML.cpp
deleted file mode 100644
index 06f87d7..0000000
--- a/libraries/irrlicht-1.8/source/Irrlicht/irrXML.cpp
+++ /dev/null
@@ -1,180 +0,0 @@
1// Copyright (C) 2002-2012 Nikolaus Gebhardt
2// This file is part of the "Irrlicht Engine" and the "irrXML" project.
3// For conditions of distribution and use, see copyright notice in irrlicht.h and/or irrXML.h
4
5#include "irrXML.h"
6#include "irrString.h"
7#include "irrArray.h"
8#include "fast_atof.h"
9#include "CXMLReaderImpl.h"
10
11namespace irr
12{
13namespace io
14{
15
16//! Implementation of the file read callback for ordinary files
17class CFileReadCallBack : public IFileReadCallBack
18{
19public:
20
21 //! construct from filename
22 CFileReadCallBack(const char* filename)
23 : File(0), Size(-1), Close(true)
24 {
25 // open file
26 File = fopen(filename, "rb");
27
28 if (File)
29 getFileSize();
30 }
31
32 //! construct from FILE pointer
33 CFileReadCallBack(FILE* file)
34 : File(file), Size(-1), Close(false)
35 {
36 if (File)
37 getFileSize();
38 }
39
40 //! destructor
41 virtual ~CFileReadCallBack()
42 {
43 if (Close && File)
44 fclose(File);
45 }
46
47 //! Reads an amount of bytes from the file.
48 virtual int read(void* buffer, int sizeToRead)
49 {
50 if (!File)
51 return 0;
52
53 return (int)fread(buffer, 1, sizeToRead, File);
54 }
55
56 //! Returns size of file in bytes
57 virtual long getSize() const
58 {
59 return Size;
60 }
61
62private:
63
64 //! retrieves the file size of the open file
65 void getFileSize()
66 {
67 fseek(File, 0, SEEK_END);
68 Size = ftell(File);
69 fseek(File, 0, SEEK_SET);
70 }
71
72 FILE* File;
73 long Size;
74 bool Close;
75
76}; // end class CFileReadCallBack
77
78
79
80// FACTORY FUNCTIONS:
81
82
83//! Creates an instance of an UFT-8 or ASCII character xml parser.
84IRRLICHT_API IrrXMLReader* IRRCALLCONV createIrrXMLReader(const char* filename)
85{
86 return createIrrXMLReader(new CFileReadCallBack(filename), true);
87}
88
89
90//! Creates an instance of an UFT-8 or ASCII character xml parser.
91IRRLICHT_API IrrXMLReader* IRRCALLCONV createIrrXMLReader(FILE* file)
92{
93 return createIrrXMLReader(new CFileReadCallBack(file), true);
94}
95
96
97//! Creates an instance of an UFT-8 or ASCII character xml parser.
98IRRLICHT_API IrrXMLReader* IRRCALLCONV createIrrXMLReader(IFileReadCallBack* callback,
99 bool deleteCallback)
100{
101 if (callback && (callback->getSize() >= 0))
102 {
103 return new CXMLReaderImpl<char, IXMLBase>(callback, deleteCallback);
104 }
105 else
106 {
107 if(callback && deleteCallback)
108 delete callback;
109
110 return 0;
111 }
112}
113
114
115//! Creates an instance of an UTF-16 xml parser.
116IRRLICHT_API IrrXMLReaderUTF16* IRRCALLCONV createIrrXMLReaderUTF16(const char* filename)
117{
118 return createIrrXMLReaderUTF16(new CFileReadCallBack(filename), true);
119}
120
121
122//! Creates an instance of an UTF-16 xml parser.
123IRRLICHT_API IrrXMLReaderUTF16* IRRCALLCONV createIrrXMLReaderUTF16(FILE* file)
124{
125 return createIrrXMLReaderUTF16(new CFileReadCallBack(file), true);
126}
127
128
129//! Creates an instance of an UTF-16 xml parser.
130IRRLICHT_API IrrXMLReaderUTF16* IRRCALLCONV createIrrXMLReaderUTF16(IFileReadCallBack* callback,
131 bool deleteCallback)
132{
133 if (callback && (callback->getSize() >= 0))
134 {
135 return new CXMLReaderImpl<char16, IXMLBase>(callback, deleteCallback);
136 }
137 else
138 {
139 if(callback && deleteCallback)
140 delete callback;
141
142 return 0;
143 }
144}
145
146
147//! Creates an instance of an UTF-32 xml parser.
148IRRLICHT_API IrrXMLReaderUTF32* IRRCALLCONV createIrrXMLReaderUTF32(const char* filename)
149{
150 return createIrrXMLReaderUTF32(new CFileReadCallBack(filename), true);
151}
152
153
154//! Creates an instance of an UTF-32 xml parser.
155IRRLICHT_API IrrXMLReaderUTF32* IRRCALLCONV createIrrXMLReaderUTF32(FILE* file)
156{
157 return createIrrXMLReaderUTF32(new CFileReadCallBack(file), true);
158}
159
160
161//! Creates an instance of an UTF-32 xml parser.
162IRRLICHT_API IrrXMLReaderUTF32* IRRCALLCONV createIrrXMLReaderUTF32(
163 IFileReadCallBack* callback, bool deleteCallback)
164{
165 if (callback && (callback->getSize() >= 0))
166 {
167 return new CXMLReaderImpl<char32, IXMLBase>(callback, deleteCallback);
168 }
169 else
170 {
171 if(callback && deleteCallback)
172 delete callback;
173
174 return 0;
175 }
176}
177
178
179} // end namespace io
180} // end namespace irr