Boost logo

Boost :

From: Rob Stewart (stewart_at_[hidden])
Date: 2005-01-07 12:21:17


From: christopher diggins <cdiggins_at_[hidden]>
>
> I've just written in a working prototype of a library for writing C++
> programs which can be treated in C++ code like Unix filters, i.e. redirected
> to and from streams, and other programs.
>
> For instance:
>
> fstream f("c:\\tmp.txt");
> stringstream s;
> HelloWorldProgram() > f > UpperCaseProgram() > s;
>
> Is there any interest in this kind of library, for boost? I am using it for
> writing test and demonstration programs of libraries, but I think it has a
> lot of other uses.

>From what I can see, you use the term "program" to mean an
instance of class Program or, more specifically, a derivate
thereof. That isn't what I think of when I see the word
"program."

You cite an example in your article of piping the output of one
*nix command to another using the output redirection operator,
">". The correct operator is the pipe, "|". You seem to have
codified that misunderstanding, since you've overloaded ">" and
not "|" for Program.

Finally, your Program class is too intrusive since one must
derive from it. It would be better if there was a make_filter()
function template called with a function (object) returning a
streamable object. Then, make_filter() can return an object
which can invoke the function(object) as necessary and can be
chained with other instances to create a pipeline. (Speaking of
"pipeline," that is the *nix term for a series of filters piped
together. Hence, your PipeChain class would be better named
"Pipeline," and its "ChainTo" member function would be better
named "PipeTo.")

Oh, I should also point you to Jonathan Turkanis' IOStreams
Library (recently accepted, but not yet added to Boost). See
http://home.comcast.net/~jturkanis/iostreams/ for code and
documentation. Look especially at the filters functionality.

-- 
Rob Stewart                           stewart_at_[hidden]
Software Engineer                     http://www.sig.com
Susquehanna International Group, LLP  using std::disclaimer;

Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk