Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-02-21 09:30:08

0001 /*
0002 ---------------------------------------------------------------------------
0003 Open Asset Import Library (assimp)
0004 ---------------------------------------------------------------------------
0005 
0006 Copyright (c) 2006-2024, assimp team
0007 
0008 All rights reserved.
0009 
0010 Redistribution and use of this software in source and binary forms,
0011 with or without modification, are permitted provided that the following
0012 conditions are met:
0013 
0014 * Redistributions of source code must retain the above
0015   copyright notice, this list of conditions and the
0016   following disclaimer.
0017 
0018 * Redistributions in binary form must reproduce the above
0019   copyright notice, this list of conditions and the
0020   following disclaimer in the documentation and/or other
0021   materials provided with the distribution.
0022 
0023 * Neither the name of the assimp team, nor the names of its
0024   contributors may be used to endorse or promote products
0025   derived from this software without specific prior
0026   written permission of the assimp team.
0027 
0028 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
0029 "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
0030 LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
0031 A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
0032 OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
0033 SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
0034 LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
0035 DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
0036 THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
0037 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
0038 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
0039 ---------------------------------------------------------------------------
0040 */
0041 /** @file IOStream.hpp
0042  *  @brief File I/O wrappers for C++.
0043  */
0044 
0045 #pragma once
0046 #ifndef AI_IOSTREAM_H_INC
0047 #define AI_IOSTREAM_H_INC
0048 
0049 #ifdef __GNUC__
0050 #   pragma GCC system_header
0051 #endif
0052 
0053 #include <assimp/types.h>
0054 
0055 #ifndef __cplusplus
0056 #   error This header requires C++ to be used. aiFileIO.h is the \
0057     corresponding C interface.
0058 #endif
0059 
0060 namespace Assimp {
0061 
0062 // ----------------------------------------------------------------------------------
0063 /** @brief CPP-API: Class to handle file I/O for C++
0064  *
0065  *  Derive an own implementation from this interface to provide custom IO handling
0066  *  to the Importer. If you implement this interface, be sure to also provide an
0067  *  implementation for IOSystem that creates instances of your custom IO class.
0068 */
0069 class ASSIMP_API IOStream
0070 #ifndef SWIG
0071     : public Intern::AllocateFromAssimpHeap
0072 #endif
0073 {
0074 protected:
0075     /** Constructor protected, use IOSystem::Open() to create an instance. */
0076     IOStream() AI_NO_EXCEPT = default;
0077 
0078 public:
0079     // -------------------------------------------------------------------
0080     /** @brief Destructor. Deleting the object closes the underlying file,
0081      * alternatively you may use IOSystem::Close() to release the file.
0082      */
0083     virtual ~IOStream() = default;
0084 
0085     // -------------------------------------------------------------------
0086     /** @brief Read from the file
0087      *
0088      * See fread() for more details
0089      * This fails for write-only files */
0090     virtual size_t Read(void* pvBuffer,
0091         size_t pSize,
0092         size_t pCount) = 0;
0093 
0094     // -------------------------------------------------------------------
0095     /** @brief Write to the file
0096     *
0097     * See fwrite() for more details
0098     * This fails for read-only files */
0099     virtual size_t Write(const void* pvBuffer,
0100         size_t pSize,
0101         size_t pCount) = 0;
0102 
0103     // -------------------------------------------------------------------
0104     /** @brief Set the read/write cursor of the file
0105      *
0106      * Note that the offset is _negative_ for aiOrigin_END.
0107      * See fseek() for more details */
0108     virtual aiReturn Seek(size_t pOffset,
0109         aiOrigin pOrigin) = 0;
0110 
0111     // -------------------------------------------------------------------
0112     /** @brief Get the current position of the read/write cursor
0113      *
0114      * See ftell() for more details */
0115     virtual size_t Tell() const = 0;
0116 
0117     // -------------------------------------------------------------------
0118     /** @brief Returns filesize
0119      *  Returns the filesize. */
0120     virtual size_t FileSize() const = 0;
0121 
0122     // -------------------------------------------------------------------
0123     /** @brief Flush the contents of the file buffer (for writers)
0124      *  See fflush() for more details.
0125      */
0126     virtual void Flush() = 0;
0127 }; //! class IOStream
0128 
0129 } //!namespace Assimp
0130 
0131 #endif //!!AI_IOSTREAM_H_INC