miniassimp

view include/miniassimp/cfileio.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 cfileio.h
45 * @brief Defines generic C routines to access memory-mapped files
46 */
47 #pragma once
48 #ifndef AI_FILEIO_H_INC
49 #define AI_FILEIO_H_INC
51 #include <miniassimp/types.h>
52 #ifdef __cplusplus
53 extern "C" {
54 #endif
55 struct aiFileIO;
56 struct aiFile;
58 // aiFile callbacks
59 typedef size_t (*aiFileWriteProc) (C_STRUCT aiFile*, const char*, size_t, size_t);
60 typedef size_t (*aiFileReadProc) (C_STRUCT aiFile*, char*, size_t,size_t);
61 typedef size_t (*aiFileTellProc) (C_STRUCT aiFile*);
62 typedef void (*aiFileFlushProc) (C_STRUCT aiFile*);
63 typedef C_ENUM aiReturn (*aiFileSeek) (C_STRUCT aiFile*, size_t, C_ENUM aiOrigin);
65 // aiFileIO callbacks
66 typedef C_STRUCT aiFile* (*aiFileOpenProc) (C_STRUCT aiFileIO*, const char*, const char*);
67 typedef void (*aiFileCloseProc) (C_STRUCT aiFileIO*, C_STRUCT aiFile*);
69 // Represents user-defined data
70 typedef char* aiUserData;
72 // ----------------------------------------------------------------------------------
73 /** @brief C-API: File system callbacks
74 *
75 * Provided are functions to open and close files. Supply a custom structure to
76 * the import function. If you don't, a default implementation is used. Use custom
77 * file systems to enable reading from other sources, such as ZIPs
78 * or memory locations. */
79 struct aiFileIO
80 {
81 /** Function used to open a new file
82 */
83 aiFileOpenProc OpenProc;
85 /** Function used to close an existing file
86 */
87 aiFileCloseProc CloseProc;
89 /** User-defined, opaque data */
90 aiUserData UserData;
91 };
93 // ----------------------------------------------------------------------------------
94 /** @brief C-API: File callbacks
95 *
96 * Actually, it's a data structure to wrap a set of fXXXX (e.g fopen)
97 * replacement functions.
98 *
99 * The default implementation of the functions utilizes the fXXX functions from
100 * the CRT. However, you can supply a custom implementation to Assimp by
101 * delivering a custom aiFileIO. Use this to enable reading from other sources,
102 * such as ZIP archives or memory locations. */
103 struct aiFile
104 {
105 /** Callback to read from a file */
106 aiFileReadProc ReadProc;
108 /** Callback to write to a file */
109 aiFileWriteProc WriteProc;
111 /** Callback to retrieve the current position of
112 * the file cursor (ftell())
113 */
114 aiFileTellProc TellProc;
116 /** Callback to retrieve the size of the file,
117 * in bytes
118 */
119 aiFileTellProc FileSizeProc;
121 /** Callback to set the current position
122 * of the file cursor (fseek())
123 */
124 aiFileSeek SeekProc;
126 /** Callback to flush the file contents
127 */
128 aiFileFlushProc FlushProc;
130 /** User-defined, opaque data
131 */
132 aiUserData UserData;
133 };
135 #ifdef __cplusplus
136 }
137 #endif
138 #endif // AI_FILEIO_H_INC