Multiscale Universal Interface  2.0
A Concurrent Framework for Coupling Heterogeneous Solvers
endian_traits.h File Reference

Support for dealing with big and little endian platforms. More...

#include <cstdint>
#include <endian.h>
Include dependency graph for endian_traits.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  mui::detail::uint< 1 >
 
struct  mui::detail::uint< 2 >
 
struct  mui::detail::uint< 4 >
 
struct  mui::detail::uint< 8 >
 
struct  mui::detail::endian_converter< size_bytes >
 
union  mui::detail::endian_converter< size_bytes >::data_t
 
struct  mui::endian_traits< T, typename std::enable_if< std::is_integral< T >::value >::type >
 
struct  mui::endian_traits< T, typename std::enable_if< std::is_floating_point< T >::value >::type >
 

Namespaces

 mui
 
 mui::detail
 

Macros

#define MUI_POSITIVE   true
 
#define MUI_NEGATIVE   false
 
#define MUI_INT_DEFINED   MUI_NEGATIVE
 
#define MUI_CONVERT_FLOAT   MUI_CONVERT_INT
 

Detailed Description

Support for dealing with big and little endian platforms.

Author
R. W. Nash r.nas.nosp@m.h@ep.nosp@m.cc.ed.nosp@m..ac..nosp@m.uk
Date
14 November 2018

Currently this only supports big and little endian platforms, if you're on something odder, then this wont work.

The primary export of this header is a template struct endian_traits - see below for a details

You can configure endianness and conversion by defining one of the following

  1. no endian options, in which case this header will try to figure it out but that probably only works on GCC
  2. MUI_IGNORE_ENDIAN - this mode will never reorder the bytes of a multibyte number
  3. (MUI_INT_BIG_ENDIAN ^ MUI_INT_LITTLE_ENDIAN) && (MUI_FLOAT_BIG_ENDIAN ^ MUI_FLOAT_LITTLE_ENDIAN)

    where:

    • MUI_INT_BIG_ENDIAN - this will assume that the host has a big endian representation of integers
    • MUI_INT_LITTLE_ENDIAN - this will assume that the host has a little endian representation of integers
    • MUI_FLOAT_BIG_ENDIAN - this will assume that the host has a big endian representation of floating values
    • MUI_FLOAT_LITTLE_ENDIAN - this will assume that the host has a little endian representation of floating values

Macro Definition Documentation

◆ MUI_CONVERT_FLOAT

#define MUI_CONVERT_FLOAT   MUI_CONVERT_INT

◆ MUI_INT_DEFINED

#define MUI_INT_DEFINED   MUI_NEGATIVE

◆ MUI_NEGATIVE

#define MUI_NEGATIVE   false

◆ MUI_POSITIVE

#define MUI_POSITIVE   true