r2088: *** empty log message ***
[ctsim.git] / include / fnetorderstream.h
index b682105b9dfecb322a6f06163148193e5b67a7db..5e1336a21accf2d29ff4f80431543919c9f6ce64 100644 (file)
@@ -1,3 +1,31 @@
+/*****************************************************************************
+** FILE IDENTIFICATION
+**
+**   Name:          fnetorderstream.h
+**   Purpose:       Network-order file stream header
+**   Programmer:    Kevin Rosenberg
+**   Date Started:  Sep 2000
+**
+**  This is part of the CTSim program
+**  Copyright (c) 1983-2001 Kevin Rosenberg
+**
+**  $Id: fnetorderstream.h,v 1.10 2002/05/28 18:43:16 kevin Exp $
+**
+**  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
+**  published by the Free Software Foundation.
+**
+**  This program is distributed in the hope that it will be useful,
+**  but WITHOUT ANY WARRANTY; without even the implied warranty of
+**  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+**  GNU General Public License for more details.
+**
+**  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., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+******************************************************************************/
+
+
 #ifndef NETORDER_H
 #define NETORDER_H
 
@@ -8,7 +36,6 @@
 #include <fstream>
 #include <iostream>
 #include <string>
-using namespace std;
 
 
 inline bool NativeBigEndian (void)
@@ -61,15 +88,44 @@ 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);
 
-
+#define GPP3 1
+using std::fstream;
 class fnetorderstream : public fstream {
  public:
+#if GPP3
+  fnetorderstream (const char* filename, std::ios::openmode mode)
+         : fstream (filename, mode) {}
+#else
   fnetorderstream (const char* filename, int mode)
-    : fstream (filename, mode) {}
+         : fstream (filename, mode) {}
+#endif
 
   ~fnetorderstream (void)
       {}
@@ -88,9 +144,13 @@ class fnetorderstream : public fstream {
 
 class frnetorderstream : public fnetorderstream {
  public:
+#if GPP3
+  frnetorderstream (const char* filename, std::ios::openmode mode)
+    : fnetorderstream (filename, mode) {}
+#else
   frnetorderstream (const char* filename, int mode)
     : fnetorderstream (filename, mode) {}
-
+#endif
   virtual void writeInt16 (kuint16 n);
   virtual void writeInt32 (kuint32 n);
   virtual void writeFloat32 (kfloat32 n);