BinaryReader: add a way to read arbitrary types.
This commit is contained in:
parent
975f471a68
commit
7cb9ea28b2
1 changed files with 5 additions and 0 deletions
|
@ -53,6 +53,11 @@ class BinaryReader {
|
||||||
auto readDouble(Double& value) -> bool;
|
auto readDouble(Double& value) -> bool;
|
||||||
auto readArray(Containers::Array<char>& array, std::size_t count) -> 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>
|
template<std::size_t S>
|
||||||
auto readStaticArray(Containers::StaticArray<S, char>& array) -> bool {
|
auto readStaticArray(Containers::StaticArray<S, char>& array) -> bool {
|
||||||
return std::fread(array.data(), sizeof(char), S, _file) == S;
|
return std::fread(array.data(), sizeof(char), S, _file) == S;
|
||||||
|
|
Loading…
Reference in a new issue