Modify input stream data on the fly
- by Frizi
I would like to implement a std::stream modifier/parser, that is doing data manipulation on the fly.
Is it possible to create it in form of stream manipulator? For example, i want to strip all the line comments (from any // to the end of line) out of the stdin and pass it to stdout.
string str;
istream strippingCin = cin >> stripcomments;
while(strippingCin.good())
{
strippingCin >> str;
cout << str;
}
There may be also a large file input instead of cin, so i don't want to load full stream data into memory at once.
Is it possible without writing my own stream class?
Maybe is there another route i should take instead?