Move code around

This commit is contained in:
Behdad Esfahbod 2014-10-14 21:26:13 -07:00
parent 666b42f73b
commit 5a5640d850
1 changed files with 25 additions and 25 deletions

View File

@ -552,6 +552,31 @@ struct BEInt<Type, 2>
private: uint8_t v[2]; private: uint8_t v[2];
}; };
template <typename Type> template <typename Type>
struct BEInt<Type, 3>
{
public:
inline void set (Type V)
{
v[0] = (V >> 16) & 0xFF;
v[1] = (V >> 8) & 0xFF;
v[2] = (V ) & 0xFF;
}
inline operator Type (void) const
{
return (v[0] << 16)
+ (v[1] << 8)
+ (v[2] );
}
inline bool operator == (const BEInt<Type, 3>& o) const
{
return v[0] == o.v[0]
&& v[1] == o.v[1]
&& v[2] == o.v[2];
}
inline bool operator != (const BEInt<Type, 3>& o) const { return !(*this == o); }
private: uint8_t v[3];
};
template <typename Type>
struct BEInt<Type, 4> struct BEInt<Type, 4>
{ {
public: public:
@ -579,31 +604,6 @@ struct BEInt<Type, 4>
inline bool operator != (const BEInt<Type, 4>& o) const { return !(*this == o); } inline bool operator != (const BEInt<Type, 4>& o) const { return !(*this == o); }
private: uint8_t v[4]; private: uint8_t v[4];
}; };
template <typename Type>
struct BEInt<Type, 3>
{
public:
inline void set (Type V)
{
v[0] = (V >> 16) & 0xFF;
v[1] = (V >> 8) & 0xFF;
v[2] = (V ) & 0xFF;
}
inline operator Type (void) const
{
return (v[0] << 16)
+ (v[1] << 8)
+ (v[2] );
}
inline bool operator == (const BEInt<Type, 3>& o) const
{
return v[0] == o.v[0]
&& v[1] == o.v[1]
&& v[2] == o.v[2];
}
inline bool operator != (const BEInt<Type, 3>& o) const { return !(*this == o); }
private: uint8_t v[3];
};
/* Integer types in big-endian order and no alignment requirement */ /* Integer types in big-endian order and no alignment requirement */
template <typename Type, unsigned int Size> template <typename Type, unsigned int Size>