The Sparta Modeling Framework
Loading...
Searching...
No Matches
ByteOrder.hpp File Reference

Byte order types and byte-swapping routines. More...

#include <iostream>
#include <typeinfo>
#include <boost/mpl/assert.hpp>
#include "sparta/utils/SpartaException.hpp"
#include "sparta/utils/SpartaAssert.hpp"

Go to the source code of this file.

Namespaces

namespace  sparta
 Macros for handling exponential backoff.
 

Macros

#define HOST_INT_SIZE   sizeof(uint32_t)
 

Enumerations

enum  sparta::ByteOrder { LE = 0 , sparta::BE = 1 }
 Byte order enum for read/write methods. More...
 

Functions

template<typename T >
std::enable_if< std::is_integral< T >::value, T >::type sparta::byte_swap (T val)
 Swaps the order of bytes for various types.
 
template<>
uint8_t sparta::byte_swap (uint8_t val)
 
template<>
int8_t sparta::byte_swap (int8_t val)
 
template<>
uint16_t sparta::byte_swap (uint16_t val)
 
template<>
int16_t sparta::byte_swap (int16_t val)
 
template<>
uint32_t sparta::byte_swap (uint32_t val)
 
template<>
int32_t sparta::byte_swap (int32_t val)
 
template<>
uint64_t sparta::byte_swap (uint64_t val)
 
template<>
int64_t sparta::byte_swap (int64_t val)
 
template<typename T , enum ByteOrder BO>
std::enable_if< std::is_same< boost::mpl::int_< BO >, boost::mpl::int_< BE > >::value, T >::type sparta::reorder (const T &t)
 
template<typename T , enum ByteOrder BO>
std::enable_if< std::is_same< boost::mpl::int_< BO >, boost::mpl::int_< LE > >::value, T >::type sparta::reorder (const T &t)
 

Detailed Description

Byte order types and byte-swapping routines.

Contains byte_swap methods for a number of types.

Definition in file ByteOrder.hpp.

Macro Definition Documentation

◆ HOST_INT_SIZE

#define HOST_INT_SIZE   sizeof(uint32_t)

Targeted for a Little Endian architecture. If this were to change, ArchData store/load routines would need to be updated to detect or force a byte-order. read/write routines would also need to change.

Definition at line 28 of file ByteOrder.hpp.