C
Christopher Benson-Manica
Yes, it's me again, with my dear, dear friends std::streambuf and
std:stream... On the bright side, the code compiles. On the gloomy
side, I can't seem to get overflow() or xsputn() called...
class TWFileBuf : public std::streambuf
{
private:
bool Open( name ) {/* debug printf - does show up */}
protected:
TLSFile lsf;
virtual int_type overflow(int_type c)
{
// debug printf omitted - it does NOT show up
if( lsf.Write(c) ) {
return c;
}
return EOF;
}
virtual std::streamsize xsputn(const char *s, std::streamsize num)
{
// debug printf omitted - it does NOT show up
lsf.Write(s);
return(strlen(s));
}
public:
TWFileBuf( const char* name ) {Open(name);}
};
class
TLogBuf : public TWFileBuf
{
protected:
virtual std::streamsize xsputn(const char *s, std::streamsize num)
{ /* do complicated stuff - printf here doesn't show up */ }
public:
TLogBuf( name ) : TWFileBuf(name) {}
};
template <class buftype>
class TWFileStreamBase : public std:stream
{
protected:
buftype buf;
public:
TWFileStreamBase( const char* name ) :
buf(name),std:stream(&buf) {}
};
typedef TWFileStream<TLogBuf> TDebugLogFile;
Any ideas on what's still wrong with this code.................?
std:stream... On the bright side, the code compiles. On the gloomy
side, I can't seem to get overflow() or xsputn() called...
class TWFileBuf : public std::streambuf
{
private:
bool Open( name ) {/* debug printf - does show up */}
protected:
TLSFile lsf;
virtual int_type overflow(int_type c)
{
// debug printf omitted - it does NOT show up
if( lsf.Write(c) ) {
return c;
}
return EOF;
}
virtual std::streamsize xsputn(const char *s, std::streamsize num)
{
// debug printf omitted - it does NOT show up
lsf.Write(s);
return(strlen(s));
}
public:
TWFileBuf( const char* name ) {Open(name);}
};
class
TLogBuf : public TWFileBuf
{
protected:
virtual std::streamsize xsputn(const char *s, std::streamsize num)
{ /* do complicated stuff - printf here doesn't show up */ }
public:
TLogBuf( name ) : TWFileBuf(name) {}
};
template <class buftype>
class TWFileStreamBase : public std:stream
{
protected:
buftype buf;
public:
TWFileStreamBase( const char* name ) :
buf(name),std:stream(&buf) {}
};
typedef TWFileStream<TLogBuf> TDebugLogFile;
Any ideas on what's still wrong with this code.................?