Re: Basic question on streams
On Jul 23, 12:18 pm, gerry2...@gmail.com wrote:
On 7 23 , 4 52 , James Kanze <james.ka...@gmail.com> wrote:
class OutPut : public streambuf, public ostream
{
private:
ofstream m_ofs;
ofstream m_ofs_error;
ofstream m_ofs_warnning;
public:
// define some other operations
}
And that should do what?
If you want to be able to configure the class so that e.g.
m_ofs_error goes to standard out, the simplest way is to make it
a pointer to an ostream. (Typically, of course, logging/tracing
is a lot more complicated than that, and the "streams" being
written to will be using filtering streambuf's, which insert
timestamps, handle "records", etc., and are addressed through
wrapper classes which handle things like synchronization,
flushing, etc. And of course, in some cases, you might
configure one of the filtering streambuf's to forward to the
streambuf of cout or cerr.)
--
James Kanze (GABI Software) email:james.kanze@gmail.com
Conseils en informatique orient=E9e objet/
Beratung in objektorientierter Datenverarbeitung
9 place S=E9mard, 78210 St.-Cyr-l'=C9cole, France, +33 (0)1 30 23 00 34