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;
}
+1 -1
View File
@@ -357,7 +357,7 @@ class StaticRTree
}
boost::filesystem::ifstream tree_node_file(node_file, std::ios::binary);
const auto tree_size = storage::io::readElementCount(tree_node_file);
const auto tree_size = storage::io::readElementCount64(tree_node_file);
m_search_tree.resize(tree_size);
storage::io::readRamIndex(tree_node_file, &m_search_tree[0], tree_size);