added override specifiers, some doc fixes
This commit is contained in:
@ -13,6 +13,12 @@ class EndianSwapper {
|
||||
private:
|
||||
EndianSwapper() {};
|
||||
public:
|
||||
/**
|
||||
* Swap the endianness of a variable with arbitrary type
|
||||
* @tparam T Type of variable
|
||||
* @param in variable
|
||||
* @return Variable with swapped endianness
|
||||
*/
|
||||
template<typename T>
|
||||
static T swap(T in) {
|
||||
#ifndef BYTE_ORDER_SYSTEM
|
||||
@ -31,7 +37,14 @@ public:
|
||||
#error Unknown Byte Order
|
||||
#endif
|
||||
}
|
||||
static void swap(uint8_t* out, const uint8_t* in, uint32_t size) {
|
||||
|
||||
/**
|
||||
* Swap the endianness of a buffer.
|
||||
* @param out
|
||||
* @param in
|
||||
* @param size
|
||||
*/
|
||||
static void swap(uint8_t* out, const uint8_t* in, size_t size) {
|
||||
#ifndef BYTE_ORDER_SYSTEM
|
||||
#error BYTE_ORDER_SYSTEM not defined
|
||||
#elif BYTE_ORDER_SYSTEM == LITTLE_ENDIAN
|
||||
@ -47,21 +60,23 @@ public:
|
||||
|
||||
/**
|
||||
* Swap endianness of buffer entries
|
||||
* Template argument specifies buffer type
|
||||
* Template argument specifies buffer type. The number of entries
|
||||
* (not the buffer size!) must be supplied
|
||||
* @param out
|
||||
* @param in
|
||||
* @param size
|
||||
* @param size Number of buffer entries (not size of buffer in bytes!)
|
||||
*/
|
||||
template<typename T>
|
||||
static void swap(T * out, const T * in, uint32_t size) {
|
||||
static void swap(T * out, const T * in, uint32_t entries) {
|
||||
#ifndef BYTE_ORDER_SYSTEM
|
||||
#error BYTE_ORDER_SYSTEM not defined
|
||||
#elif BYTE_ORDER_SYSTEM == LITTLE_ENDIAN
|
||||
const uint8_t * in_buffer = reinterpret_cast<const uint8_t *>(in);
|
||||
uint8_t * out_buffer = reinterpret_cast<uint8_t *>(out);
|
||||
for (uint8_t count = 0; count < size; count++) {
|
||||
for (uint8_t count = 0; count < entries; count++) {
|
||||
for(uint8_t i = 0; i < sizeof(T);i++) {
|
||||
out_buffer[sizeof(T)* (count + 1) - i - 1] = in_buffer[count * sizeof(T) + i];
|
||||
out_buffer[sizeof(T)* (count + 1) - i - 1] =
|
||||
in_buffer[count * sizeof(T) + i];
|
||||
}
|
||||
}
|
||||
return;
|
||||
|
Reference in New Issue
Block a user