Topic: Custom stream manipulators ?
Author: jimrush@indirect.com (Jim Rush)
Date: 23 Jul 1994 17:32:01 GMT Raw View
I am writing a collection of objects for sending data to a dumb
terminal. I already have the two key classes :
streambuf -> tstreambuf
ostream -> tstream
I need to change the existing manipulators (I am also adding some custom
ones, but that is not a problem), but since the existing ostream
operators return ostream (of course) my manipulators will not be called.
qvtstream& endl(qvtstream& stream)
{
stream.put((char)13);
stream.gotox(0);
stream.flush();
return stream;
}
Tout << "My data" << endl;
The standard endl will be called.
I suspect I am going to have to choose custom names, but this isn't OOP.
The real problem seems to be with the design of the manipulators. They
should have been written as :
ostream& endl(ostream& os)
{
os.endl();
}
This would provide for a method that could be over ridden.
Any suggestions ?
Jim Rush
jimrush@indirect.com