|
|
|
@ -23,7 +23,7 @@ template< typename T >
|
|
|
|
|
class EndianTypesBase
|
|
|
|
|
{
|
|
|
|
|
protected:
|
|
|
|
|
#if defined ( _MSC_VER )
|
|
|
|
|
#if defined( _MSC_VER )
|
|
|
|
|
#pragma warning ( push )
|
|
|
|
|
#endif
|
|
|
|
|
static T swapBytes( const T& b )
|
|
|
|
@ -35,7 +35,6 @@ protected:
|
|
|
|
|
return( n );
|
|
|
|
|
} // swapBytes
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#if defined( _MSC_VER )
|
|
|
|
|
#pragma warning ( pop )
|
|
|
|
|
#endif
|
|
|
|
@ -53,7 +52,6 @@ protected:
|
|
|
|
|
return( ( reinterpret_cast< const char& >( k_i ) == 1 ) ? b : EndianTypesBase< T >::swapBytes( b ) ); //NOLINT
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
// Constructors
|
|
|
|
|
LittleEndianType() = default;
|
|
|
|
@ -73,31 +71,31 @@ public:
|
|
|
|
|
template < typename U > explicit operator U() const { return( U( transform( m_data ) ) ); }
|
|
|
|
|
explicit operator T() const { return( transform( m_data ) ); }
|
|
|
|
|
|
|
|
|
|
template < typename U > bool operator ==( U const& o ) { return( U( *this ) == o ); }
|
|
|
|
|
template < typename U > bool operator !=( U const& o ) { return( U( *this ) != o ); }
|
|
|
|
|
template < typename U > bool operator==( U const& o ) { return( U( *this ) == o ); }
|
|
|
|
|
template < typename U > bool operator!=( U const& o ) { return( U( *this ) != o ); }
|
|
|
|
|
|
|
|
|
|
// Arithmetic assignment operators
|
|
|
|
|
LittleEndianType& operator ++() /* prefix */ { *this = T( *this ) + T( 1 ); return( *this ); }
|
|
|
|
|
LittleEndianType operator ++( int ) /* suffix */ { LittleEndianType t( *this ); *this = T( *this ) + T( 1 ); return( t ); }
|
|
|
|
|
LittleEndianType& operator --() /* prefix */ { *this = T( *this ) - T( 1 ); return( *this ); }
|
|
|
|
|
LittleEndianType operator --( int ) /* suffix */ { LittleEndianType t( *this ); *this = T( *this ) - T( 1 ); return( t ); }
|
|
|
|
|
LittleEndianType& operator++() /* prefix */ { *this = T( *this ) + T( 1 ); return( *this ); }
|
|
|
|
|
LittleEndianType operator++( int ) /* suffix */ { LittleEndianType t( *this ); *this = T( *this ) + T( 1 ); return( t ); }
|
|
|
|
|
LittleEndianType& operator--() /* prefix */ { *this = T( *this ) - T( 1 ); return( *this ); }
|
|
|
|
|
LittleEndianType operator--( int ) /* suffix */ { LittleEndianType t( *this ); *this = T( *this ) - T( 1 ); return( t ); }
|
|
|
|
|
|
|
|
|
|
// Compound assignment operators
|
|
|
|
|
LittleEndianType& operator +=( const T& b ) { *this = T( *this ) + b; return( *this ); }
|
|
|
|
|
LittleEndianType& operator -=( const T& b ) { *this = T( *this ) - b; return( *this ); }
|
|
|
|
|
LittleEndianType& operator *=( const T& b ) { *this = T( *this ) * b; return( *this ); }
|
|
|
|
|
LittleEndianType& operator /=( const T& b ) { *this = T( *this ) / b; return( *this ); }
|
|
|
|
|
LittleEndianType& operator %=( const T& b ) { *this = T( *this ) % b; return( *this ); }
|
|
|
|
|
LittleEndianType& operator &=( const T& b ) { *this = T( *this ) & b; return( *this ); }
|
|
|
|
|
LittleEndianType& operator |=( const T& b ) { *this = T( *this ) | b; return( *this ); }
|
|
|
|
|
LittleEndianType& operator ^=( const T& b ) { *this = T( *this ) ^ b; return( *this ); }
|
|
|
|
|
LittleEndianType& operator <<=( const T& b ) { *this = T( T( *this ) << b ); return( *this ); }
|
|
|
|
|
LittleEndianType& operator >>=( const T& b ) { *this = T( T( *this ) >> b ); return( *this ); }
|
|
|
|
|
friend std::ostream& operator <<( std::ostream& out, const LittleEndianType b ) { out << T( b ); return( out ); }
|
|
|
|
|
friend std::istream& operator >>( std::istream& in, LittleEndianType& b ) { T val; in >> val; b = val; return( in ); }
|
|
|
|
|
LittleEndianType& operator+=( const T& b ) { *this = T( *this ) + b; return( *this ); }
|
|
|
|
|
LittleEndianType& operator-=( const T& b ) { *this = T( *this ) - b; return( *this ); }
|
|
|
|
|
LittleEndianType& operator*=( const T& b ) { *this = T( *this ) * b; return( *this ); }
|
|
|
|
|
LittleEndianType& operator/=( const T& b ) { *this = T( *this ) / b; return( *this ); }
|
|
|
|
|
LittleEndianType& operator%=( const T& b ) { *this = T( *this ) % b; return( *this ); }
|
|
|
|
|
LittleEndianType& operator&=( const T& b ) { *this = T( *this ) & b; return( *this ); }
|
|
|
|
|
LittleEndianType& operator|=( const T& b ) { *this = T( *this ) | b; return( *this ); }
|
|
|
|
|
LittleEndianType& operator^=( const T& b ) { *this = T( *this ) ^ b; return( *this ); }
|
|
|
|
|
LittleEndianType& operator<<=( const T& b ) { *this = T( T( *this ) << b ); return( *this ); }
|
|
|
|
|
LittleEndianType& operator>>=( const T& b ) { *this = T( T( *this ) >> b ); return( *this ); }
|
|
|
|
|
friend std::ostream& operator<<( std::ostream& out, const LittleEndianType b ) { out << T( b ); return( out ); }
|
|
|
|
|
friend std::istream& operator>>( std::istream& in, LittleEndianType& b ) { T val; in >> val; b = val; return( in ); }
|
|
|
|
|
std::string toStdString() { return( std::to_string( transform( m_data ) ) ); }
|
|
|
|
|
#ifdef QT_CORE_LIB
|
|
|
|
|
friend QDebug& operator <<( QDebug& out, const LittleEndianType< T > b ) { out << T( b ); return( out ); }
|
|
|
|
|
friend QDebug& operator<<( QDebug& out, const LittleEndianType< T > b ) { out << T( b ); return( out ); }
|
|
|
|
|
QString toQString() { return( QString::number( transform( m_data ) ) ); }
|
|
|
|
|
#endif
|
|
|
|
|
}; // class LittleEndianType
|
|
|
|
@ -114,7 +112,6 @@ protected:
|
|
|
|
|
return( ( reinterpret_cast< const char& >( k_i ) == 1 ) ? EndianTypesBase< T >::swapBytes( b ) : b ); //NOLINT
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
// Constructors
|
|
|
|
|
BigEndianType() = default;
|
|
|
|
@ -134,31 +131,31 @@ public:
|
|
|
|
|
template < typename U > explicit operator U() const { return( U( transform( m_data ) ) ); }
|
|
|
|
|
explicit operator T() const { return( transform( m_data ) ); }
|
|
|
|
|
|
|
|
|
|
template < typename U > bool operator ==( U const& o ) { return( U( *this ) == o ); }
|
|
|
|
|
template < typename U > bool operator !=( U const& o ) { return( U( *this ) != o ); }
|
|
|
|
|
template < typename U > bool operator==( U const& o ) { return( U( *this ) == o ); }
|
|
|
|
|
template < typename U > bool operator!=( U const& o ) { return( U( *this ) != o ); }
|
|
|
|
|
|
|
|
|
|
// Arithmetic assignment operators
|
|
|
|
|
BigEndianType& operator ++() /* prefix */ { *this = T( *this ) + 1; return( *this ); }
|
|
|
|
|
BigEndianType operator ++( int ) /* suffix */ { BigEndianType t( *this ); *this = T( *this ) + 1; return( t ); }
|
|
|
|
|
BigEndianType& operator --() /* prefix */ { *this = T( *this ) - 1; return( *this ); }
|
|
|
|
|
BigEndianType operator --( int ) /* suffix */ { BigEndianType t( *this ); *this = T( *this ) - 1; return( t ); }
|
|
|
|
|
BigEndianType& operator++() /* prefix */ { *this = T( *this ) + 1; return( *this ); }
|
|
|
|
|
BigEndianType operator++( int ) /* suffix */ { BigEndianType t( *this ); *this = T( *this ) + 1; return( t ); }
|
|
|
|
|
BigEndianType& operator--() /* prefix */ { *this = T( *this ) - 1; return( *this ); }
|
|
|
|
|
BigEndianType operator--( int ) /* suffix */ { BigEndianType t( *this ); *this = T( *this ) - 1; return( t ); }
|
|
|
|
|
|
|
|
|
|
// Compound assignment operators
|
|
|
|
|
BigEndianType& operator +=( const T& b ) { *this = T( *this ) + b; return( *this ); }
|
|
|
|
|
BigEndianType& operator -=( const T& b ) { *this = T( *this ) - b; return( *this ); }
|
|
|
|
|
BigEndianType& operator *=( const T& b ) { *this = T( *this ) * b; return( *this ); }
|
|
|
|
|
BigEndianType& operator /=( const T& b ) { *this = T( *this ) / b; return( *this ); }
|
|
|
|
|
BigEndianType& operator %=( const T& b ) { *this = T( *this ) % b; return( *this ); }
|
|
|
|
|
BigEndianType& operator &=( const T& b ) { *this = T( *this ) & b; return( *this ); }
|
|
|
|
|
BigEndianType& operator |=( const T& b ) { *this = T( *this ) | b; return( *this ); }
|
|
|
|
|
BigEndianType& operator ^=( const T& b ) { *this = T( *this ) ^ b; return( *this ); }
|
|
|
|
|
BigEndianType& operator <<=( const T& b ) { *this = T( T( *this ) << b ); return( *this ); }
|
|
|
|
|
BigEndianType& operator >>=( const T& b ) { *this = T( T( *this ) >> b ); return( *this ); }
|
|
|
|
|
friend std::ostream& operator <<( std::ostream& out, const BigEndianType b ) { out << T( b ); return( out ); }
|
|
|
|
|
friend std::istream& operator >>( std::istream& in, BigEndianType& b ) { T val; in >> val; b = val; return( in ); }
|
|
|
|
|
BigEndianType& operator+=( const T& b ) { *this = T( *this ) + b; return( *this ); }
|
|
|
|
|
BigEndianType& operator-=( const T& b ) { *this = T( *this ) - b; return( *this ); }
|
|
|
|
|
BigEndianType& operator*=( const T& b ) { *this = T( *this ) * b; return( *this ); }
|
|
|
|
|
BigEndianType& operator/=( const T& b ) { *this = T( *this ) / b; return( *this ); }
|
|
|
|
|
BigEndianType& operator%=( const T& b ) { *this = T( *this ) % b; return( *this ); }
|
|
|
|
|
BigEndianType& operator&=( const T& b ) { *this = T( *this ) & b; return( *this ); }
|
|
|
|
|
BigEndianType& operator|=( const T& b ) { *this = T( *this ) | b; return( *this ); }
|
|
|
|
|
BigEndianType& operator^=( const T& b ) { *this = T( *this ) ^ b; return( *this ); }
|
|
|
|
|
BigEndianType& operator<<=( const T& b ) { *this = T( T( *this ) << b ); return( *this ); }
|
|
|
|
|
BigEndianType& operator>>=( const T& b ) { *this = T( T( *this ) >> b ); return( *this ); }
|
|
|
|
|
friend std::ostream& operator<<( std::ostream& out, const BigEndianType b ) { out << T( b ); return( out ); }
|
|
|
|
|
friend std::istream& operator>>( std::istream& in, BigEndianType& b ) { T val; in >> val; b = val; return( in ); }
|
|
|
|
|
std::string toStdString() { return( std::to_string( transform( m_data ) ) ); }
|
|
|
|
|
#ifdef QT_CORE_LIB
|
|
|
|
|
friend QDebug& operator <<( QDebug& out, const BigEndianType< T > b ) { out << T( b ); return( out ); }
|
|
|
|
|
friend QDebug& operator<<( QDebug& out, const BigEndianType< T > b ) { out << T( b ); return( out ); }
|
|
|
|
|
QString toQString() { return( QString::number( transform( m_data ) ) ); }
|
|
|
|
|
#endif
|
|
|
|
|
}; // class BigEndianType
|
|
|
|
|