vrshoot

diff libs/assimp/assimp/IOSystem.hpp @ 0:b2f14e535253

initial commit
author John Tsiombikas <nuclear@member.fsf.org>
date Sat, 01 Feb 2014 19:58:19 +0200
parents
children
line diff
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/libs/assimp/assimp/IOSystem.hpp	Sat Feb 01 19:58:19 2014 +0200
     1.3 @@ -0,0 +1,222 @@
     1.4 +/*
     1.5 +---------------------------------------------------------------------------
     1.6 +Open Asset Import Library (assimp)
     1.7 +---------------------------------------------------------------------------
     1.8 +
     1.9 +Copyright (c) 2006-2012, assimp team
    1.10 +
    1.11 +All rights reserved.
    1.12 +
    1.13 +Redistribution and use of this software in source and binary forms, 
    1.14 +with or without modification, are permitted provided that the following 
    1.15 +conditions are met:
    1.16 +
    1.17 +* Redistributions of source code must retain the above
    1.18 +  copyright notice, this list of conditions and the
    1.19 +  following disclaimer.
    1.20 +
    1.21 +* Redistributions in binary form must reproduce the above
    1.22 +  copyright notice, this list of conditions and the
    1.23 +  following disclaimer in the documentation and/or other
    1.24 +  materials provided with the distribution.
    1.25 +
    1.26 +* Neither the name of the assimp team, nor the names of its
    1.27 +  contributors may be used to endorse or promote products
    1.28 +  derived from this software without specific prior
    1.29 +  written permission of the assimp team.
    1.30 +
    1.31 +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 
    1.32 +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 
    1.33 +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
    1.34 +A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 
    1.35 +OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
    1.36 +SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 
    1.37 +LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
    1.38 +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 
    1.39 +THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 
    1.40 +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 
    1.41 +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
    1.42 +---------------------------------------------------------------------------
    1.43 +*/
    1.44 +
    1.45 +/** @file IOSystem.h
    1.46 + *  @brief File system wrapper for C++. Inherit this class to supply
    1.47 + *  custom file handling logic to the Import library.
    1.48 +*/
    1.49 +
    1.50 +#ifndef AI_IOSYSTEM_H_INC
    1.51 +#define AI_IOSYSTEM_H_INC
    1.52 +
    1.53 +#ifndef __cplusplus
    1.54 +#	error This header requires C++ to be used. aiFileIO.h is the \
    1.55 +	corresponding C interface.
    1.56 +#endif
    1.57 +
    1.58 +#include "types.h"
    1.59 +namespace Assimp	{
    1.60 +class IOStream;
    1.61 +
    1.62 +// ---------------------------------------------------------------------------
    1.63 +/** @brief CPP-API: Interface to the file system.
    1.64 + *
    1.65 + *  Derive an own implementation from this interface to supply custom file handling
    1.66 + *  to the importer library. If you implement this interface, you also want to
    1.67 + *  supply a custom implementation for IOStream.
    1.68 + *
    1.69 + *  @see Importer::SetIOHandler() */
    1.70 +class ASSIMP_API IOSystem : public Intern::AllocateFromAssimpHeap
    1.71 +{
    1.72 +public:
    1.73 +
    1.74 +	// -------------------------------------------------------------------
    1.75 +	/** @brief Default constructor.
    1.76 +	 *
    1.77 +	 *  Create an instance of your derived class and assign it to an 
    1.78 +	 *  #Assimp::Importer instance by calling Importer::SetIOHandler().
    1.79 +	 */
    1.80 +	IOSystem();
    1.81 +
    1.82 +	// -------------------------------------------------------------------
    1.83 +	/** @brief Virtual destructor.
    1.84 +	 *
    1.85 +	 *  It is safe to be called from within DLL Assimp, we're constructed
    1.86 +	 *  on Assimp's heap.
    1.87 +	 */
    1.88 +	virtual ~IOSystem();
    1.89 +
    1.90 +
    1.91 +public:
    1.92 +
    1.93 +	// -------------------------------------------------------------------
    1.94 +	/** @brief For backward compatibility
    1.95 +	 *  @see Exists(const char*)
    1.96 +	 */
    1.97 +	AI_FORCE_INLINE bool Exists( const std::string& pFile) const;
    1.98 +
    1.99 +	// -------------------------------------------------------------------
   1.100 +	/** @brief Tests for the existence of a file at the given path. 
   1.101 +	 *
   1.102 +	 * @param pFile Path to the file
   1.103 +	 * @return true if there is a file with this path, else false.
   1.104 +	 */
   1.105 +
   1.106 +	virtual bool Exists( const char* pFile) const = 0;
   1.107 +
   1.108 +
   1.109 +
   1.110 +	// -------------------------------------------------------------------
   1.111 +	/**	@brief Returns the system specific directory separator
   1.112 +	 *	@return	System specific directory separator
   1.113 +	 */
   1.114 +	virtual char getOsSeparator() const = 0;
   1.115 +
   1.116 +
   1.117 +	// -------------------------------------------------------------------
   1.118 +	/** @brief Open a new file with a given path.
   1.119 +	 *
   1.120 +	 *  When the access to the file is finished, call Close() to release
   1.121 +	 *  all associated resources (or the virtual dtor of the IOStream).
   1.122 +	 *
   1.123 +	 *  @param pFile Path to the file
   1.124 +	 *  @param pMode Desired file I/O mode. Required are: "wb", "w", "wt",
   1.125 +	 *         "rb", "r", "rt".
   1.126 +	 *
   1.127 +	 *  @return New IOStream interface allowing the lib to access
   1.128 +	 *         the underlying file. 
   1.129 +	 *  @note When implementing this class to provide custom IO handling, 
   1.130 +	 *  you probably have to supply an own implementation of IOStream as well. 
   1.131 +	 */
   1.132 +	virtual IOStream* Open(const char* pFile,
   1.133 +		const char* pMode = "rb") = 0;
   1.134 +
   1.135 +	// -------------------------------------------------------------------
   1.136 +	/** @brief For backward compatibility
   1.137 +	 *  @see Open(const char*, const char*)
   1.138 +	 */
   1.139 +	inline IOStream* Open(const std::string& pFile,
   1.140 +		const std::string& pMode = std::string("rb"));
   1.141 +
   1.142 +
   1.143 +
   1.144 +	// -------------------------------------------------------------------
   1.145 +	/** @brief Closes the given file and releases all resources 
   1.146 +	 *    associated with it.
   1.147 +	 *  @param pFile The file instance previously created by Open().
   1.148 +	 */
   1.149 +	virtual void Close( IOStream* pFile) = 0;
   1.150 +
   1.151 +	// -------------------------------------------------------------------
   1.152 +	/** @brief Compares two paths and check whether the point to
   1.153 +	 *         identical files.
   1.154 +	 *  
   1.155 +	 * The dummy implementation of this virtual member performs a 
   1.156 +	 * case-insensitive comparison of the given strings. The default IO
   1.157 +	 * system implementation uses OS mechanisms to convert relative into
   1.158 +	 * absolute paths, so the result can be trusted.
   1.159 +	 * @param one First file
   1.160 +	 * @param second Second file
   1.161 +	 * @return true if the paths point to the same file. The file needn't
   1.162 +	 *   be existing, however.
   1.163 +	 */
   1.164 +	virtual bool ComparePaths (const char* one, 
   1.165 +		const char* second) const;
   1.166 +
   1.167 +	// -------------------------------------------------------------------
   1.168 +	/** @brief For backward compatibility
   1.169 +	 *  @see ComparePaths(const char*, const char*)
   1.170 +	 */
   1.171 +	inline bool ComparePaths (const std::string& one, 
   1.172 +		const std::string& second) const;
   1.173 +};
   1.174 +
   1.175 +// ----------------------------------------------------------------------------
   1.176 +AI_FORCE_INLINE IOSystem::IOSystem() 
   1.177 +{
   1.178 +	// empty
   1.179 +}
   1.180 +
   1.181 +// ----------------------------------------------------------------------------
   1.182 +AI_FORCE_INLINE IOSystem::~IOSystem() 
   1.183 +{
   1.184 +	// empty
   1.185 +}
   1.186 +
   1.187 +// ----------------------------------------------------------------------------
   1.188 +// For compatibility, the interface of some functions taking a std::string was
   1.189 +// changed to const char* to avoid crashes between binary incompatible STL 
   1.190 +// versions. This code her is inlined,  so it shouldn't cause any problems.
   1.191 +// ----------------------------------------------------------------------------
   1.192 +
   1.193 +// ----------------------------------------------------------------------------
   1.194 +AI_FORCE_INLINE IOStream* IOSystem::Open(const std::string& pFile,
   1.195 +	const std::string& pMode)
   1.196 +{
   1.197 +	// NOTE:
   1.198 +	// For compatibility, interface was changed to const char* to
   1.199 +	// avoid crashes between binary incompatible STL versions 
   1.200 +	return Open(pFile.c_str(),pMode.c_str());
   1.201 +}
   1.202 +
   1.203 +// ----------------------------------------------------------------------------
   1.204 +AI_FORCE_INLINE bool IOSystem::Exists( const std::string& pFile) const
   1.205 +{
   1.206 +	// NOTE:
   1.207 +	// For compatibility, interface was changed to const char* to
   1.208 +	// avoid crashes between binary incompatible STL versions 
   1.209 +	return Exists(pFile.c_str());
   1.210 +}
   1.211 +
   1.212 +// ----------------------------------------------------------------------------
   1.213 +inline bool IOSystem::ComparePaths (const std::string& one, 
   1.214 +	const std::string& second) const
   1.215 +{
   1.216 +	// NOTE:
   1.217 +	// For compatibility, interface was changed to const char* to
   1.218 +	// avoid crashes between binary incompatible STL versions 
   1.219 +	return ComparePaths(one.c_str(),second.c_str());
   1.220 +}
   1.221 +
   1.222 +// ----------------------------------------------------------------------------
   1.223 +} //!ns Assimp
   1.224 +
   1.225 +#endif //AI_IOSYSTEM_H_INC