]> git.sesse.net Git - stockfish/blobdiff - src/book.cpp
Reintroduce operator>>() in Book class
[stockfish] / src / book.cpp
index 26fd7c92faa930518315c46222ad31c08d326ec0..757c8238fe82627143215c7bc73932605a593c9b 100644 (file)
@@ -502,15 +502,17 @@ int Book::find_entry(uint64_t key) {
 }
 
 
-/// Book::get_number() reads sizeof(T) chars from the file's binary byte
+/// 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>
-void Book::get_number(T& n) {
+Book& Book::operator>>(T& n) {
 
   n = 0;
 
   for (size_t i = 0; i < sizeof(T); i++)
       n = (n << 8) + (T)bookFile.get();
+
+  return *this;
 }
 
 
@@ -526,10 +528,7 @@ BookEntry Book::read_entry(int idx) {
 
   bookFile.seekg(idx * sizeof(BookEntry), ios_base::beg);
 
-  get_number(e.key);
-  get_number(e.move);
-  get_number(e.count);
-  get_number(e.learn);
+  *this >> e.key >> e.move >> e.count >> e.learn;
 
   if (!bookFile.good())
   {