evio  6.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
evio::ByteOrder Class Reference

Numerical values associated with endian byte order. More...

#include <ByteOrder.h>

Public Member Functions

std::string getName () const
 Get the object name. More...
 
bool isBigEndian () const
 Is this big endian? More...
 
bool isLittleEndian () const
 Is this little endian? More...
 
bool isLocalEndian () const
 Is this endian same as the local host? More...
 
ByteOrder getOppositeEndian () const
 Get the oppposite endian (little if this is big and vice versa). More...
 
bool operator== (const ByteOrder &rhs) const
 
bool operator!= (const ByteOrder &rhs) const
 

Static Public Member Functions

static ByteOrder const & getLocalByteOrder ()
 Get the byte order of the local host. More...
 
static ByteOrder const & nativeOrder ()
 Get the byte order of the local host. More...
 
static bool isLocalHostBigEndian ()
 Is the local host big endian? More...
 
static bool needToSwap (ByteOrder &order)
 Is the argument the opposite of the local host's endian? More...
 
template<typename T >
static void byteSwapInPlace (T &var)
 Templated method to swap data in place. More...
 
template<typename T >
static void byteSwapInPlace (T &var, size_t elements)
 Templated method to swap array data in place. More...
 
template<typename T >
static void byteSwapInPlace (T *var, size_t elements)
 Templated method to swap array data in place. More...
 
static float byteSwap (float var)
 Convenience method to return swapped float. More...
 
static double byteSwap (double var)
 Convenience method to return swapped double. More...
 
static uint16_t * byteSwap16 (uint16_t *src, size_t elements, uint16_t *dst)
 This method swaps an array of 2-byte data. More...
 
static uint32_t * byteSwap32 (uint32_t *src, size_t elements, uint32_t *dst)
 This method swaps an array of 4-byte data. More...
 
static uint64_t * byteSwap64 (uint64_t *src, size_t elements, uint64_t *dst)
 This method swaps an array of 8-byte data. More...
 
static void byteNoSwap32 (const uint32_t *src, size_t elements, uint32_t *dst)
 This routine swaps nothing, it just copies the given number of 32 bit ints. More...
 

Static Public Attributes

static const ByteOrder ENDIAN_LITTLE
 Little endian byte order. More...
 
static const ByteOrder ENDIAN_BIG
 Big endian byte order. More...
 
static const ByteOrder ENDIAN_UNKNOWN
 Unknown endian byte order. More...
 
static const ByteOrder ENDIAN_LOCAL = ByteOrder::getLocalByteOrder()
 Local host's byte order. More...
 

Detailed Description

Numerical values associated with endian byte order.

Version
6.0
Since
6.0 4/16/2019
Author
timmer

Member Function Documentation

void evio::ByteOrder::byteNoSwap32 ( const uint32_t *  src,
size_t  elements,
uint32_t *  dst 
)
static

This routine swaps nothing, it just copies the given number of 32 bit ints.

If source pointer is null, nothing is done.

Parameters
srcpointer to data to be copied
elementsnumber of 32 bit ints to be copied
dstpointer to where data is to be copied to. If null, nothing is done.

Referenced by evio::EvioSwap::swapData().

float evio::ByteOrder::byteSwap ( float  var)
static

Convenience method to return swapped float.

Parameters
varfloat to swap
Returns
swapped float.

Referenced by evio::ByteBuffer::getDouble(), evio::ByteBuffer::getFloat(), evio::ByteBuffer::putDouble(), and evio::ByteBuffer::putFloat().

double evio::ByteOrder::byteSwap ( double  var)
static

Convenience method to return swapped double.

Parameters
vardouble to swap
Returns
swapped double.
uint16_t * evio::ByteOrder::byteSwap16 ( uint16_t *  src,
size_t  elements,
uint16_t *  dst 
)
static

This method swaps an array of 2-byte data.

If source pointer is null, nothing is done. If destination pointer is null, src is swapped in place.

Parameters
srcpointer to data source.
elementsnumber of 2-byte elements to swap.
dstpointer to destination or nullptr if data is to be swapped in place.
Returns
pointer to beginning of swapped data; null if src is null.

References SWAP_16.

Referenced by evio::EvioSwap::swapData(), evio::BaseStructure::updateShortData(), evio::BaseStructure::updateUShortData(), and evio::BaseStructure::write().

uint32_t * evio::ByteOrder::byteSwap32 ( uint32_t *  src,
size_t  elements,
uint32_t *  dst 
)
static

This method swaps an array of 4-byte data.

If source pointer is null, nothing is done. If destination pointer is null, src is swapped in place.

Parameters
srcpointer to data source.
elementsnumber of 4-byte elements to swap.
dstpointer to destination or nullptr if data is to be swapped in place.
Returns
pointer to beginning of swapped data; null if src is null.

References SWAP_32.

Referenced by evio::EvioSwap::swapBank(), evio::EvioSwap::swapData(), evio::EvioSwap::swapSegment(), evio::EvioSwap::swapTagsegment(), evio::BaseStructure::updateFloatData(), evio::BaseStructure::updateIntData(), evio::BaseStructure::updateUIntData(), and evio::BaseStructure::write().

uint64_t * evio::ByteOrder::byteSwap64 ( uint64_t *  src,
size_t  elements,
uint64_t *  dst 
)
static

This method swaps an array of 8-byte data.

If source pointer is null, nothing is done. If destination pointer is null, src is swapped in place.

Parameters
srcpointer to data source.
elementsnumber of 8-byte elements to swap.
dstpointer to destination or nullptr if data is to be swapped in place.
Returns
pointer to beginning of swapped data; null if src is null.

References SWAP_64.

Referenced by evio::EvioSwap::swapData(), evio::BaseStructure::updateDoubleData(), evio::BaseStructure::updateLongData(), evio::BaseStructure::updateULongData(), and evio::BaseStructure::write().

template<typename T >
void evio::ByteOrder::byteSwapInPlace ( T &  var)
static

Templated method to swap data in place.

Template Parameters
Ttype of data.
Parameters
varreference to data to be swapped.
template<typename T >
void evio::ByteOrder::byteSwapInPlace ( T &  var,
size_t  elements 
)
static

Templated method to swap array data in place.

Template Parameters
Tdata type.
Parameters
varreference to data to be swapped.
elementsnumber of data elements to be swapped.
template<typename T >
void evio::ByteOrder::byteSwapInPlace ( T *  var,
size_t  elements 
)
static

Templated method to swap array data in place.

If source pointer is null, nothing is done.

Template Parameters
Tdata type.
Parameters
varpointer to data to be swapped.
elementsnumber of data elements to be swapped.
static ByteOrder const& evio::ByteOrder::getLocalByteOrder ( )
inlinestatic

Get the byte order of the local host.

Returns
byte order of the local host.

References ENDIAN_BIG, ENDIAN_LITTLE, and isLocalHostBigEndian().

Referenced by nativeOrder(), and needToSwap().

std::string evio::ByteOrder::getName ( ) const
inline

Get the object name.

Returns
the object name.

Referenced by evio::CompositeData::parse().

ByteOrder evio::ByteOrder::getOppositeEndian ( ) const
inline

Get the oppposite endian (little if this is big and vice versa).

Returns
he oppposite endian.

References ENDIAN_BIG, ENDIAN_LITTLE, and isBigEndian().

Referenced by evio::EvioReaderV4::parseFirstHeader(), and evio::CompositeData::swapAll().

bool evio::ByteOrder::isBigEndian ( ) const
inline

Is this big endian?

Returns
true if big endian, else false.

References ENDIAN_BIG.

Referenced by getOppositeEndian().

bool evio::ByteOrder::isLittleEndian ( ) const
inline

Is this little endian?

Returns
true if little endian, else false.

References ENDIAN_LITTLE.

Referenced by evio::ByteBuffer::ByteBuffer().

bool evio::ByteOrder::isLocalEndian ( ) const
inline
static bool evio::ByteOrder::isLocalHostBigEndian ( )
inlinestatic

Is the local host big endian?

Returns
true if the local host is big endian, else false.

Referenced by getLocalByteOrder().

static ByteOrder const& evio::ByteOrder::nativeOrder ( )
inlinestatic

Get the byte order of the local host.

Returns
byte order of the local host.

References getLocalByteOrder().

static bool evio::ByteOrder::needToSwap ( ByteOrder order)
inlinestatic

Is the argument the opposite of the local host's endian?

Parameters
orderbyte order to compare to local host's.
Returns
true if the argument is the opposite of the local host's endian.

References getLocalByteOrder().

Referenced by evio::BaseStructure::updateDoubleData(), evio::BaseStructure::updateFloatData(), evio::BaseStructure::updateIntData(), evio::BaseStructure::updateLongData(), evio::BaseStructure::updateShortData(), evio::BaseStructure::updateUIntData(), evio::BaseStructure::updateULongData(), and evio::BaseStructure::updateUShortData().

bool evio::ByteOrder::operator!= ( const ByteOrder rhs) const
bool evio::ByteOrder::operator== ( const ByteOrder rhs) const

Member Data Documentation

const ByteOrder evio::ByteOrder::ENDIAN_UNKNOWN
static

Unknown endian byte order.


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