refactor bitfield io
This commit is contained in:
@@ -4,34 +4,13 @@
|
||||
|
||||
namespace sp {
|
||||
|
||||
/**
|
||||
* \brief Serialize value to (network byte order) big endian
|
||||
*/
|
||||
template <typename T>
|
||||
void ToNetwork(T& value) {}
|
||||
bool IsLittleEndian();
|
||||
|
||||
template <>
|
||||
void ToNetwork<std::uint16_t>(std::uint16_t& value);
|
||||
void SwapBytes(std::uint8_t* begin, std::uint8_t* end);
|
||||
|
||||
template <>
|
||||
void ToNetwork<std::uint32_t>(std::uint32_t& value);
|
||||
|
||||
template <>
|
||||
void ToNetwork<std::uint64_t>(std::uint64_t& value);
|
||||
|
||||
/**
|
||||
* \brief Deserialize value from (network byte order) big endian
|
||||
*/
|
||||
template <typename T>
|
||||
void FromNetwork(T& value) {}
|
||||
|
||||
template <>
|
||||
void FromNetwork<std::uint16_t>(std::uint16_t& value);
|
||||
|
||||
template <>
|
||||
void FromNetwork<std::uint32_t>(std::uint32_t& value);
|
||||
|
||||
template <>
|
||||
void FromNetwork<std::uint64_t>(std::uint64_t& value);
|
||||
template<typename T>
|
||||
void SwapBytes(T& a_Data) {
|
||||
SwapBytes(reinterpret_cast<std::uint8_t*>(&a_Data), reinterpret_cast<std::uint8_t*>(&a_Data) + sizeof(T));
|
||||
}
|
||||
|
||||
} // namespace sp
|
||||
|
||||
Reference in New Issue
Block a user