r98: finished object-orient convern of Scanner & Phantom
[ctsim.git] / include / byteorder.h
index 187e4fb571ab292037f19847129a68f7285eecba..94fe9598dd6609de4de8f8279de87ab571d53232 100644 (file)
@@ -1,9 +1,10 @@
 #ifndef NETORDER_H
 #define NETORDER_H
 
+#include <iostream>
+
 /* netorder.cpp */
 
-void *strreverse (void *dest, const void *src, size_t n);
 bool read_nint16 (kuint16 *n, int fd);
 bool write_nint16 (kuint16 const *n, int fd);
 bool read_nint32 (kuint32 *n, int fd);
@@ -12,7 +13,32 @@ bool read_nfloat32 (float *f, int fd);
 bool write_nfloat32 (float const *f, int fd);
 bool read_nfloat64 (double *d, int fd);
 bool write_nfloat64 (double const *d, int fd);
-void ConvertNetworkOrder (void* buffer, size_t bytes);
-void ConvertReverseNetworkOrder (void* buffer, size_t bytes);
+void  ConvertNetworkOrder (void* buffer, size_t bytes);
+void  ConvertReverseNetworkOrder (void* buffer, size_t bytes);
+
+class inetorderstream : public istream {
+ public:
+    inetorderstream& readInt16 (kuint16& n);
+    inetorderstream& readInt32 (kuint32& n);
+    inetorderstream& readFloat32 (kfloat32& n);
+    inetorderstream& readFloat64 (kfloat64& n);
+};
+
+class onetorderstream : public ostream {
+ public:
+    onetorderstream& writeInt16 (kuint16 n);
+    onetorderstream& writeInt32 (kuint32 n);
+    onetorderstream& writeFloat32 (kfloat32 n);
+    onetorderstream& writeFloat64 (kfloat64 n);
+};
+
+void read_rnint16 (kuint16& n, istream istr);
+void write_rnint16 (kuint16 n, ostream ostr);
+void read_rnint32 (kuint32& n, istream istr);
+void write_rnint32 (kuint32 n, ostream ostr);
+void read_rnfloat32 (kfloat32& n, istream istr);
+void write_rnfloat32 (kfloat32 n, ostream ostr);
+void read_rnfloat64 (kfloat64& n, istream istr);
+void write_rnfloat64 (kfloat64 n, ostream ostr);
 
 #endif