From 5a91c4f1185af82219f30946992bdffcfab1da2d Mon Sep 17 00:00:00 2001 From: Eric Frias Date: Mon, 22 Dec 2014 17:56:30 -0500 Subject: [PATCH] Virtualize a few functions in istream to allow them to be overridden in derived classes --- include/fc/io/buffered_iostream.hpp | 2 +- include/fc/io/iostream.hpp | 2 +- src/io/fstream.cpp | 3 ++- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/include/fc/io/buffered_iostream.hpp b/include/fc/io/buffered_iostream.hpp index f1803eb..470b1fd 100644 --- a/include/fc/io/buffered_iostream.hpp +++ b/include/fc/io/buffered_iostream.hpp @@ -38,7 +38,7 @@ namespace fc * This method may block until at least 1 character is * available. */ - char peek()const; + virtual char peek() const; private: std::unique_ptr my; diff --git a/include/fc/io/iostream.hpp b/include/fc/io/iostream.hpp index 582797f..7ec8149 100644 --- a/include/fc/io/iostream.hpp +++ b/include/fc/io/iostream.hpp @@ -30,7 +30,7 @@ namespace fc { **/ istream& read( char* buf, size_t len ); istream& read( const std::shared_ptr& buf, size_t len, size_t offset = 0 ); - char get(); + virtual char get(); }; typedef std::shared_ptr istream_ptr; diff --git a/src/io/fstream.cpp b/src/io/fstream.cpp index b76960c..71af81d 100644 --- a/src/io/fstream.cpp +++ b/src/io/fstream.cpp @@ -74,7 +74,8 @@ namespace fc { } ifstream& ifstream::read( char* buf, size_t len ) { - if( eof() ) FC_THROW_EXCEPTION( eof_exception , ""); + if (eof()) + FC_THROW_EXCEPTION( eof_exception , ""); my->ifs.read(buf,len); if (my->ifs.gcount() < int64_t(len)) FC_THROW_EXCEPTION( eof_exception , "");