BinaryReader: add a way to read arbitrary types.

This commit is contained in:
Guillaume Jacquemin 2022-02-16 11:47:49 +01:00
parent 975f471a68
commit 7cb9ea28b2
1 changed files with 5 additions and 0 deletions

View File

@ -53,6 +53,11 @@ class BinaryReader {
auto readDouble(Double& value) -> bool;
auto readArray(Containers::Array<char>& array, std::size_t count) -> bool;
template<typename T>
auto readValue(T& value) -> bool {
return fread(&value, sizeof(T), 1, _file) == sizeof(T);
}
template<std::size_t S>
auto readStaticArray(Containers::StaticArray<S, char>& array) -> bool {
return std::fread(array.data(), sizeof(char), S, _file) == S;