0

On one hand I have a nice c++ function taking an istream& as parameter. On the other hand I have a old school home made stream of bytes (kind of open/read/close stuff).

And, of course, I want to plug the second into the first.

I tried to create a derived class from streambuf and pass it to the istream's constructor. But it seems that streambuf's methods are not virtual...

What is the right way to do it ? Thanks !

Captain'Flam
  • 479
  • 4
  • 12
  • 2
    Look again, `std::streambuf` has several virtual methods for you to override so you can read and write your byte data – Remy Lebeau Feb 23 '18 at 14:59
  • [`std::basic_streambuf`](http://en.cppreference.com/w/cpp/io/basic_streambuf), there are a lot of virtual methods in there, especially `underflow`, and `overflow`. Which non-virtual method would you like to override ? (btw: https://stackoverflow.com/questions/14086417/how-to-write-custom-input-stream-in-c ) – Caninonos Feb 23 '18 at 14:59
  • I thought that the most significant methods for me were `sbumpc`, `sgetn` and `snextc`. But those are not virtual (at least in my Visual Studio 2010 stl). – Captain'Flam Feb 23 '18 at 15:33
  • My mistake! I didn't see the protected methods which are those I need. – Captain'Flam Feb 23 '18 at 16:06

0 Answers0