#include namespace ctrff { /** Supported reads */ template CTRFF_API void BinUtil::Read(PD::u8&); template CTRFF_API void BinUtil::Read(PD::u16&); template CTRFF_API void BinUtil::Read(PD::u32&); template CTRFF_API void BinUtil::Read(PD::u64&); /** Supported writes */ template CTRFF_API void BinUtil::Write(const PD::u8&); template CTRFF_API void BinUtil::Write(const PD::u16&); template CTRFF_API void BinUtil::Write(const PD::u32&); template CTRFF_API void BinUtil::Write(const PD::u64&); template void BinUtil::Read(T& v) { // Check if Value could be Read static_assert(std::is_integral::value, "Cannot Read type T"); v = 0; // Set value to 0 (most cases a windows problem) std::vector buf(sizeof(T), 0); // declare buffer // Read data into buffer m_file.read(reinterpret_cast(buf.data()), sizeof(T)); // Loop or in be reverse loop and chift the values for (int i = 0; i < sizeof(T); i++) { v |= static_cast(buf[m_big ? sizeof(T) - 1 - i : i]) << (8 * i); } } template void BinUtil::Write(const T& v) { // Check if Value could Write static_assert(std::is_integral::value, "Cannot Write type T"); std::vector buf(sizeof(T), 0); // declare buffer // Loop or in be reverse loop and write the values for (size_t i = 0; i < sizeof(T); i++) { buf[(m_big ? sizeof(T) - 1 - i : i)] = buf[m_big ? sizeof(T) - 1 - i : i] = static_cast((v >> (8 * i)) & 0xFF); } // Write buffer into file m_file.write(reinterpret_cast(buf.data()), sizeof(T)); } } // namespace ctrff