Sese Framework
2.3.0
A cross-platform framework
|
Endianness conversion. More...
#include <type_traits>
#include <cstring>
#include <cstdint>
Go to the source code of this file.
Macros | |
#define | ByteSwap16(i16) ((i16 & 0x00FF) << 8 | (i16 & 0xFF00) >> 8) |
#define | ByteSwap32(i32) ((i32 & 0x000000FF) << 24 | (i32 & 0x0000FF00) << 8 | (i32 & 0x00FF0000) >> 8 | (i32 & 0xFF000000) >> 24) |
#define | ByteSwap64(i64) |
#define | SESE_LITTLE_ENDIAN |
#define | ASSERT_FLOAT_SIZE static_assert(sizeof(float) == 4, "Float size is not 4 bytes") |
#define | ASSERT_DOUBLE_SIZE static_assert(sizeof(double) == 8, "Double size is not 8 bytes") |
Enumerations | |
enum class | EndianType { LITTLE , BIG } |
Functions | |
template<typename T > | |
T | ToBigEndian16 (T t) |
template<typename T > | |
T | ToBigEndian32 (T t) |
template<typename T > | |
T | ToBigEndian64 (T t) |
template<typename T > | |
T | ToLittleEndian16 (T t) |
template<typename T > | |
T | ToLittleEndian32 (T t) |
template<typename T > | |
T | ToLittleEndian64 (T t) |
template<typename T > | |
T | FromBigEndian16 (T t) |
template<typename T > | |
T | FromBigEndian32 (T t) |
template<typename T > | |
T | FromBigEndian64 (T t) |
template<typename T > | |
T | FromLittleEndian16 (T t) |
template<typename T > | |
T | FromLittleEndian32 (T t) |
template<typename T > | |
T | FromLittleEndian64 (T t) |
template<typename T > | |
std::enable_if< sizeof(T)==2, T >::t | ToBigEndian (T t) |
template<typename T > | |
std::enable_if< sizeof(T)==4, T >::t | ToBigEndian (T t) |
template<typename T > | |
std::enable_if< sizeof(T)==8, T >::t | ToBigEndian (T t) |
template<typename T > | |
T | ToLittleEndian (T t) |
template<typename T > | |
std::enable_if< sizeof(T)==2, T >::t | FromBigEndian (T t) |
template<typename T > | |
std::enable_if< sizeof(T)==4, T >::t | FromBigEndian (T t) |
template<typename T > | |
std::enable_if< sizeof(T)==8, T >::t | FromBigEndian (T t) |
template<typename T > | |
T | FromLittleEndian (T t) |
template<> | |
float | ToBigEndian32 (float t) |
template<> | |
double | ToBigEndian64 (double t) |
template<> | |
float | ToLittleEndian32 (float t) |
template<> | |
double | ToLittleEndian64 (double t) |
template<> | |
float | FromBigEndian32 (float t) |
template<> | |
double | FromBigEndian64 (double t) |
template<> | |
float | FromLittleEndian32 (float t) |
template<> | |
double | FromLittleEndian64 (double t) |
Endianness conversion.
#define ASSERT_DOUBLE_SIZE static_assert(sizeof(double) == 8, "Double size is not 8 bytes") |
Referenced by FromBigEndian64(), FromLittleEndian64(), ToBigEndian64(), and ToLittleEndian64().
#define ASSERT_FLOAT_SIZE static_assert(sizeof(float) == 4, "Float size is not 4 bytes") |
Referenced by FromBigEndian32(), FromLittleEndian32(), ToBigEndian32(), and ToLittleEndian32().
#define ByteSwap16 | ( | i16 | ) | ((i16 & 0x00FF) << 8 | (i16 & 0xFF00) >> 8) |
Referenced by FromBigEndian(), FromBigEndian16(), ToBigEndian(), and ToBigEndian16().
#define ByteSwap32 | ( | i32 | ) | ((i32 & 0x000000FF) << 24 | (i32 & 0x0000FF00) << 8 | (i32 & 0x00FF0000) >> 8 | (i32 & 0xFF000000) >> 24) |
Referenced by FromBigEndian(), FromBigEndian32(), ToBigEndian(), and ToBigEndian32().
#define ByteSwap64 | ( | i64 | ) |
Referenced by FromBigEndian(), FromBigEndian64(), ToBigEndian(), and ToBigEndian64().
#define SESE_LITTLE_ENDIAN |
|
strong |
|
inline |
References ByteSwap16.
|
inline |
References ByteSwap32.
|
inline |
References ByteSwap64.
|
inline |
References ByteSwap16.
Referenced by sese::net::dns::DnsPackage::decode(), sese::net::dns::DnsPackage::decodeAnswers(), sese::net::dns::DnsPackage::decodeWords(), sese::net::IPv4Address::getPort(), sese::net::IPv6Address::getPort(), sese::internal::service::http::HttpConnectionEx::handleSettingsFrame(), and sese::net::Socket::readInt16().
|
inline |
References ASSERT_FLOAT_SIZE, and FromBigEndian32().
|
inline |
References ByteSwap32.
Referenced by sese::Bitset32::Bitset32(), sese::net::dns::DnsPackage::decodeAnswers(), sese::SHA1Util::encode(), sese::Base64Converter::encodeBase62(), FromBigEndian32(), FromLittleEndian32(), sese::Bitset32::get(), sese::internal::service::http::HttpConnectionEx::handleGoawayFrame(), sese::internal::service::http::HttpConnectionEx::handleHeadersFrame(), sese::internal::service::http::HttpConnectionEx::handlePriorityFrame(), sese::internal::service::http::HttpConnectionEx::handleRstStreamFrame(), sese::internal::service::http::HttpConnectionEx::handleSettingsFrame(), sese::internal::service::http::HttpConnectionEx::handleWindowUpdate(), sese::Bitset32::operator+(), and sese::internal::service::http::HttpConnectionEx::readFrameHeader().
|
inline |
References ASSERT_DOUBLE_SIZE, and FromBigEndian64().
|
inline |
References ByteSwap64.
Referenced by FromBigEndian64(), and FromLittleEndian64().
|
inline |
|
inline |
|
inline |
References ASSERT_FLOAT_SIZE, and FromBigEndian32().
|
inline |
|
inline |
References ASSERT_DOUBLE_SIZE, and FromBigEndian64().
|
inline |
|
inline |
References ByteSwap16.
|
inline |
References ByteSwap32.
|
inline |
References ByteSwap64.
|
inline |
References ByteSwap16.
Referenced by sese::net::IPv4Address::create(), sese::net::IPv6Address::create(), sese::net::dns::DnsPackage::encode(), sese::net::dns::DnsPackage::encodeAnswers(), sese::net::dns::DnsPackage::encodeQuestions(), sese::net::dns::DnsPackage::Index::encodeWords(), sese::net::IPv6Address::getAddress(), sese::net::IPv4Address::IPv4Address(), sese::net::IPv6Address::IPv6Address(), sese::MemoryViewer::peer16(), sese::net::IPv4Address::setPort(), sese::net::IPv6Address::setPort(), sese::net::Socket::writeInt16(), and sese::internal::service::http::HttpConnectionEx::writeSettingsFrame().
|
inline |
References ASSERT_FLOAT_SIZE, and ToBigEndian32().
|
inline |
References ByteSwap32.
Referenced by sese::net::http::Http2Frame::buildFrameHeader(), sese::Base64Converter::decodeBase62(), sese::net::dns::DnsPackage::encodeAnswers(), sese::net::IPv4Address::getBroadcastAddress(), sese::net::IPv4Address::getNetworkAddress(), sese::net::IPv4Address::getSubnetMask(), sese::net::IPv4Address::IPv4Address(), sese::Bitset32::operator+(), sese::MemoryViewer::peer32(), sese::Bitset32::set(), ToBigEndian32(), ToLittleEndian32(), sese::internal::service::http::HttpConnectionEx::writeGoawayFrame(), sese::internal::service::http::HttpConnectionEx::writeRstStreamFrame(), sese::internal::service::http::HttpConnectionEx::writeSettingsFrame(), and sese::internal::service::http::HttpConnectionEx::writeWindowUpdateFrame().
|
inline |
References ASSERT_DOUBLE_SIZE, and ToBigEndian64().
|
inline |
References ByteSwap64.
Referenced by sese::SHA1Util::encode(), sese::SHA256Util::encode(), sese::MemoryViewer::peer64(), ToBigEndian64(), and ToLittleEndian64().
|
inline |
Referenced by sese::SHA256Util::encode().
|
inline |
Referenced by sese::MemoryViewer::peer16().
|
inline |
References ASSERT_FLOAT_SIZE, and ToBigEndian32().
|
inline |
Referenced by sese::net::IPv4Address::getAddress(), and sese::MemoryViewer::peer32().
|
inline |
References ASSERT_DOUBLE_SIZE, and ToBigEndian64().
|
inline |
Referenced by sese::MD5Util::encode(), and sese::MemoryViewer::peer64().