|
Boost Users : |
Subject: Re: [Boost-users] commandline args
From: OvermindDL1 (overminddl1_at_[hidden])
Date: 2009-08-23 21:34:10
On Sun, Aug 23, 2009 at 7:08 PM, Shaolin<shaolinfinest_at_[hidden]> wrote:
> Ok, I have managed to get it to work, however, the file param only accepts
> one value. How can I get several different values for one param ? e.g.
> --file file1.txt file2.txt file3.txt
>
> if (vm.count("file")) {
> cout << "Files selected: ";
> vector<string> files = vm["file"].as< vector<string> >();
> for(int i=0; i<files.size(); ++i) {
> cout << files[i];
> }
> cout << "\n";
> }
>
> 2009/8/24 OvermindDL1 <overminddl1_at_[hidden]>
>>
>> On Sun, Aug 23, 2009 at 6:36 PM, OvermindDL1<overminddl1_at_[hidden]> wrote:
>> > LLVM.
>> Er, ignore that, was typing up 3 emails at the same time and got my
>> wires crossed, I mean Boost.Program_Options. :)
As-is I bet it accepts it like: --file file1.txt --file file2.txt
--file file3.txt
If you want to to accept arguments like: file1.txt file2.txt
file3.txt, assuming you have no other repeatable types, then you need
to specify a positional arguments function for file, like:
positional_options_description pd; pd.add("file", -1);
The Boost.Program_Options documentation details all of this.
Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net