Virtualize a few functions in istream to allow them to be overridden in derived classes

This commit is contained in:
Eric Frias 2014-12-22 17:56:30 -05:00
parent 6ddf1639c5
commit 5a91c4f118
3 changed files with 4 additions and 3 deletions

View file

@ -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<detail::buffered_istream_impl> my;

View file

@ -30,7 +30,7 @@ namespace fc {
**/
istream& read( char* buf, size_t len );
istream& read( const std::shared_ptr<char>& buf, size_t len, size_t offset = 0 );
char get();
virtual char get();
};
typedef std::shared_ptr<istream> istream_ptr;

View file

@ -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 , "");