vrshoot

view libs/assimp/assimp/IOStream.hpp @ 0:b2f14e535253

initial commit
author John Tsiombikas <nuclear@member.fsf.org>
date Sat, 01 Feb 2014 19:58:19 +0200
parents
children
line source
1 /*
2 ---------------------------------------------------------------------------
3 Open Asset Import Library (assimp)
4 ---------------------------------------------------------------------------
6 Copyright (c) 2006-2012, assimp team
8 All rights reserved.
10 Redistribution and use of this software in source and binary forms,
11 with or without modification, are permitted provided that the following
12 conditions are met:
14 * Redistributions of source code must retain the above
15 copyright notice, this list of conditions and the
16 following disclaimer.
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.
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.
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 /** @file IOStream.h
42 * @brief File I/O wrappers for C++.
43 */
45 #ifndef AI_IOSTREAM_H_INC
46 #define AI_IOSTREAM_H_INC
48 #include "types.h"
50 #ifndef __cplusplus
51 # error This header requires C++ to be used. aiFileIO.h is the \
52 corresponding C interface.
53 #endif
55 namespace Assimp {
57 // ----------------------------------------------------------------------------------
58 /** @brief CPP-API: Class to handle file I/O for C++
59 *
60 * Derive an own implementation from this interface to provide custom IO handling
61 * to the Importer. If you implement this interface, be sure to also provide an
62 * implementation for IOSystem that creates instances of your custom IO class.
63 */
64 class ASSIMP_API IOStream : public Intern::AllocateFromAssimpHeap
65 {
66 protected:
67 /** Constructor protected, use IOSystem::Open() to create an instance. */
68 IOStream(void);
70 public:
71 // -------------------------------------------------------------------
72 /** @brief Destructor. Deleting the object closes the underlying file,
73 * alternatively you may use IOSystem::Close() to release the file.
74 */
75 virtual ~IOStream();
77 // -------------------------------------------------------------------
78 /** @brief Read from the file
79 *
80 * See fread() for more details
81 * This fails for write-only files */
82 virtual size_t Read(void* pvBuffer,
83 size_t pSize,
84 size_t pCount) = 0;
86 // -------------------------------------------------------------------
87 /** @brief Write to the file
88 *
89 * See fwrite() for more details
90 * This fails for read-only files */
91 virtual size_t Write(const void* pvBuffer,
92 size_t pSize,
93 size_t pCount) = 0;
95 // -------------------------------------------------------------------
96 /** @brief Set the read/write cursor of the file
97 *
98 * Note that the offset is _negative_ for aiOrigin_END.
99 * See fseek() for more details */
100 virtual aiReturn Seek(size_t pOffset,
101 aiOrigin pOrigin) = 0;
103 // -------------------------------------------------------------------
104 /** @brief Get the current position of the read/write cursor
105 *
106 * See ftell() for more details */
107 virtual size_t Tell() const = 0;
109 // -------------------------------------------------------------------
110 /** @brief Returns filesize
111 * Returns the filesize. */
112 virtual size_t FileSize() const = 0;
114 // -------------------------------------------------------------------
115 /** @brief Flush the contents of the file buffer (for writers)
116 * See fflush() for more details.
117 */
118 virtual void Flush() = 0;
119 }; //! class IOStream
121 // ----------------------------------------------------------------------------------
122 inline IOStream::IOStream()
123 {
124 // empty
125 }
127 // ----------------------------------------------------------------------------------
128 inline IOStream::~IOStream()
129 {
130 // empty
131 }
132 // ----------------------------------------------------------------------------------
133 } //!namespace Assimp
135 #endif //!!AI_IOSTREAM_H_INC