X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=simgear%2Fio%2Flowlevel.hxx;h=2367d0d4a5ad4bcd60885c4720055fd52bc6982e;hb=598b64fa9569c16878c904e344e2e2775e210c42;hp=b01b9f1a87f7b3173e3507fa40d66d2898b96ec3;hpb=260dbeb3d2a8e711ae7b9d386f09e33ccaa992db;p=simgear.git diff --git a/simgear/io/lowlevel.hxx b/simgear/io/lowlevel.hxx index b01b9f1a..2367d0d4 100644 --- a/simgear/io/lowlevel.hxx +++ b/simgear/io/lowlevel.hxx @@ -4,7 +4,7 @@ // Shamelessly adapted from plib January 2001 // // Original version Copyright (C) 2000 the plib team -// Local changes Copyright (C) 2000 Curtis L. Olson - curt@flightgear.org +// Local changes Copyright (C) 2000 Curtis L. Olson - http://www.flightgear.org/~curt // // This program is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by @@ -18,7 +18,7 @@ // // You should have received a copy of the GNU General Public License // along with this program; if not, write to the Free Software -// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. // // $Id$ // @@ -27,12 +27,16 @@ #ifndef _SG_LOWLEVEL_HXX #define _SG_LOWLEVEL_HXX - #include #include -#include +#include +#include + +#include +// Note that output is written in little endian form (and converted as +// necessary for big endian machines) void sgReadChar ( gzFile fd, char *var ) ; void sgWriteChar ( gzFile fd, const char var ) ; @@ -44,8 +48,10 @@ void sgReadUInt ( gzFile fd, unsigned int *var ) ; void sgWriteUInt ( gzFile fd, const unsigned int var ) ; void sgReadInt ( gzFile fd, int *var ) ; void sgWriteInt ( gzFile fd, const int var ) ; -void sgReadLong ( gzFile fd, long int *var ) ; -void sgWriteLong ( gzFile fd, const long int var ) ; +void sgReadLong ( gzFile fd, int32_t *var ) ; +void sgWriteLong ( gzFile fd, const int32_t var ) ; +void sgReadLongLong ( gzFile fd, int64_t *var ) ; +void sgWriteLongLong ( gzFile fd, const int64_t var ) ; void sgReadUShort ( gzFile fd, unsigned short *var ) ; void sgWriteUShort ( gzFile fd, const unsigned short var ) ; void sgReadShort ( gzFile fd, short *var ) ; @@ -69,22 +75,55 @@ void sgWriteBytes ( gzFile fd, const unsigned int n, const void *var ) ; void sgReadString ( gzFile fd, char **var ) ; void sgWriteString ( gzFile fd, const char *var ) ; -void sgReadVec2 ( gzFile fd, sgVec2 var ) ; -void sgWriteVec2 ( gzFile fd, const sgVec2 var ) ; -void sgReadVec3 ( gzFile fd, sgVec3 var ) ; -void sgWriteVec3 ( gzFile fd, const sgVec3 var ) ; -void sgReaddVec3 ( gzFile fd, sgdVec3 var ) ; -void sgWritedVec3 ( gzFile fd, const sgdVec3 var ) ; -void sgReadVec4 ( gzFile fd, sgVec4 var ) ; -void sgWriteVec4 ( gzFile fd, const sgVec4 var ) ; +inline void sgReadVec2 ( gzFile fd, SGVec2f& var ) { + sgReadFloat ( fd, 2, var.data() ) ; +} +inline void sgWriteVec2 ( gzFile fd, const SGVec2f& var ) { + sgWriteFloat ( fd, 2, var.data() ) ; +} + +inline void sgReadVec3 ( gzFile fd, SGVec3f& var ) { + sgReadFloat ( fd, 3, var.data() ) ; +} +inline void sgWriteVec3 ( gzFile fd, const SGVec3f& var ) { + sgWriteFloat ( fd, 3, var.data() ) ; +} + +inline void sgReaddVec3 ( gzFile fd, SGVec3d& var ) { + sgReadDouble ( fd, 3, var.data() ) ; +} +inline void sgWritedVec3 ( gzFile fd, const SGVec3d& var ) { + sgWriteDouble ( fd, 3, var.data() ) ; +} -void sgReadMat4 ( gzFile fd, sgMat4 var ) ; -void sgWriteMat4 ( gzFile fd, const sgMat4 var ) ; +inline void sgReadVec4 ( gzFile fd, SGVec4f& var ) { + sgReadFloat ( fd, 4, var.data() ) ; +} +inline void sgWriteVec4 ( gzFile fd, const SGVec4f& var ) { + sgWriteFloat ( fd, 4, var.data() ) ; +} + +inline void sgReadMat4 ( gzFile fd, SGMatrixf& var ) { + sgReadFloat ( fd, 16, (float *)var.data() ) ; +} +inline void sgWriteMat4 ( gzFile fd, const SGMatrixf& var ) { + sgWriteFloat ( fd, 16, (float *)var.data() ) ; +} + +inline void sgReadGeod ( gzFile fd, SGGeod& var ) { + double data[3]; + sgReadDouble ( fd, 3, data ); + var = SGGeod::fromDegM( data[0], data[1], data[2] ); +} +inline void sgWriteGeod ( gzFile fd, const SGGeod& var ) { + sgWriteDouble( fd, var.getLongitudeDeg() ); + sgWriteDouble( fd, var.getLatitudeDeg() ); + sgWriteDouble( fd, var.getElevationM() ); +} void sgClearReadError(); void sgClearWriteError(); int sgReadError(); int sgWriteError(); - #endif // _SG_LOWLEVEL_HXX