]> git.mxchange.org Git - simgear.git/blob - simgear/io/lowlevel.hxx
Lots of (mostly) doxygen fixes/cleanup.
[simgear.git] / simgear / io / lowlevel.hxx
1 // lowlevel.hxx -- routines to handle lowlevel compressed binary IO of
2 //                 various datatypes
3 //
4 // Shamelessly adapted from plib  January 2001
5 //
6 // Original version Copyright (C) 2000  the plib team
7 // Local changes Copyright (C) 2000  Curtis L. Olson  - http://www.flightgear.org/~curt
8 //
9 // This program is free software; you can redistribute it and/or modify
10 // it under the terms of the GNU General Public License as published by
11 // the Free Software Foundation; either version 2 of the License, or
12 // (at your option) any later version.
13 //
14 // This program is distributed in the hope that it will be useful,
15 // but WITHOUT ANY WARRANTY; without even the implied warranty of
16 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17 // GNU General Public License for more details.
18 //
19 // You should have received a copy of the GNU General Public License
20 // along with this program; if not, write to the Free Software
21 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
22 //
23 // $Id$
24 //
25
26
27 #ifndef _SG_LOWLEVEL_HXX
28 #define _SG_LOWLEVEL_HXX
29
30 #include <stdio.h>
31 #include <zlib.h>
32
33 #include <simgear/compiler.h>
34 #include <simgear/misc/stdint.hxx>
35
36 #include <simgear/math/SGMath.hxx>
37
38 // Note that output is written in little endian form (and converted as
39 // necessary for big endian machines)
40
41 void sgReadChar ( gzFile fd, char *var ) ;
42 void sgWriteChar ( gzFile fd, const char var ) ;
43 void sgReadFloat ( gzFile fd, float *var ) ;
44 void sgWriteFloat ( gzFile fd, const float var ) ;
45 void sgReadDouble ( gzFile fd, double *var ) ;
46 void sgWriteDouble ( gzFile fd, const double var ) ;
47 void sgReadUInt ( gzFile fd, unsigned int *var ) ;
48 void sgWriteUInt ( gzFile fd, const unsigned int var ) ;
49 void sgReadInt ( gzFile fd, int *var ) ;
50 void sgWriteInt ( gzFile fd, const int var ) ;
51 void sgReadLong ( gzFile fd, int32_t *var ) ;
52 void sgWriteLong ( gzFile fd, const int32_t var ) ;
53 void sgReadLongLong ( gzFile fd, int64_t *var ) ;
54 void sgWriteLongLong ( gzFile fd, const int64_t var ) ;
55 void sgReadUShort ( gzFile fd, unsigned short *var ) ;
56 void sgWriteUShort ( gzFile fd, const unsigned short var ) ;
57 void sgReadShort ( gzFile fd, short *var ) ;
58 void sgWriteShort ( gzFile fd, const short var ) ;
59
60 void sgReadFloat ( gzFile fd, const unsigned int n, float *var ) ;
61 void sgWriteFloat ( gzFile fd, const unsigned int n, const float *var ) ;
62 void sgReadDouble ( gzFile fd, const unsigned int n, double *var ) ;
63 void sgWriteDouble ( gzFile fd, const unsigned int n, const double *var ) ;
64 void sgReadUInt ( gzFile fd, const unsigned int n, unsigned int *var ) ;
65 void sgWriteUInt ( gzFile fd, const unsigned int n, const unsigned int *var ) ;
66 void sgReadInt ( gzFile fd, const unsigned int n, int *var ) ;
67 void sgWriteInt ( gzFile fd, const unsigned int n, const int *var ) ;
68 void sgReadUShort ( gzFile fd, const unsigned int n, unsigned short *var ) ;
69 void sgWriteUShort ( gzFile fd, const unsigned int n, const unsigned short *var ) ;
70 void sgReadShort ( gzFile fd, const unsigned int n, short *var ) ;
71 void sgWriteShort ( gzFile fd, const unsigned int n, const short *var ) ;
72 void sgReadBytes ( gzFile fd, const unsigned int n, void *var ) ;
73 void sgWriteBytes ( gzFile fd, const unsigned int n, const void *var ) ;
74
75 void sgReadString ( gzFile fd, char **var ) ;
76 void sgWriteString ( gzFile fd, const char *var ) ;
77
78 inline void sgReadVec2  ( gzFile fd, SGVec2f& var ) {
79     sgReadFloat  ( fd, 2, var.data() ) ;
80 }
81 inline void sgWriteVec2 ( gzFile fd, const SGVec2f& var ) {
82     sgWriteFloat ( fd, 2, var.data() ) ;
83 }
84
85 inline void sgReadVec3  ( gzFile fd, SGVec3f& var ) {
86     sgReadFloat  ( fd, 3, var.data() ) ;
87 }
88 inline void sgWriteVec3 ( gzFile fd, const SGVec3f& var ) {
89     sgWriteFloat ( fd, 3, var.data() ) ;
90 }
91
92 inline void sgReaddVec3  ( gzFile fd, SGVec3d& var ) {
93     sgReadDouble  ( fd, 3, var.data() ) ;
94 }
95 inline void sgWritedVec3 ( gzFile fd, const SGVec3d& var ) {
96     sgWriteDouble ( fd, 3, var.data() ) ;
97 }
98
99 inline void sgReadVec4  ( gzFile fd, SGVec4f& var ) {
100     sgReadFloat  ( fd, 4, var.data() ) ;
101 }
102 inline void sgWriteVec4 ( gzFile fd, const SGVec4f& var ) {
103     sgWriteFloat ( fd, 4, var.data() ) ;
104 }
105
106 inline void sgReadMat4  ( gzFile fd, SGMatrixf& var ) {
107     sgReadFloat  ( fd, 16, (float *)var.data() ) ;
108 }
109 inline void sgWriteMat4 ( gzFile fd, const SGMatrixf& var ) {
110     sgWriteFloat ( fd, 16, (float *)var.data() ) ;
111 }
112
113 inline void sgReadGeod  ( gzFile fd, SGGeod& var ) {
114     double data[3];
115     sgReadDouble ( fd, 3, data );
116     var = SGGeod::fromDegM( data[0], data[1], data[2] );
117 }
118 inline void sgWriteGeod ( gzFile fd, const SGGeod& var ) {
119     sgWriteDouble( fd, var.getLongitudeDeg() );
120     sgWriteDouble( fd, var.getLatitudeDeg() );
121     sgWriteDouble( fd, var.getElevationM() );
122 }
123
124 void sgClearReadError();
125 void sgClearWriteError();
126 int sgReadError();
127 int sgWriteError();
128
129 #endif // _SG_LOWLEVEL_HXX