nuclear@0: /* nuclear@0: --------------------------------------------------------------------------- nuclear@0: Open Asset Import Library (assimp) nuclear@0: --------------------------------------------------------------------------- nuclear@0: nuclear@0: Copyright (c) 2006-2018, assimp team nuclear@0: nuclear@0: nuclear@0: nuclear@0: All rights reserved. nuclear@0: nuclear@0: Redistribution and use of this software in source and binary forms, nuclear@0: with or without modification, are permitted provided that the following nuclear@0: conditions are met: nuclear@0: nuclear@0: * Redistributions of source code must retain the above nuclear@0: copyright notice, this list of conditions and the nuclear@0: following disclaimer. nuclear@0: nuclear@0: * Redistributions in binary form must reproduce the above nuclear@0: copyright notice, this list of conditions and the nuclear@0: following disclaimer in the documentation and/or other nuclear@0: materials provided with the distribution. nuclear@0: nuclear@0: * Neither the name of the assimp team, nor the names of its nuclear@0: contributors may be used to endorse or promote products nuclear@0: derived from this software without specific prior nuclear@0: written permission of the assimp team. nuclear@0: nuclear@0: THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS nuclear@0: "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT nuclear@0: LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR nuclear@0: A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT nuclear@0: OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, nuclear@0: SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT nuclear@0: LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, nuclear@0: DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY nuclear@0: THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT nuclear@0: (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE nuclear@0: OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. nuclear@0: --------------------------------------------------------------------------- nuclear@0: */ nuclear@0: /** @file IOStream.hpp nuclear@0: * @brief File I/O wrappers for C++. nuclear@0: */ nuclear@0: nuclear@0: #pragma once nuclear@0: #ifndef AI_IOSTREAM_H_INC nuclear@0: #define AI_IOSTREAM_H_INC nuclear@0: nuclear@0: #include "types.h" nuclear@0: nuclear@0: #ifndef __cplusplus nuclear@0: # error This header requires C++ to be used. aiFileIO.h is the \ nuclear@0: corresponding C interface. nuclear@0: #endif nuclear@0: nuclear@0: namespace Assimp { nuclear@0: nuclear@0: // ---------------------------------------------------------------------------------- nuclear@0: /** @brief CPP-API: Class to handle file I/O for C++ nuclear@0: * nuclear@0: * Derive an own implementation from this interface to provide custom IO handling nuclear@0: * to the Importer. If you implement this interface, be sure to also provide an nuclear@0: * implementation for IOSystem that creates instances of your custom IO class. nuclear@0: */ nuclear@0: class ASSIMP_API IOStream nuclear@0: #ifndef SWIG nuclear@0: : public Intern::AllocateFromAssimpHeap nuclear@0: #endif nuclear@0: { nuclear@0: protected: nuclear@0: /** Constructor protected, use IOSystem::Open() to create an instance. */ nuclear@0: IOStream() AI_NO_EXCEPT; nuclear@0: nuclear@0: public: nuclear@0: // ------------------------------------------------------------------- nuclear@0: /** @brief Destructor. Deleting the object closes the underlying file, nuclear@0: * alternatively you may use IOSystem::Close() to release the file. nuclear@0: */ nuclear@0: virtual ~IOStream(); nuclear@0: nuclear@0: // ------------------------------------------------------------------- nuclear@0: /** @brief Read from the file nuclear@0: * nuclear@0: * See fread() for more details nuclear@0: * This fails for write-only files */ nuclear@0: virtual size_t Read(void* pvBuffer, nuclear@0: size_t pSize, nuclear@0: size_t pCount) = 0; nuclear@0: nuclear@0: // ------------------------------------------------------------------- nuclear@0: /** @brief Write to the file nuclear@0: * nuclear@0: * See fwrite() for more details nuclear@0: * This fails for read-only files */ nuclear@0: virtual size_t Write(const void* pvBuffer, nuclear@0: size_t pSize, nuclear@0: size_t pCount) = 0; nuclear@0: nuclear@0: // ------------------------------------------------------------------- nuclear@0: /** @brief Set the read/write cursor of the file nuclear@0: * nuclear@0: * Note that the offset is _negative_ for aiOrigin_END. nuclear@0: * See fseek() for more details */ nuclear@0: virtual aiReturn Seek(size_t pOffset, nuclear@0: aiOrigin pOrigin) = 0; nuclear@0: nuclear@0: // ------------------------------------------------------------------- nuclear@0: /** @brief Get the current position of the read/write cursor nuclear@0: * nuclear@0: * See ftell() for more details */ nuclear@0: virtual size_t Tell() const = 0; nuclear@0: nuclear@0: // ------------------------------------------------------------------- nuclear@0: /** @brief Returns filesize nuclear@0: * Returns the filesize. */ nuclear@0: virtual size_t FileSize() const = 0; nuclear@0: nuclear@0: // ------------------------------------------------------------------- nuclear@0: /** @brief Flush the contents of the file buffer (for writers) nuclear@0: * See fflush() for more details. nuclear@0: */ nuclear@0: virtual void Flush() = 0; nuclear@0: }; //! class IOStream nuclear@0: nuclear@0: // ---------------------------------------------------------------------------------- nuclear@0: inline nuclear@0: IOStream::IOStream() AI_NO_EXCEPT { nuclear@0: // empty nuclear@0: } nuclear@0: nuclear@0: // ---------------------------------------------------------------------------------- nuclear@0: inline nuclear@0: IOStream::~IOStream() { nuclear@0: // empty nuclear@0: } nuclear@0: // ---------------------------------------------------------------------------------- nuclear@0: nuclear@0: } //!namespace Assimp nuclear@0: nuclear@0: #endif //!!AI_IOSTREAM_H_INC