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 (void)
77 virtual fnetorderstream& writeInt16 (kuint16 n);
78 virtual fnetorderstream& writeInt32 (kuint32 n);
79 virtual fnetorderstream& writeFloat32 (kfloat32 n);
80 virtual fnetorderstream& writeFloat64 (kfloat64 n);
82 virtual fnetorderstream& readInt16 (kuint16& n);
83 virtual fnetorderstream& readInt32 (kuint32& n);
84 virtual fnetorderstream& readFloat32 (kfloat32& n);
85 virtual fnetorderstream& readFloat64 (kfloat64& n);
89 class frnetorderstream : public fnetorderstream {
91 frnetorderstream (const char* filename, int mode)
92 : fnetorderstream (filename, mode) {}
94 virtual frnetorderstream& writeInt16 (kuint16 n);
95 virtual frnetorderstream& writeInt32 (kuint32 n);
96 virtual frnetorderstream& writeFloat32 (kfloat32 n);
97 virtual frnetorderstream& writeFloat64 (kfloat64 n);
99 virtual frnetorderstream& readInt16 (kuint16& n);
100 virtual frnetorderstream& readInt32 (kuint32& n);
101 virtual frnetorderstream& readFloat32 (kfloat32& n);
102 virtual frnetorderstream& readFloat64 (kfloat64& n);