const-ify things, use RAII for file closure, and start to use io:: to read some stuff.

This commit is contained in:
Daniel Patterson
2016-11-10 23:04:32 -08:00
parent b1125b7f1f
commit e226b52f21
3 changed files with 307 additions and 290 deletions
+9 -2
View File
@@ -21,10 +21,17 @@ namespace io
{
// Reads the count of elements that is written in the file header and returns the number
inline std::uint64_t readElementCount(boost::filesystem::ifstream &input_stream)
inline std::uint64_t readElementCount64(boost::filesystem::ifstream &input_stream)
{
std::uint64_t number_of_elements = 0;
input_stream.read((char *)&number_of_elements, sizeof(std::uint64_t));
input_stream.read(reinterpret_cast<char *>(&number_of_elements), sizeof(number_of_elements));
return number_of_elements;
}
inline std::uint64_t readElementCount32(boost::filesystem::ifstream &input_stream)
{
std::uint32_t number_of_elements = 0;
input_stream.read(reinterpret_cast<char *>(&number_of_elements), sizeof(number_of_elements));
return number_of_elements;
}