v0.1.0
Fast, portable C library for geometry input/output
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Modules
stream.h
Go to the documentation of this file.
1 /****************************************************************************
2 ** gmio
3 ** Copyright Fougue (24 Jun. 2016)
4 ** contact@fougue.pro
5 **
6 ** This software is a reusable library whose purpose is to provide complete
7 ** I/O support for various CAD file formats (eg. STL)
8 **
9 ** This software is governed by the CeCILL-B license under French law and
10 ** abiding by the rules of distribution of free software. You can use,
11 ** modify and/ or redistribute the software under the terms of the CeCILL-B
12 ** license as circulated by CEA, CNRS and INRIA at the following URL
13 ** "http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html".
14 ****************************************************************************/
15 
23 #ifndef GMIO_STREAM_H
24 #define GMIO_STREAM_H
25 
26 #include "global.h"
27 #include "memblock.h"
28 #include "streampos.h"
29 #include <stdio.h>
30 
31 #ifndef DOXYGEN
32 # ifdef GMIO_HAVE_INT64_TYPE
33 typedef int64_t gmio_streamsize_t;
34 typedef int64_t gmio_streamoffset_t;
35 # else
36 typedef long gmio_streamsize_t;
37 typedef long gmio_streamoffset_t;
38 # endif
39 #else
40 
44 typedef int64_or_long gmio_streamsize_t;
49 typedef int64_or_long gmio_streamoffset_t;
50 #endif
51 
66 {
69  void* cookie;
70 
79  bool (*func_at_end)(void* cookie);
80 
89  int (*func_error)(void* cookie);
90 
102  size_t (*func_read)(void* cookie, void* ptr, size_t size, size_t count);
103 
115  size_t (*func_write)(void* cookie, const void* ptr, size_t size, size_t count);
116 
119 
125  int (*func_get_pos)(void* cookie, struct gmio_streampos* pos);
126 
133  int (*func_set_pos)(void* cookie, const struct gmio_streampos* pos);
134 };
135 
136 
138 
139 /* Initialization */
140 
143 
145 GMIO_API struct gmio_stream gmio_stream_stdio(FILE* file);
146 
148 
149 #endif /* GMIO_STREAM_H */
150 
#define GMIO_API
Expands either to GMIO_DECL_EXPORT or GMIO_DECL_IMPORT when respectively compiling/using the DLL...
Definition: global.h:76
int(* func_get_pos)(void *cookie, struct gmio_streampos *pos)
Pointer on a function that retrieves the current position in the stream.
Definition: stream.h:125
bool(* func_at_end)(void *cookie)
Pointer on a function that checks end-of-stream indicator.
Definition: stream.h:79
size_t(* func_write)(void *cookie, const void *ptr, size_t size, size_t count)
Pointer on a function that writes block of data to stream.
Definition: stream.h:115
Fundamental global declarations, included by almost all other header/source files.
Declaration of gmio_memblock and utility functions.
int(* func_set_pos)(void *cookie, const struct gmio_streampos *pos)
Pointer on a function that restores the current position in the stream to pos.
Definition: stream.h:133
struct gmio_stream gmio_stream_stdio(FILE *file)
Returns a stream for standard FILE* (cookie will hold file)
#define GMIO_C_LINKAGE_BEGIN
Expands to extern "C" { when building with a C++ compiler.
Definition: global.h:181
size_t(* func_read)(void *cookie, void *ptr, size_t size, size_t count)
Pointer on a function that reads block of data from stream.
Definition: stream.h:102
Declaration of gmio_streampos and utility functions.
#define GMIO_C_LINKAGE_END
Expands to } when building with a C++ compiler.
Definition: global.h:183
Specifies a position within a stream.
Definition: streampos.h:41
int64_or_long gmio_streamsize_t
Type able to represent the size(in bytes) of a stream.
Definition: stream.h:44
Stream that can get input from an arbitrary data source or can write output to an arbitrary data sink...
Definition: stream.h:65
int64_or_long gmio_streamoffset_t
Type able to represent the offset position within a stream.
Definition: stream.h:49
void * cookie
Opaque pointer on the user stream, passed as first argument to hook functions.
Definition: stream.h:69
int(* func_error)(void *cookie)
Pointer on a function that checks error indicator.
Definition: stream.h:89
gmio_streamsize_t(* func_size)(void *cookie)
Pointer on a function that returns the size(in bytes) of the stream.
Definition: stream.h:118
struct gmio_stream gmio_stream_null()
Returns a null stream.
Fougue © 2016