#include <Endian.h>
Public Member Functions | |
| Endian (EndianType endian) | |
| Endian () | |
| ~Endian () | |
| EndianType | getEndian () const |
| bool | isBigEndian () const |
| bool | isLittleEndian () const |
| template<class T> | |
| bool | swapValue (T &value) const |
| template<class T> | |
| T | swapValue (const T &value) const |
| template<class T> | |
| bool | swapBuffer (T *pBuffer, size_t count) const |
| bool | swapBuffer (FloatComplex *pBuffer, size_t count) const |
| bool | swapBuffer (IntegerComplex *pBuffer, size_t count) const |
| bool | swapBuffer (void *pBuffer, size_t dataSize, size_t count) const |
Static Public Member Functions | |
| static EndianType | getSystemEndian () |
The Endian class provides a capability to perform byte-swapping of data values based on the endian type of the system. An Endian object should be created with the target endian type. The swapping methods can then be called to swap data values to the target type. If the target type is the same as the system, no swapping is performed.
Definition at line 27 of file Endian.h.
| Endian::Endian | ( | EndianType | endian | ) |
Creates an Endian object of a given endian type.
| endian | The endian type for the object. This type is used as the target endian type for the byte-swapping methods. If the given type is the same as the system type the byte-swapping methods can still be called, but no swapping is performed. |
| Endian::Endian | ( | ) |
| Endian::~Endian | ( | ) |
Destroys the Endian object.
| EndianType Endian::getEndian | ( | ) | const |
| bool Endian::isBigEndian | ( | ) | const |
Queries the endian type of this for EndianType::BIG_ENDIAN_ORDER.
| bool Endian::isLittleEndian | ( | ) | const |
Queries the endian type of this for EndianType::LITTLE_ENDIAN_ORDER.
| bool Endian::swapValue | ( | T & | value | ) | const |
Swaps the bytes of a single data value.
This method performs in-place byte swapping of a single data value by modifying the given element. If the original value should not be overwritten, use the swapValue() method instead.
| value | A reference to the data value to swap. |
| T Endian::swapValue | ( | const T & | value | ) | const |
Swaps the bytes of a single data value.
This method performs byte swapping of a single data value and returns the swapped value. The original data element is not modified. For performance reasons, if the original data element can be overwritten, use the swapValue() method instead.
| value | A data value to swap. The value is not modified. |
| bool Endian::swapBuffer | ( | T * | pBuffer, | |
| size_t | count | |||
| ) | const |
Swaps the bytes of data elements in an array.
This method swaps the bytes of data elements in an array if the endian type of the system is different than the endian type of this.
This method is provided as a convenience if the data type is known.
| pBuffer | A pointer to the data to be byte swapped. | |
| count | The number of items in the array to byte swap. |
| bool Endian::swapBuffer | ( | FloatComplex * | pBuffer, | |
| size_t | count | |||
| ) | const |
This override has the same behavior as the templated function of the same name.
It is needed because the template definition is incorrect for complex data.
| pBuffer | The FloatComplex buffer to swap | |
| count | The number of elements in pBuffer to swap |
| bool Endian::swapBuffer | ( | IntegerComplex * | pBuffer, | |
| size_t | count | |||
| ) | const |
This override has the same behavior as the templated function of the same name.
It is needed because the template definition is incorrect for complex data.
| pBuffer | The IntegerComplex buffer to swap | |
| count | The number of elements in pBuffer to swap |
| bool Endian::swapBuffer | ( | void * | pBuffer, | |
| size_t | dataSize, | |||
| size_t | count | |||
| ) | const |
Swaps the bytes of data elements in an array.
This method swaps the bytes of data elements in an array if the endian type of the system is different than endian type of this.
| pBuffer | A pointer to the data to be byte swapped. | |
| dataSize | The size of each element in the array. | |
| count | The number of items in the array to byte swap. |
| static EndianType Endian::getSystemEndian | ( | ) | [static] |
Returns the endian type of the system.
This value is used in the byte-swapping methods to determine whether the data values should be swapped or not.