14 inline bool NativeBigEndian (void)
16 #ifdef WORDS_BIGENDIAN
24 SwapBytes2 (void* buffer)
26 unsigned char* p = static_cast<unsigned char*>(buffer);
27 unsigned char temp = p[0];
32 // 0<->3 1<->2 = 0123 -> 3210
34 SwapBytes4 (void* buffer)
36 unsigned char* p = static_cast<unsigned char*>(buffer);
37 unsigned char temp = p[0];
45 // 0<->7 1<->6 2<->5 3<->4 = 01234567 -> 76543210
47 SwapBytes8 (void* buffer)
49 unsigned char* p = static_cast<unsigned char*>(buffer);
50 unsigned char temp = p[0];
65 void ConvertNetworkOrder (void* buffer, size_t bytes);
66 void ConvertReverseNetworkOrder (void* buffer, size_t bytes);
69 class fnetorderstream : public fstream {
71 fnetorderstream (const char* filename, int mode)
72 : fstream (filename, mode) {}
74 fnetorderstream (const int fd)
77 ~fnetorderstream (void)
80 virtual void writeInt16 (kuint16 n);
81 virtual void writeInt32 (kuint32 n);
82 virtual void writeFloat32 (kfloat32 n);
83 virtual void writeFloat64 (kfloat64 n);
85 virtual void readInt16 (kuint16& n);
86 virtual void readInt32 (kuint32& n);
87 virtual void readFloat32 (kfloat32& n);
88 virtual void readFloat64 (kfloat64& n);
92 class frnetorderstream : public fnetorderstream {
94 frnetorderstream (const char* filename, int mode)
95 : fnetorderstream (filename, mode) {}
97 frnetorderstream (const int fd)
98 : fnetorderstream (fd) {}
100 virtual void writeInt16 (kuint16 n);
101 virtual void writeInt32 (kuint32 n);
102 virtual void writeFloat32 (kfloat32 n);
103 virtual void writeFloat64 (kfloat64 n);
105 virtual void readInt16 (kuint16& n);
106 virtual void readInt32 (kuint32& n);
107 virtual void readFloat32 (kfloat32& n);
108 virtual void readFloat64 (kfloat64& n);