SCIRun  5.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Namespaces | Macros | Functions
Endian.h File Reference

Detect host endianness and provide tools to swap bytes if necessary. More...

#include <sci_defs/config_defs.h>
#include <string>
#include <Core/Utils/Legacy/share.h>

Go to the source code of this file.

Namespaces

 SCIRun
 STL datatypes needed.
 

Macros

#define SWAP_2(u2)
 
#define SWAP_4(u4)
 
#define SWAP_8(u8)
 

Functions

void swapbytes (bool &)
 
void swapbytes (int8_t &)
 
void swapbytes (uint8_t &)
 
void swapbytes (int16_t &i)
 
void swapbytes (uint16_t &i)
 
void swapbytes (int32_t &i)
 
void swapbytes (uint32_t &i)
 
void swapbytes (int64_t &i)
 
void swapbytes (uint64_t &i)
 
void swapbytes (float &i)
 
void swapbytes (double &i)
 
bool isBigEndian ()
 
bool isLittleEndian ()
 
std::string endianness ()
 

Detailed Description

Detect host endianness and provide tools to swap bytes if necessary.

Author
Kurt Zimmerman Department of Computer Science University of Utah
Date
January 2001

Macro Definition Documentation

#define SWAP_2 (   u2)
Value:
/* IronDoc macro to swap two byte quantity */ \
{ unsigned char* _p = reinterpret_cast<unsigned char*>(&(u2)); \
unsigned char _c = *_p; *_p = _p[1]; _p[1] = _c; }
#define SWAP_4 (   u4)
Value:
/* IronDoc macro to swap four byte quantity */ \
{ unsigned char* _p = reinterpret_cast<unsigned char*>(&(u4)); \
unsigned char _c = *_p; *_p = _p[3]; _p[3] = _c; \
_c = *++_p; *_p = _p[1]; _p[1] = _c; }
#define SWAP_8 (   u8)
Value:
/* IronDoc macro to swap eight byte quantity */ \
{ unsigned char* _p = reinterpret_cast<unsigned char*>(&(u8)); \
unsigned char _c = *_p; *_p = _p[7]; _p[7] = _c; \
_c = *++_p; *_p = _p[5]; _p[5] = _c; \
_c = *++_p; *_p = _p[3]; _p[3] = _c; \
_c = *++_p; *_p = _p[1]; _p[1] = _c; }