procbuf
JW
cow-SPAM@compsoc-SPAM.man.ac.uk
Wed Dec 26 19:46:00 GMT 2001
On Tue, 18 Dec 2001, Eric Bourque wrote:
> > Dropped.
>
> I can see why, but it's too bad it's not part of the GNU extensions
> anymore. It does have its uses.
>
> > Look at file streams (fstream) or stringstreams (sstream)
>
> Neither really helps me in this case: I need to run a command and
> process its output as a stream. I guess I can derive from streambuf and
> use something like popen().
>
Since I've seen this question asked a few times, I sat down and wrote a
(sort of) replacement for the pfsteams in the old libstdc++, that would
work with libstdc++-v3 (and other standard-conforming compilers)
It's a work in progress, but seems to work for me, I'd be grateful for any
feedback. The ipstream and opstream classes will work on any ISO-C++
compliant compiler on systems that support the popen/pclose POSIX
functions.
http://www.redi.uklinux.net/pstreams/
I implemented a pstreambuf class (actually a class template) that uses
popen() to open a FILE* and then uses it when reading and writing.
I then made basic_opstream and basic_ipstream classes that derive from the
standard stream classes and use a pstreambuf as the streambuf (exactly as
you suggest.)
hope this is useful to you or anyone else...
jon
--
(remove -SPAM to reply)
More information about the Libstdc++
mailing list