问题
These days I am playing with Boost program options for reading INI files.
The code I have throws an exception once in the file there is a line with an unknown option. Do you know whether is possible and how to let the code below read the whole file? I want to skip the unknown options without throwing so that I can read all possible values. Thanks a lot AFG
namespace pod = boost::program_options;
pod::options_description options("Options");
std::string myArgValue;
options.add_options()
("SECT_A.Option_A",
pod::value<int>()->default_value(1),
"xxx")
("SECT_B.Option_B",
pod::value<std::string>(&myArgValue),
"xxx")
;
pod::variables_map vm;
pod::store( pod::parse_config_file( s, options ) , vm);
pod::notify( vm );
回答1:
Yip: allow_unregistered()
, have a look at:
http://www.boost.org/doc/libs/1_45_0/doc/html/program_options/howto.html#id2075177
来源:https://stackoverflow.com/questions/4459650/skipping-unknown-options-without-throwing-with-boost-program-options