From: Marco Costalba Date: Sun, 8 May 2011 08:12:28 +0000 (+0100) Subject: Reintroduce operator>>() in Book class X-Git-Url: https://git.sesse.net/?p=stockfish;a=commitdiff_plain;h=d5f0b91c0622b843d8cc79774ce0b4caf9e8a0dd Reintroduce operator>>() in Book class No functional change. Signed-off-by: Marco Costalba --- diff --git a/src/book.cpp b/src/book.cpp index 26fd7c92..757c8238 100644 --- a/src/book.cpp +++ b/src/book.cpp @@ -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 -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()) { diff --git a/src/book.h b/src/book.h index 8299b031..0101bcf2 100644 --- a/src/book.h +++ b/src/book.h @@ -48,7 +48,7 @@ public: const std::string name() const { return bookName; } private: - template void get_number(T& n); + template Book& operator>>(T& n); BookEntry read_entry(int idx); int find_entry(uint64_t key);