diff --git a/tools/HogMaker/IOOps.h b/lib/IOOps.h similarity index 66% rename from tools/HogMaker/IOOps.h rename to lib/IOOps.h index 57739270..7efd3bdf 100644 --- a/tools/HogMaker/IOOps.h +++ b/lib/IOOps.h @@ -18,18 +18,28 @@ #pragma once #include +#include #include #include "byteswap.h" namespace D3 { -template -static inline std::ostream &bin_write(std::ostream &output, T value, bool is_little_endian = true, size_t n = sizeof(T)) { +template >> +static inline std::ostream &bin_write(std::ostream &output, T value, bool is_little_endian = true, + size_t n = sizeof(T)) { value = is_little_endian ? convert_le(value) : convert_be(value); output.write(reinterpret_cast(&value), n); return output; } +template >> +static inline std::istream &bin_read(std::istream &input, T &value, bool is_little_endian = true, size_t n = sizeof(T)) { + input.read(reinterpret_cast(&value), n); + value = is_little_endian ? convert_le(value) : convert_be(value); + + return input; +} + } // namespace D3