|
Boost : |
Subject: Re: [boost] Formal Review of Proposed Boost.Process library
From: Jeff Flinn (TriumphSprint2000_at_[hidden])
Date: 2011-02-21 12:29:33
Artyom wrote:
>> Or maybe something like
>>
>> command_line_params ls_params;
>>
>> ls_params.add("--reverse");
>> ls_params.add("-l");
>>
>> command_line_params grep_params;
>> grep_params.add("^d");
>>
>> grep.stdin().connect(ls.stdout());
>>
>> ls.spawn(ls_params);
>> grep.spawn(grep_params);
>>
>> +- - something like that.
>>
>
> Or even better:
>
> pipe::connect(ls.stdout(),grep.stdin());
>
> ls.spawn("--reverse","-l","/usr/bin");
> grep.spawn("^d");
>
> ls.wait();
> grep.wait();
>
> I think this would be much more readable
> and what is important maintainable.
I've posted a similar approach in the original review thread with 'arg'
and 'args' classes with operator() usage inspired by boost spirit's
symbols class. The operator is templated and uses boost::lexical_cast to
convert to a std::[w]string as appropriate.
arg("-d")(some_path_type)("-count")(123)("--do_it=abc")
returns an args instance.
https://goo.gl/NvRAH has some initial documentation and describes an
approach that's similar to what you describe. A zip file is attached to
the posting http://goo.gl/8R6cR
I was thinking that Stjepan Rajko's previously reviewed Data Flow
library's interface was very applicable to the child process domain.
It's described at
http://dancinghacker.com/code/dataflow/dataflow/introduction/dataflow.html.
Jeff
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk