Path Tracer
DefaultIOStream.h
1 /*
2 Open Asset Import Library (assimp)
3 ----------------------------------------------------------------------
4 
5 Copyright (c) 2006-2020, assimp team
6 
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
12 following 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 */
42 
44 #pragma once
45 #ifndef AI_DEFAULTIOSTREAM_H_INC
46 #define AI_DEFAULTIOSTREAM_H_INC
47 
48 #ifdef __GNUC__
49 # pragma GCC system_header
50 #endif
51 
52 #include <stdio.h>
53 #include <assimp/IOStream.hpp>
54 #include <assimp/importerdesc.h>
55 #include <assimp/Defines.h>
56 
57 namespace Assimp {
58 
59 // ----------------------------------------------------------------------------------
65 class ASSIMP_API DefaultIOStream : public IOStream {
66  friend class DefaultIOSystem;
67 #if __ANDROID__
68 # if __ANDROID_API__ > 9
69 # if defined(AI_CONFIG_ANDROID_JNI_ASSIMP_MANAGER_SUPPORT)
70  friend class AndroidJNIIOSystem;
71 # endif // defined(AI_CONFIG_ANDROID_JNI_ASSIMP_MANAGER_SUPPORT)
72 # endif // __ANDROID_API__ > 9
73 #endif // __ANDROID__
74 
75 protected:
76  DefaultIOStream() AI_NO_EXCEPT;
77  DefaultIOStream(FILE* pFile, const std::string &strFilename);
78 
79 public:
82 
83  // -------------------------------------------------------------------
85  size_t Read(void* pvBuffer,
86  size_t pSize,
87  size_t pCount);
88 
89  // -------------------------------------------------------------------
91  size_t Write(const void* pvBuffer,
92  size_t pSize,
93  size_t pCount);
94 
95  // -------------------------------------------------------------------
97  aiReturn Seek(size_t pOffset,
98  aiOrigin pOrigin);
99 
100  // -------------------------------------------------------------------
102  size_t Tell() const;
103 
104  // -------------------------------------------------------------------
106  size_t FileSize() const;
107 
108  // -------------------------------------------------------------------
110  void Flush();
111 
112 private:
113  FILE* mFile;
114  std::string mFilename;
115  mutable size_t mCachedSize;
116 };
117 
118 // ----------------------------------------------------------------------------------
119 AI_FORCE_INLINE
120 DefaultIOStream::DefaultIOStream() AI_NO_EXCEPT
121 : mFile(nullptr)
122 , mFilename("")
123 , mCachedSize(SIZE_MAX) {
124  // empty
125 }
126 
127 // ----------------------------------------------------------------------------------
128 AI_FORCE_INLINE
129 DefaultIOStream::DefaultIOStream (FILE* pFile, const std::string &strFilename)
130 : mFile(pFile)
131 , mFilename(strFilename)
132 , mCachedSize(SIZE_MAX) {
133  // empty
134 }
135 // ----------------------------------------------------------------------------------
136 
137 } // ns assimp
138 
139 #endif
Assimp::DefaultIOStream::Flush
void Flush()
Flush file contents.
Assimp::DefaultIOStream::Write
size_t Write(const void *pvBuffer, size_t pSize, size_t pCount)
Write to stream.
aiOrigin
aiOrigin
Definition: types.h:426
Assimp::DefaultIOSystem
Definition: DefaultIOSystem.h:58
Assimp::DefaultIOStream::~DefaultIOStream
~DefaultIOStream()
aiReturn
aiReturn
Definition: types.h:397
Assimp::DefaultIOStream::Tell
size_t Tell() const
Get current seek position.
Assimp::DefaultIOStream
Default IO implementation, use standard IO operations.
Definition: DefaultIOStream.h:65
Assimp::DefaultIOStream::Read
size_t Read(void *pvBuffer, size_t pSize, size_t pCount)
Read from stream.
IOStream.hpp
File I/O wrappers for C++.
importerdesc.h
aiImporterFlags, aiImporterDesc implementation.
Assimp
Definition: ai_assert.h:50
Assimp::IOStream
CPP-API: Class to handle file I/O for C++.
Definition: IOStream.hpp:75
Assimp::DefaultIOStream::FileSize
size_t FileSize() const
Get size of file.
Assimp::DefaultIOStream::Seek
aiReturn Seek(size_t pOffset, aiOrigin pOrigin)
Seek specific position.