Boost logo

Boost Users :

From: Drumheller, Michael (michael.drumheller_at_[hidden])
Date: 2006-07-21 12:06:26


Regarding boost::program_options:

I would like to parse (and then store) some command-line options that
potentially contain unregistered flags, and I understand from
<<http://www.boost.org/doc/html/program_options/howto.html#id2716386>>
that the way to do this is:

  basic_command_line_parser<char> parser(argc, argv);
  basic_parsed_options<char>
parsed(parser.options(options).allow_unregistered().run());

Indeed this works--for parsing. But how do I store the resulting parsed
options (in a way that ignores the unregistered ones)? Simply calling

   store(parsed, vm);

throws a boost::program_options::unknown_option exception. I can take
the (brute force) step of erasing from parsed.options all elements for
which the unregistered attribute is true, and then calling store(parsed,
vm). That seems to work, but it so clumsy that it makes me think I'm
using the system in a way that was not intended.

Can anyone help?

Thank you.

MD

P.S. There is a bug in the doc: "collect_arguments(...)" on the last
line of the above link should be collect_unrecognized(...); similarly,
in the source code parsers.hpp (line 158) there is a mention of the
nonexistent function "collect_unregistered").

Michael Drumheller
Boeing Phantom Works
Mathematics and Engineering Analysis
425.865.3520 michael.drumheller_at_[hidden]
This email may contain proprietary information. If you are not the
intended recipient please delete it and notify the sender that you
received it in error.


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