Virtualize a few functions in istream to allow them to be overridden in derived classes
This commit is contained in:
parent
6ddf1639c5
commit
5a91c4f118
3 changed files with 4 additions and 3 deletions
|
|
@ -38,7 +38,7 @@ namespace fc
|
||||||
* This method may block until at least 1 character is
|
* This method may block until at least 1 character is
|
||||||
* available.
|
* available.
|
||||||
*/
|
*/
|
||||||
char peek()const;
|
virtual char peek() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::unique_ptr<detail::buffered_istream_impl> my;
|
std::unique_ptr<detail::buffered_istream_impl> my;
|
||||||
|
|
|
||||||
|
|
@ -30,7 +30,7 @@ namespace fc {
|
||||||
**/
|
**/
|
||||||
istream& read( char* buf, size_t len );
|
istream& read( char* buf, size_t len );
|
||||||
istream& read( const std::shared_ptr<char>& buf, size_t len, size_t offset = 0 );
|
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;
|
typedef std::shared_ptr<istream> istream_ptr;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -74,7 +74,8 @@ namespace fc {
|
||||||
}
|
}
|
||||||
|
|
||||||
ifstream& ifstream::read( char* buf, size_t len ) {
|
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);
|
my->ifs.read(buf,len);
|
||||||
if (my->ifs.gcount() < int64_t(len))
|
if (my->ifs.gcount() < int64_t(len))
|
||||||
FC_THROW_EXCEPTION( eof_exception , "");
|
FC_THROW_EXCEPTION( eof_exception , "");
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue