-
-/// Book::operator>>() reads sizeof(T) chars from the file's binary byte
-/// stream and converts them in a number of type T.
-template<typename T>
-Book& Book::operator>>(T& n) {
-
- n = 0;
-
- for (size_t i = 0; i < sizeof(T); i++)
- n = T((n << 8) + bookFile.get());
-
- return *this;
-}
-
-
-/// Book::read_entry() takes an integer index, and returns the BookEntry
-/// at the given index in the book file.
-
-BookEntry Book::read_entry(int idx) {
-
- assert(idx >= 0 && idx < bookSize);
- assert(bookFile.is_open());
-
- BookEntry e;
-
- bookFile.seekg(idx * sizeof(BookEntry), ios_base::beg);
-
- *this >> e.key >> e.move >> e.count >> e.learn;
-
- if (!bookFile.good())
- {
- cerr << "Failed to read book entry at index " << idx << endl;
- exit(EXIT_FAILURE);
- }
- return e;