BRE12
IOSystem.hpp
1 /*
2 ---------------------------------------------------------------------------
3 Open Asset Import Library (assimp)
4 ---------------------------------------------------------------------------
5 
6 Copyright (c) 2006-2012, assimp team
7 
8 All rights reserved.
9 
10 Redistribution and use of this software in source and binary forms,
11 with or without modification, are permitted provided that the following
12 conditions are met:
13 
14 * Redistributions of source code must retain the above
15  copyright notice, this list of conditions and the
16  following disclaimer.
17 
18 * Redistributions in binary form must reproduce the above
19  copyright notice, this list of conditions and the
20  following disclaimer in the documentation and/or other
21  materials provided with the distribution.
22 
23 * Neither the name of the assimp team, nor the names of its
24  contributors may be used to endorse or promote products
25  derived from this software without specific prior
26  written permission of the assimp team.
27 
28 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
29 "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
30 LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
31 A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
32 OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
33 SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
34 LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
35 DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
36 THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
37 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
38 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
39 ---------------------------------------------------------------------------
40 */
41 
47 #ifndef AI_IOSYSTEM_H_INC
48 #define AI_IOSYSTEM_H_INC
49 
50 #ifndef __cplusplus
51 # error This header requires C++ to be used. aiFileIO.h is the \
52  corresponding C interface.
53 #endif
54 
55 #include "types.h"
56 namespace Assimp {
57 class IOStream;
58 
59 // ---------------------------------------------------------------------------
67 class ASSIMP_API IOSystem
68 #ifndef SWIG
69  : public Intern::AllocateFromAssimpHeap
70 #endif
71 {
72 public:
73 
74  // -------------------------------------------------------------------
80  IOSystem();
81 
82  // -------------------------------------------------------------------
88  virtual ~IOSystem();
89 
90 
91 public:
92 
93  // -------------------------------------------------------------------
97  AI_FORCE_INLINE bool Exists( const std::string& pFile) const;
98 
99  // -------------------------------------------------------------------
106  virtual bool Exists( const char* pFile) const = 0;
107 
108 
109 
110  // -------------------------------------------------------------------
114  virtual char getOsSeparator() const = 0;
115 
116 
117  // -------------------------------------------------------------------
132  virtual IOStream* Open(const char* pFile,
133  const char* pMode = "rb") = 0;
134 
135  // -------------------------------------------------------------------
139  inline IOStream* Open(const std::string& pFile,
140  const std::string& pMode = std::string("rb"));
141 
142 
143 
144  // -------------------------------------------------------------------
149  virtual void Close( IOStream* pFile) = 0;
150 
151  // -------------------------------------------------------------------
164  virtual bool ComparePaths (const char* one,
165  const char* second) const;
166 
167  // -------------------------------------------------------------------
171  inline bool ComparePaths (const std::string& one,
172  const std::string& second) const;
173 };
174 
175 // ----------------------------------------------------------------------------
176 AI_FORCE_INLINE IOSystem::IOSystem()
177 {
178  // empty
179 }
180 
181 // ----------------------------------------------------------------------------
182 AI_FORCE_INLINE IOSystem::~IOSystem()
183 {
184  // empty
185 }
186 
187 // ----------------------------------------------------------------------------
188 // For compatibility, the interface of some functions taking a std::string was
189 // changed to const char* to avoid crashes between binary incompatible STL
190 // versions. This code her is inlined, so it shouldn't cause any problems.
191 // ----------------------------------------------------------------------------
192 
193 // ----------------------------------------------------------------------------
194 AI_FORCE_INLINE IOStream* IOSystem::Open(const std::string& pFile,
195  const std::string& pMode)
196 {
197  // NOTE:
198  // For compatibility, interface was changed to const char* to
199  // avoid crashes between binary incompatible STL versions
200  return Open(pFile.c_str(),pMode.c_str());
201 }
202 
203 // ----------------------------------------------------------------------------
204 AI_FORCE_INLINE bool IOSystem::Exists( const std::string& pFile) const
205 {
206  // NOTE:
207  // For compatibility, interface was changed to const char* to
208  // avoid crashes between binary incompatible STL versions
209  return Exists(pFile.c_str());
210 }
211 
212 // ----------------------------------------------------------------------------
213 inline bool IOSystem::ComparePaths (const std::string& one,
214  const std::string& second) const
215 {
216  // NOTE:
217  // For compatibility, interface was changed to const char* to
218  // avoid crashes between binary incompatible STL versions
219  return ComparePaths(one.c_str(),second.c_str());
220 }
221 
222 // ----------------------------------------------------------------------------
223 }
224 
225 #endif //AI_IOSYSTEM_H_INC
Basic data types and primitives, such as vectors or colors.
Assimp's CPP-API and all internal APIs.
Definition: DefaultLogger.hpp:51
CPP-API: Class to handle file I/O for C++.
Definition: IOStream.hpp:64
virtual bool ComparePaths(const char *one, const char *second) const
Compares two paths and check whether the point to identical files.
AI_FORCE_INLINE bool Exists(const std::string &pFile) const
For backward compatibility.
Definition: IOSystem.hpp:204
CPP-API: Interface to the file system.
Definition: IOSystem.hpp:67
IOSystem()
Default constructor.
Definition: IOSystem.hpp:176
virtual ~IOSystem()
Virtual destructor.
Definition: IOSystem.hpp:182
virtual IOStream * Open(const char *pFile, const char *pMode="rb")=0
Open a new file with a given path.