CopperSpice API  1.9.1
Endian Functions

Functions to convert between little and big endian representations of numbers.

Functions

template<typename T >
qFromBigEndian (const uchar *source)
 
template<typename T >
qFromBigEndian (T source)
 
template<typename T >
qFromLittleEndian (const uchar *source)
 
template<typename T >
qFromLittleEndian (T source)
 
template<typename T >
qToBigEndian (T source)
 
template<typename T >
void qToBigEndian (T source, uchar *dest)
 
template<typename T >
qToLittleEndian (T source)
 
template<typename T >
void qToLittleEndian (T source, uchar *dest)
 

Function Documentation

template<typename T >
T qFromBigEndian ( const uchar source)
inline

Reads a big-endian number from memory location source and returns the number in the host byte order representation. On CPU architectures where the host byte order is little-endian (such as x86) this will swap the byte order, otherwise it will just read from source.

There are no data alignment constraints for source.

Note
Template type T can either be a qint16, qint32 or qint64. Other types of integers such as qlong are not supported.
See also
qFromLittleEndian(), qToBigEndian(), qToLittleEndian()
template<typename T >
T qFromBigEndian ( source)
inline

Converts source from big-endian byte order and returns the number in host byte order representation of that number. On CPU architectures where the host byte order is little-endian this will return source with the byte order swapped, otherwise it will return source.

template<typename T >
T qFromLittleEndian ( const uchar source)
inline

Reads a little-endian number from memory location source and returns the number in the host byte order representation. On CPU architectures where the host byte order is big-endian this will swap the byte order, otherwise it will just read from source.

There are no data alignment constraints for source.

Note
Template type T can either be a qint16, qint32 or qint64. Other types of integers such as qlong are not supported.
See also
qFromBigEndian(), qToBigEndian(), qToLittleEndian()
template<typename T >
T qFromLittleEndian ( source)
inline

Converts source from little endian byte order and returns the number in host byte order representation of that number. On CPU architectures where the host byte order is big-endian this will return source with the byte order swapped, otherwise it will return source.

template<typename T >
T qToBigEndian ( source)
inline

Converts source from host byte order and returns the number in big-endian byte order representation of that number. On CPU architectures where the host byte order is little-endian this will return source with the byte order swapped, otherwise it will return source.

template<typename T >
void qToBigEndian ( source,
uchar dest 
)
inline

Writes the number source with template type T to the memory location at dest in big-endian byte order. Template type T can only be an integer data type (signed or unsigned). There are no data alignment constraints for dest.

See also
qFromBigEndian(), qFromLittleEndian(), qToLittleEndian()
template<typename T >
T qToLittleEndian ( source)
inline

Converts source from host byte order and returns the number in little-endian byte order representation of that number. On CPU architectures where the host byte order is big-endian this will return source with the byte order swapped, otherwise it will return source.

template<typename T >
void qToLittleEndian ( source,
uchar dest 
)
inline

Writes the number source with template type T to the memory location at dest in little-endian byte order. Note that template type T can only be an integer data type (signed or unsigned). There are no data alignment constraints for dest.

See also
qFromBigEndian(), qFromLittleEndian(), qToBigEndian()