STIR 6.5.0
stir::ByteOrder Class Reference

This class provides member functions to find out what byte-order your machine is and to swap numbers. More...

#include "stir/ByteOrder.h"

Public Types

enum  Order { little_endian , big_endian , native , swapped }
 enum for specifying the byte-order More...

Public Member Functions

 ByteOrder (Order byte_order=native)
 constructor, defaulting to 'native' byte order
bool operator== (const ByteOrder order2) const
 comparison operator
bool operator!= (const ByteOrder order2) const
bool is_native_order () const
 check if the object refers to the native order.
template<class NUMBER>
void swap_if_necessary (NUMBER &a) const
 this swaps only when the order != native order

Static Public Member Functions

static Order get_native_order ()
 returns the byte-order native to the machine the programme is running on.
template<class NUMBER>
static void swap_order (NUMBER &value)
 swap the byteorder of the argument

Detailed Description

This class provides member functions to find out what byte-order your machine is and to swap numbers.

Some machine architectures:
-Little endian processors: Intel, Alpha, VAX, PDP-11, ... -Big endian processors: Sparc, PowerPC, Motorola 68???, ...

In a little-endian architecture, within a given 16- or 32-bit word, bytes at lower addresses have lower significance (the word is stored little-end-first). (Quoted from http://www.techfak.uni-bielefeld.de/~joern/jargon/)

Member Enumeration Documentation

◆ Order

enum for specifying the byte-order

Enumerator
little_endian 

is like x86, MIPS

big_endian 

is like PowerPC, Sparc.

native 

means the same order as the machine the programme is running on

swapped 

means the opposite order of native

Constructor & Destructor Documentation

◆ ByteOrder()

stir::ByteOrder::ByteOrder ( Order byte_order = native)
inline

constructor, defaulting to 'native' byte order

References ByteOrder().

Referenced by ByteOrder(), and operator==().

Member Function Documentation

◆ get_native_order()

ByteOrder::Order stir::ByteOrder::get_native_order ( )
inlinestatic

returns the byte-order native to the machine the programme is running on.

for efficiency, this refers to the static member native_order.

Referenced by is_native_order(), and stir::ByteOrderTests::run_tests().

◆ swap_order()

template<class NUMBER>
void stir::ByteOrder::swap_order ( NUMBER & value)
inlinestatic

swap the byteorder of the argument

Referenced by stir::detail::read_data_1d(), swap_if_necessary(), and stir::detail::write_data_1d().

◆ operator==()

bool stir::ByteOrder::operator== ( const ByteOrder order2) const
inline

comparison operator

This takes care of interpreting 'native' and 'swapped'.

References ByteOrder(), and is_native_order().

◆ is_native_order()

◆ swap_if_necessary()

template<class NUMBER>
void stir::ByteOrder::swap_if_necessary ( NUMBER & a) const
inline

this swaps only when the order != native order

References is_native_order(), and swap_order().


The documentation for this class was generated from the following files: