Go to the documentation of this file.00001
00002
00003
00004
00005
00008
00009 #ifndef leTypes_H_
00010 #define leTypes_H_
00011
00012 #include <vlutil/vlNetTypes.h>
00013
00015 class DtLeU16
00016 {
00017 public:
00018 DtNetU8 msbyte;
00019 DtNetU8 lsbyte;
00020
00021 DtLeU16(): msbyte(), lsbyte() { }
00022
00023 DtLeU16(DtU16 u)
00024 {
00025 #if DT_LITTLE_ENDIAN
00026 *((DtU16 *) this) = u;
00027 #else
00028 lsbyte = ((u & 0xff00) >> 8); msbyte = (u & 0xff);
00029 #endif
00030 }
00031
00032 DtLeU16(const DtLeU16& u) : msbyte(u.msbyte), lsbyte(u.lsbyte) { }
00033
00034 DtLeU16& operator=(const DtLeU16& u) {
00035 if (this != &u)
00036 { msbyte = u.msbyte; lsbyte = u.lsbyte;}
00037 return *this; }
00038
00039 DtLeU16& operator=(const DtU16& u) { return (*this= DtLeU16(u));}
00040
00041 operator DtU16 () const
00042 {
00043 #if DT_LITTLE_ENDIAN
00044 return *((DtU16 *) this);
00045 #else
00046 return (msbyte & 0xff) | ((lsbyte & 0xff) << 8);
00047 #endif
00048 }
00049 };
00050
00052 class DtLeU32
00053 {
00054 public:
00055
00056 DtLeU16 msword;
00057 DtLeU16 lsword;
00058
00059 DtLeU32() { }
00060
00061 DtLeU32(const DtU32 &u)
00062 {
00063 #if DT_LITTLE_ENDIAN
00064 *((DtU32 *) this) = u;
00065 #else
00066 msword = (DtU16)(u & 0xffff); lsword = (DtU16)((u & 0xffff0000) >> 16);
00067 #endif
00068 }
00069
00070 DtLeU32(const DtLeU32& u) : msword(u.msword),lsword(u.lsword) { }
00071
00072 DtLeU32& operator=(const DtLeU32 &u) {
00073 if (this != &u)
00074 { msword = u.msword; lsword = u.lsword; }
00075 return *this; }
00076
00077 DtLeU32& operator=(const DtU32 &u) { return (*this = DtLeU32(u)); }
00078
00079 operator DtU32 () const
00080 {
00081 #if DT_LITTLE_ENDIAN
00082 return *((DtU32 *) this);
00083 #else
00084 return ((lsword & 0xffff) << 16) | (msword & 0xffff);
00085 #endif
00086 }
00087 };
00088
00089
00090
00092 class DtLeInt16
00093 {
00094 public:
00095
00096 DtNetInt8 msbyte;
00097 DtNetInt8 lsbyte;
00098
00099 DtLeInt16() { }
00100
00101 DtLeInt16(const DtInt16& i)
00102 {
00103 #if DT_LITTLE_ENDIAN
00104 *((DtInt16 *) this) = i;
00105 #else
00106 lsbyte = ((i & 0xff00) >> 8); msbyte = (i & 0xff);
00107 #endif
00108 }
00109
00110 DtLeInt16(const DtLeInt16& i) : msbyte(i.msbyte), lsbyte(i.lsbyte) { }
00111
00112 DtLeInt16& operator=(const DtLeInt16& other) {
00113 if (&other != this)
00114 { lsbyte = other.lsbyte; msbyte = other.msbyte; }
00115 return *this; }
00116
00117 DtLeInt16& operator=(const DtInt16& other) {return (*this = DtLeInt16(other)); }
00118
00119 operator DtInt16 () const
00120 {
00121 #if DT_LITTLE_ENDIAN
00122 return *((DtInt16 *) this);
00123 #else
00124 return (msbyte & 0xff) | ((lsbyte & 0xff) << 8);
00125 #endif
00126 }
00127 };
00128
00130 class DtLeInt32
00131 {
00132 public:
00133
00134 DtLeInt16 msword;
00135 DtLeInt16 lsword;
00136
00137 DtLeInt32() { }
00138
00139 DtLeInt32(const DtInt32& i)
00140 {
00141 #if DT_LITTLE_ENDIAN
00142 *((DtInt32 *) this) = i;
00143 #else
00144 msword = (DtU16)(i & 0xffff); lsword = (DtU16)((i & 0xffff0000) >> 16);
00145 #endif
00146 }
00147
00148 DtLeInt32(const DtLeInt32& i) : msword(i.msword),lsword(i.lsword) { }
00149
00150 DtLeInt32& operator=(const DtLeInt32 &other) {
00151 if (this != &other)
00152 { msword = other.msword; lsword = other.lsword; }
00153 return(*this);
00154 }
00155
00156 DtLeInt32& operator=(const DtInt32 &other){ return *this = DtLeInt32(other); }
00157
00158 operator DtInt32 () const
00159 {
00160 #if DT_LITTLE_ENDIAN
00161 return *((DtInt32 *) this);
00162 #else
00163 return ((lsword & 0xffff) << 16) | (msword & 0xffff);
00164 #endif
00165 }
00166 };
00167
00168 #endif