STIR  6.2.0
Public Types | Public Member Functions | Static Public Member Functions | List of all members
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 More...
 
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. More...
 
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

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 stir::ecat::CListModeDataECAT8_32bit::get_empty_record_sptr(), is_native_order(), stir::CListModeDataSAFIR< CListRecordT >::reset(), and stir::ProjDataFromStream::set_segment().

◆ operator==()

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

comparison operator

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

References is_native_order().


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