whee, it works now

This commit is contained in:
Cary Sandvig 2000-12-13 20:07:37 +00:00
parent d7e0fb7bd6
commit 8acc30a68c
3 changed files with 23 additions and 17 deletions

View File

@ -3,26 +3,28 @@
// //
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////
INLINE ipfstream::ipfstream(const string cmd) : _psb(PipeStreamBuf::Input) { INLINE IPipeStream::IPipeStream(const std::string cmd)
: istream(&_psb), _psb(PipeStreamBuf::Input) {
_psb.command(cmd); _psb.command(cmd);
} }
INLINE void ipfstream::flush(void) { INLINE void IPipeStream::flush(void) {
_psb.flush(); _psb.flush();
} }
INLINE ipfstream::ipfstream(void) : _psb(PipeStreamBuf::Input) { INLINE IPipeStream::IPipeStream(void) : _psb(PipeStreamBuf::Input) {
cerr << "should never call default constructor of ipfstream" << endl; cerr << "should never call default constructor of IPipeStream" << endl;
} }
INLINE opfstream::opfstream(const string cmd) : _psb(PipeStreamBuf::Output) { INLINE OPipeStream::OPipeStream(const std::string cmd)
: ostream(&_psb), _psb(PipeStreamBuf::Output) {
_psb.command(cmd); _psb.command(cmd);
} }
INLINE void opfstream::flush(void) { INLINE void OPipeStream::flush(void) {
_psb.flush(); _psb.flush();
} }
INLINE opfstream::opfstream(void) : _psb(PipeStreamBuf::Output) { INLINE OPipeStream::OPipeStream(void) : _psb(PipeStreamBuf::Output) {
cerr << "should never call default constructor of opfstream" << endl; cerr << "should never call default constructor of OPipeStream" << endl;
} }

View File

@ -8,28 +8,30 @@
#include "pfstreamBuf.h" #include "pfstreamBuf.h"
class EXPCL_DTOOL ipfstream : public istream { class EXPCL_DTOOL IPipeStream : public istream {
PUBLISHED: PUBLISHED:
INLINE ipfstream(const string); INLINE IPipeStream(const std::string);
INLINE void flush(void); INLINE void flush(void);
private: private:
PipeStreamBuf _psb; PipeStreamBuf _psb;
INLINE ipfstream(void); INLINE IPipeStream(void);
}; };
class EXPCL_DTOOL opfstream : public ostream { class EXPCL_DTOOL OPipeStream : public ostream {
PUBLISHED: PUBLISHED:
INLINE opfstream(const string); INLINE OPipeStream(const std::string);
INLINE void flush(void); INLINE void flush(void);
private: private:
PipeStreamBuf _psb; PipeStreamBuf _psb;
INLINE opfstream(void); INLINE OPipeStream(void);
}; };
#include "pfstream.I"
#endif /* __PFSTREAM_H__ */ #endif /* __PFSTREAM_H__ */

View File

@ -20,7 +20,7 @@ PipeStreamBuf::PipeStreamBuf(PipeStreamBuf::Direction dir) : _dir(dir),
allocate(); allocate();
assert((dir == Input) || (dir == Output)); assert((dir == Input) || (dir == Output));
if (dir == Input) { if (dir == Input) {
cerr << "allocated reserve is " << blen() << " bytes long" << endl; // cerr << "allocated reserve is " << blen() << " bytes long" << endl;
setg(base(), ebuf(), ebuf()); setg(base(), ebuf(), ebuf());
} else { } else {
setp(base(), ebuf()); setp(base(), ebuf());
@ -74,8 +74,10 @@ int PipeStreamBuf::sync(void) {
pbump(-n); pbump(-n);
} else { } else {
streamsize n = egptr() - gptr(); streamsize n = egptr() - gptr();
gbump(n); // flush all our stored input away if (n != 0) {
cerr << "pfstream tossed out " << n << " bytes" << endl; gbump(n); // flush all our stored input away
cerr << "pfstream tossed out " << n << " bytes" << endl;
}
} }
return 0; return 0;
} }