用于处理大小端运算,根据实际平台字节序类型进行自动匹配
更多...
#include <NBT_Endian.hpp>
|
| static constexpr bool | IsLittleEndian (void) noexcept |
| | 判断当前平台字节序是否是小端字节序
|
| static constexpr bool | IsBigEndian (void) noexcept |
| | 判断当前平台字节序是否是大端字节序
|
template<typename T>
requires std::integral<T> |
| static constexpr T | ByteSwapAny (T data) noexcept |
| | 颠倒字节序,需要整数字节数为2的倍数或字节数为1
|
| static uint16_t | ByteSwap16 (uint16_t data) noexcept |
| | 颠倒字节序16位特化版
|
| static uint32_t | ByteSwap32 (uint32_t data) noexcept |
| | 颠倒字节序32位特化版
|
| static uint64_t | ByteSwap64 (uint64_t data) noexcept |
| | 颠倒字节序32位特化版
|
template<typename T>
requires std::integral<T> |
| static constexpr T | AutoByteSwap (T data) noexcept |
| | 颠倒字节序,自动匹配位数
|
template<typename T>
requires std::integral<T> |
| static T | NativeToBigAny (T data) noexcept |
| | 从当前平台字节序转换到大端字节序,自动匹配位数
|
template<typename T>
requires std::integral<T> |
| static T | NativeToLittleAny (T data) noexcept |
| | 从当前平台字节序转换到小端字节序,自动匹配位数
|
template<typename T>
requires std::integral<T> |
| static T | BigToNativeAny (T data) noexcept |
| | 从大端字节序转换到当前平台字节序,自动匹配位数
|
template<typename T>
requires std::integral<T> |
| static T | LittleToNativeAny (T data) noexcept |
| | 从小端字节序转换到当前平台字节序,自动匹配位数
|
用于处理大小端运算,根据实际平台字节序类型进行自动匹配
◆ AutoByteSwap()
template<typename T>
requires std::integral<T>
| constexpr T NBT_Endian::AutoByteSwap |
( |
T | data | ) |
|
|
inlinestaticconstexprnoexcept |
颠倒字节序,自动匹配位数
- 模板参数
-
- 参数
-
- 返回
- 字节序的颠倒形式
- 注解
- 如果没有T类型位数的特化版,则落到保守实现ByteSwapAny
◆ BigToNativeAny()
template<typename T>
requires std::integral<T>
| T NBT_Endian::BigToNativeAny |
( |
T | data | ) |
|
|
inlinestaticnoexcept |
从大端字节序转换到当前平台字节序,自动匹配位数
- 模板参数
-
- 参数
-
- 返回
- 平台字节序的值
- 注解
- 如果平台字节序与大端相同,则返回值不变
◆ ByteSwap16()
| uint16_t NBT_Endian::ByteSwap16 |
( |
uint16_t | data | ) |
|
|
inlinestaticnoexcept |
颠倒字节序16位特化版
- 参数
-
- 返回
- 字节序的颠倒形式
- 注解
- 如果平台支持内建指令,则使用平台内建指令,否则落到保守实现ByteSwapAny
◆ ByteSwap32()
| uint32_t NBT_Endian::ByteSwap32 |
( |
uint32_t | data | ) |
|
|
inlinestaticnoexcept |
颠倒字节序32位特化版
- 参数
-
- 返回
- 字节序的颠倒形式
- 注解
- 如果平台支持内建指令,则使用平台内建指令,否则落到保守实现ByteSwapAny
◆ ByteSwap64()
| uint64_t NBT_Endian::ByteSwap64 |
( |
uint64_t | data | ) |
|
|
inlinestaticnoexcept |
颠倒字节序32位特化版
- 参数
-
- 返回
- 字节序的颠倒形式
- 注解
- 如果平台支持内建指令,则使用平台内建指令,否则落到保守实现ByteSwapAny
◆ ByteSwapAny()
template<typename T>
requires std::integral<T>
| constexpr T NBT_Endian::ByteSwapAny |
( |
T | data | ) |
|
|
inlinestaticconstexprnoexcept |
颠倒字节序,需要整数字节数为2的倍数或字节数为1
- 模板参数
-
- 参数
-
- 返回
- 字节序的颠倒形式
- 注解
- 保守实现,仅需平台支持位操作
◆ IsBigEndian()
| constexpr bool NBT_Endian::IsBigEndian |
( |
void | | ) |
|
|
inlinestaticconstexprnoexcept |
判断当前平台字节序是否是大端字节序
- 返回
- 如果是大端字节序,返回true,否则返回false
◆ IsLittleEndian()
| constexpr bool NBT_Endian::IsLittleEndian |
( |
void | | ) |
|
|
inlinestaticconstexprnoexcept |
判断当前平台字节序是否是小端字节序
- 返回
- 如果是小端字节序,返回true,否则返回false
◆ LittleToNativeAny()
template<typename T>
requires std::integral<T>
| T NBT_Endian::LittleToNativeAny |
( |
T | data | ) |
|
|
inlinestaticnoexcept |
从小端字节序转换到当前平台字节序,自动匹配位数
- 模板参数
-
- 参数
-
- 返回
- 平台字节序的值
- 注解
- 如果平台字节序与小端相同,则返回值不变
◆ NativeToBigAny()
template<typename T>
requires std::integral<T>
| T NBT_Endian::NativeToBigAny |
( |
T | data | ) |
|
|
inlinestaticnoexcept |
从当前平台字节序转换到大端字节序,自动匹配位数
- 模板参数
-
- 参数
-
- 返回
- 大端字节序的值
- 注解
- 如果平台字节序与大端相同,则返回值不变
◆ NativeToLittleAny()
template<typename T>
requires std::integral<T>
| T NBT_Endian::NativeToLittleAny |
( |
T | data | ) |
|
|
inlinestaticnoexcept |
从当前平台字节序转换到小端字节序,自动匹配位数
- 模板参数
-
- 参数
-
- 返回
- 小端字节序的值
- 注解
- 如果平台字节序与小端相同,则返回值不变
该类的文档由以下文件生成: