[program_options][filesystem] custom validator for std::vector<filesystem::path>

Hi, I made a custom validator for filesystem::path and that works, but I can't seem to get the same to work for std::vector<filesystem::path>. I keep getting an exception about multiple_occurrences when I use it. Here is the code for the validator: void validate(boost::any& v, const std::vector<std::string>& values, std::vector<boost::filesystem::path>* target_type, int) { using namespace boost::program_options; // Make sure no previous assignment to 'v' was made. validators::check_first_occurrence(v); std::vector<boost::filesystem::path> result; for(size_t i=0;i<values.size();++i) { result.push_back(boost::filesystem::path(values[i])); } v = boost::any(result); } Thanks, Chris

"Chris Weed" <chrisweed@gmail.com> wrote in message news:359e4bf50601110848w64205e7bt812579c77be3e983@mail.gmail.com...
Hi,
I made a custom validator for filesystem::path and that works, but I can't seem to get the same to work for std::vector<filesystem::path>.
I keep getting an exception about multiple_occurrences when I use it.
What version of Boost? What compiler and compiler version? What is the exact error message you are getting? --Beman

HI, I am using boost 1.33.0 with g++ 3.4.2 on Sun. The error is: terminate called after throwing an instance of 'boost::program_options::multiple_occurrences' what(): multiple_occurrences Abort (core dumped) For the following code: namespace po = boost::program_options; namespace fs = boost::filesystem; po::options_description generic("Allowed options"); generic.add_options() ("help", "produce help message") ; po::options_description hidden("Hidden options"); hidden.add_options() ("input-file", po::value< std::vector<fs::path> >(), "input file") ; po::options_description cmdline_options; cmdline_options.add(generic).add(hidden); po::positional_options_description p; p.add("input-file", -1); po::variables_map vm; po::store(po::command_line_parser(argc, argv). options(cmdline_options).positional(p).run(), vm); po::notify(vm); if (vm.count("help")) { std::cout << generic << " input1 [input2 ...]\n" << std::endl; return 1; } std::vector<fs::path> inputFilenames; if(vm.count("input-file")) { inputFilenames = vm["input-file"].as<std::vector<fs::path> >(); } Thanks, Chris On 1/12/06, Beman Dawes <bdawes@acm.org> wrote:
"Chris Weed" <chrisweed@gmail.com> wrote in message news:359e4bf50601110848w64205e7bt812579c77be3e983@mail.gmail.com...
Hi,
I made a custom validator for filesystem::path and that works, but I can't seem to get the same to work for std::vector<filesystem::path>.
I keep getting an exception about multiple_occurrences when I use it.
What version of Boost?
What compiler and compiler version?
What is the exact error message you are getting?
--Beman
_______________________________________________ Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost

"Chris Weed" <chrisweed@gmail.com> wrote in message news:359e4bf50601120722i7e28631we3528c7d9d239ffb@mail.gmail.com...
HI, I am using boost 1.33.0 with g++ 3.4.2 on Sun.
Chris, could you see if the problem is present with Boost.Filesystem from the CVS HEAD? The CVS head represents a major Boost.Filesystem upgrade, and I'm putting all my current effort into cleaning it up for the 1.34 release. Thanks, --Beman

The changes work. Thanks, Chris On 1/15/06, Beman Dawes <bdawes@acm.org> wrote:
"Chris Weed" <chrisweed@gmail.com> wrote in message news:359e4bf50601120722i7e28631we3528c7d9d239ffb@mail.gmail.com...
HI, I am using boost 1.33.0 with g++ 3.4.2 on Sun.
Chris, could you see if the problem is present with Boost.Filesystem from the CVS HEAD?
The CVS head represents a major Boost.Filesystem upgrade, and I'm putting all my current effort into cleaning it up for the 1.34 release.
Thanks,
--Beman
_______________________________________________ Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost
participants (2)
-
Beman Dawes
-
Chris Weed