template <class T>
inline BinaryFileReader & operator>>( T & value )
{
readIn( &value, sizeof( value ) );
if ( mFlipBytes )
{
if ( sizeof( value ) == 4 )
{
value = ( ( value >> 24 ) & 0x000000FF ) |
( ( value >> 8 ) & 0x0000FF00 ) |
( ( value << 8 ) & 0x00FF0000 ) |
( ( value << 24 ) & 0xFF000000 );
}
else if ( sizeof( value ) == 2 )
{
value = ( ( value >> 8 ) ) |
( ( value << 8 ) );
}
else if ( sizeof( value ) == 1 )
{
// (empty purposely) do not need to reverse
}
else
{
Debug( "Undefined!" );
}
}
return *this;
}
inline BinaryFileReader & operator>>( uint64 & value )
{
readIn( &value, sizeof( value ) );
if ( mFlipBytes )
{
value = ((value >> 56) & 0x00000000000000FFLL) |
((value >> 40) & 0x000000000000FF00LL) |
((value >> 24) & 0x0000000000FF0000LL) |
((value >> 8) & 0x00000000FF000000LL) |
((value << 8) & 0x000000FF00000000LL) |
((value << 24) & 0x0000FF0000000000LL) |
((value << 40) & 0x00FF000000000000LL) |
((value << 56) & 0xFF00000000000000LL);
}
return *this;
}
inline BinaryFileReader & operator>>( int64 & value )
{
readIn( &value, sizeof( value ) );
if ( mFlipBytes )
{
value = ((value >> 56) & 0x00000000000000FFLL) |
((value >> 40) & 0x000000000000FF00LL) |
((value >> 24) & 0x0000000000FF0000LL) |
((value >> 8) & 0x00000000FF000000LL) |
((value << 8) & 0x000000FF00000000LL) |
((value << 24) & 0x0000FF0000000000LL) |
((value << 40) & 0x00FF000000000000LL) |
((value << 56) & 0xFF00000000000000LL);
}
return *this;
}