EMAN2
|
ByteOrder defines functions to work on big/little endian byte orders. More...
#include <byteorder.h>
Static Public Member Functions | |
static bool | is_host_big_endian () |
static bool | is_float_big_endian (float small_number) |
given a small floating number, return whether the number is in big endian or not. More... | |
template<class T > | |
static bool | is_data_big_endian (const T *small_num_addr) |
given a pointer to a reasonable small integer number, return whether the number is big endian or not. More... | |
template<class T > | |
static void | become_big_endian (T *data, size_t n=1) |
convert data from host byte order to big endian order. More... | |
template<class T > | |
static void | become_little_endian (T *data, size_t n=1) |
convert data from host byte order to little endian order. More... | |
template<class T > | |
static void | swap_bytes (T *data, size_t n=1) |
swap the byte order of data with 'n' T-type elements. More... | |
Static Private Attributes | |
static bool | is_host_endian_checked = false |
static bool | host_big_endian = false |
ByteOrder defines functions to work on big/little endian byte orders.
The byte order is the order in which bytes are stored to create larger data types such as the int and long values. Different kinds of computers use different byte order conventions.
There are 2 major byte orders: big-endian and little-endian.
big-endian (like SGI) store the most significant bytes (i.e. the bytes that hold the largest part of the value) first. little-endian (like x86) store the most significant byte last.
The host byte order is the byte order used on the current host.
ByteOrder class defines functions for checking running-host byte-order, checking data byte-order, convert data from one byte-order to another byte-order.
Definition at line 58 of file byteorder.h.
|
inlinestatic |
convert data from host byte order to big endian order.
'n' is the number of elements of type T.
Definition at line 112 of file byteorder.h.
References is_host_big_endian().
Referenced by EMAN::DM3IO::is_valid(), EMAN::Gatan::TagData::read(), EMAN::Gatan::TagGroup::read(), EMAN::Gatan::TagEntry::read(), EMAN::Gatan::TagData::read_any(), EMAN::GatanDM4::TagData::read_any(), EMAN::Gatan::TagData::read_array_data(), EMAN::GatanDM4::TagData::read_array_data(), EMAN::Gatan::TagData::read_array_types(), EMAN::GatanDM4::TagData::read_array_types(), EMAN::Gatan::TagData::read_struct_types(), EMAN::GatanDM4::TagData::read_struct_types(), EMAN::GatanDM4::TagData::read_tag_data(), EMAN::GatanDM4::TagEntry::read_tag_entry(), and EMAN::GatanDM4::TagGroup::read_tag_group().
|
inlinestatic |
convert data from host byte order to little endian order.
'n' is the number of elements of type T.
Definition at line 122 of file byteorder.h.
References is_host_big_endian().
|
inlinestatic |
given a pointer to a reasonable small integer number, return whether the number is big endian or not.
For a n-bit integer, the number should < (2 ^ (n/2)). e.g., for 'int', number should < 65535; for 'short', number should < 255.
Definition at line 76 of file byteorder.h.
References is_host_big_endian().
Referenced by EMAN::DM4IO::is_valid(), EMAN::Gatan2IO::is_valid(), EMAN::IcosIO::is_valid(), EMAN::ImagicIO::is_valid(), EMAN::ImagicIO2::is_valid(), EMAN::Df3IO::is_valid(), and EMAN::EmIO::is_valid().
|
static |
given a small floating number, return whether the number is in big endian or not.
If a number is smaller than 65535, it is defined as a "small" number here.
Definition at line 59 of file byteorder.cpp.
References EMAN::Util::goodf(), and is_host_big_endian().
Referenced by EMAN::SpiderIO::is_valid(), and EMAN::SingleSpiderIO::is_valid().
|
static |
Definition at line 40 of file byteorder.cpp.
References host_big_endian, and is_host_endian_checked.
Referenced by become_big_endian(), EMAN::Gatan::TagTable::become_host_endian(), EMAN::GatanDM4::TagTable::become_host_endian(), EMAN::ImageIO::become_host_endian(), become_little_endian(), EMAN::DM3IO::DM3IO(), EMAN::DM4IO::DM4IO(), EMAN::EmIO::EmIO(), EMAN::FitsIO::FitsIO(), EMAN::Gatan2IO::Gatan2IO(), EMAN::MrcIO::generate_machine_stamp(), EMAN::IcosIO::IcosIO(), EMAN::ImagicIO::ImagicIO(), EMAN::ImagicIO2::ImagicIO2(), is_data_big_endian(), is_float_big_endian(), EMAN::DM4IO::is_valid(), EMAN::Gatan2IO::is_valid(), EMAN::IcosIO::is_valid(), EMAN::ImagicIO::is_valid(), EMAN::ImagicIO2::is_valid(), EMAN::PifIO::is_valid(), EMAN::SpiderIO::is_valid(), EMAN::SingleSpiderIO::is_valid(), EMAN::EmIO::is_valid(), EMAN::OmapIO::is_valid(), EMAN::LstFastIO::LstFastIO(), EMAN::LstIO::LstIO(), EMAN::ImagicIO2::make_header_host_endian(), EMAN::ImagicIO::make_header_host_endian(), EMAN::MrcIO::MrcIO(), EMAN::SpiderIO::need_swap(), EMAN::OmapIO::OmapIO(), EMAN::PifIO::PifIO(), EMAN::Util::recv_broadcast(), EMAN::EMData::save_byteorder_to_dict(), EMAN::VtkIO::VtkIO(), EMAN::XplorIO::XplorIO(), and EMAN::XYZIO::XYZIO().
|
inlinestatic |
swap the byte order of data with 'n' T-type elements.
Definition at line 131 of file byteorder.h.
Referenced by EMAN::Gatan::TagTable::become_host_endian(), EMAN::GatanDM4::TagTable::become_host_endian(), EMAN::ImageIO::become_host_endian(), EMAN::MrcIO::check_swap(), EMAN::DM4IO::is_valid(), EMAN::Gatan2IO::is_valid(), EMAN::IcosIO::is_valid(), EMAN::ImagicIO::is_valid(), EMAN::ImagicIO2::is_valid(), EMAN::PifIO::is_valid(), EMAN::SpiderIO::is_valid(), EMAN::SingleSpiderIO::is_valid(), EMAN::EmIO::is_valid(), EMAN::MrcIO::is_valid(), EMAN::OmapIO::is_valid(), EMAN::SpiderIO::swap_data(), EMAN::ImagicIO2::swap_header(), EMAN::ImagicIO::swap_header(), EMAN::MrcIO::swap_header(), EMAN::SpiderIO::swap_header(), EMAN::SpiderIO::write_single_data(), and EMAN::SpiderIO::write_single_header().
|
staticprivate |
Definition at line 150 of file byteorder.h.
Referenced by is_host_big_endian().
|
staticprivate |
Definition at line 149 of file byteorder.h.
Referenced by is_host_big_endian().