miniassimp

view src/CInterfaceIOWrapper.h @ 0:879c81d94345

initial commit
author John Tsiombikas <nuclear@member.fsf.org>
date Mon, 28 Jan 2019 18:19:26 +0200
parents
children
line source
1 /*
2 ---------------------------------------------------------------------------
3 Open Asset Import Library (assimp)
4 ---------------------------------------------------------------------------
6 Copyright (c) 2006-2018, assimp team
10 All rights reserved.
12 Redistribution and use of this software in source and binary forms,
13 with or without modification, are permitted provided that the following
14 conditions are met:
16 * Redistributions of source code must retain the above
17 copyright notice, this list of conditions and the
18 following disclaimer.
20 * Redistributions in binary form must reproduce the above
21 copyright notice, this list of conditions and the
22 following disclaimer in the documentation and/or other
23 materials provided with the distribution.
25 * Neither the name of the assimp team, nor the names of its
26 contributors may be used to endorse or promote products
27 derived from this software without specific prior
28 written permission of the assimp team.
30 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
31 "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
32 LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
33 A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
34 OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
35 SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
36 LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
37 DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
38 THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
39 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
40 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
41 ---------------------------------------------------------------------------
42 */
44 /** @file aiFileIO -> IOSystem wrapper*/
46 #ifndef AI_CIOSYSTEM_H_INCLUDED
47 #define AI_CIOSYSTEM_H_INCLUDED
49 #include <miniassimp/cfileio.h>
50 #include <miniassimp/IOStream.hpp>
51 #include <miniassimp/IOSystem.hpp>
53 namespace Assimp {
55 class CIOSystemWrapper;
57 // ------------------------------------------------------------------------------------------------
58 // Custom IOStream implementation for the C-API
59 class CIOStreamWrapper : public IOStream
60 {
61 public:
62 explicit CIOStreamWrapper(aiFile* pFile, CIOSystemWrapper* io)
63 : mFile(pFile),
64 mIO(io)
65 {}
66 ~CIOStreamWrapper(void);
68 size_t Read(void* pvBuffer, size_t pSize, size_t pCount);
69 size_t Write(const void* pvBuffer, size_t pSize, size_t pCount);
70 aiReturn Seek(size_t pOffset, aiOrigin pOrigin);
71 size_t Tell(void) const;
72 size_t FileSize() const;
73 void Flush();
75 private:
76 aiFile* mFile;
77 CIOSystemWrapper* mIO;
78 };
80 class CIOSystemWrapper : public IOSystem
81 {
82 friend class CIOStreamWrapper;
83 public:
84 explicit CIOSystemWrapper(aiFileIO* pFile)
85 : mFileSystem(pFile)
86 {}
88 bool Exists( const char* pFile) const;
89 char getOsSeparator() const;
90 IOStream* Open(const char* pFile,const char* pMode = "rb");
91 void Close( IOStream* pFile);
92 private:
93 aiFileIO* mFileSystem;
94 };
96 }
98 #endif