X-Git-Url: http://git.kpe.io/?a=blobdiff_plain;f=include%2Ffnetorderstream.h;h=876c6a350bb98253cb9b8a4807b93d612b5eacd7;hb=bb09705ec0a20bf5b41b4248cf7800b000bc3fcb;hp=70b857e1d4748a5958659c7a799d8dd33b4193d2;hpb=9f29c8b32c972db1178d6f8551d5cd57ceb67083;p=ctsim.git diff --git a/include/fnetorderstream.h b/include/fnetorderstream.h index 70b857e..876c6a3 100644 --- a/include/fnetorderstream.h +++ b/include/fnetorderstream.h @@ -9,7 +9,7 @@ ** This is part of the CTSim program ** Copyright (c) 1983-2001 Kevin Rosenberg ** -** $Id: fnetorderstream.h,v 1.8 2001/01/28 19:10:18 kevin Exp $ +** $Id$ ** ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License (version 2) as @@ -88,6 +88,29 @@ SwapBytes8 (void* buffer) p[4] = temp; } +inline void +SwapBytes2IfLittleEndian (void* buffer) +{ +#ifndef WORDS_BIGENDIAN + SwapBytes2 (buffer); +#endif +} + +inline void +SwapBytes4IfLittleEndian (void* buffer) +{ +#ifndef WORDS_BIGENDIAN + SwapBytes4 (buffer); +#endif +} + +inline void +SwapBytes8IfLittleEndian (void* buffer) +{ +#ifndef WORDS_BIGENDIAN + SwapBytes8 (buffer); +#endif +} void ConvertNetworkOrder (void* buffer, size_t bytes); void ConvertReverseNetworkOrder (void* buffer, size_t bytes); @@ -95,8 +118,8 @@ void ConvertReverseNetworkOrder (void* buffer, size_t bytes); using std::fstream; class fnetorderstream : public fstream { public: - fnetorderstream (const char* filename, int mode) - : fstream (filename, mode) {} + fnetorderstream (const char* filename, std::ios::openmode mode) + : fstream (filename, mode) {} ~fnetorderstream (void) {} @@ -105,7 +128,7 @@ class fnetorderstream : public fstream { virtual void writeInt32 (kuint32 n); virtual void writeFloat32 (kfloat32 n); virtual void writeFloat64 (kfloat64 n); - + virtual void readInt16 (kuint16& n); virtual void readInt32 (kuint32& n); virtual void readFloat32 (kfloat32& n); @@ -115,14 +138,14 @@ class fnetorderstream : public fstream { class frnetorderstream : public fnetorderstream { public: - frnetorderstream (const char* filename, int mode) + frnetorderstream (const char* filename, std::ios::openmode mode) : fnetorderstream (filename, mode) {} virtual void writeInt16 (kuint16 n); virtual void writeInt32 (kuint32 n); virtual void writeFloat32 (kfloat32 n); virtual void writeFloat64 (kfloat64 n); - + virtual void readInt16 (kuint16& n); virtual void readInt32 (kuint32& n); virtual void readFloat32 (kfloat32& n);