1#ifndef __stir_ByteOrder_H__
2#define __stir_ByteOrder_H__
78 inline static void revert(
unsigned char* ptr)
80 std::swap(ptr[0], ptr[size - 1]);
81 revert_region<size - 2>::revert(ptr + 1);
89 inline static void revert(
unsigned char* ptr) {}
96 inline static void revert(
unsigned char* ptr) {}
114 inline static Order get_native_order();
121 template <
class NUMBER>
124 revert_region<
sizeof(NUMBER)>::revert(
reinterpret_cast<unsigned char*
>(&value));
130 inline ByteOrder(Order byte_order = native);
133 inline bool operator==(
const ByteOrder order2)
const;
134 inline bool operator!=(
const ByteOrder order2)
const;
137 inline bool is_native_order()
const;
144 template <
class NUMBER>
153 static const Order native_order;
This file declares the stir::ByteOrder class.
This class provides member functions to find out what byte-order your machine is and to swap numbers.
Definition ByteOrder.h:100
bool is_native_order() const
check if the object refers to the native order.
Definition ByteOrder.inl:39
Order
enum for specifying the byte-order
Definition ByteOrder.h:104
@ big_endian
Definition ByteOrder.h:106
@ little_endian
Definition ByteOrder.h:105
@ native
Definition ByteOrder.h:107
@ swapped
Definition ByteOrder.h:108
static void swap_order(NUMBER &value)
swap the byteorder of the argument
Definition ByteOrder.h:122
void swap_if_necessary(NUMBER &a) const
this swaps only when the order != native order
Definition ByteOrder.h:145
ByteOrder(Order byte_order=native)
constructor, defaulting to 'native' byte order
Definition ByteOrder.inl:27
basic configuration include file