Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

skipping unknown options without throwing with boost program options

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 );
like image 578
Abruzzo Forte e Gentile Avatar asked May 03 '26 08:05

Abruzzo Forte e Gentile


1 Answers

Yip: allow_unregistered(), have a look at:

http://www.boost.org/doc/libs/1_45_0/doc/html/program_options/howto.html#id2075177

like image 135
Nim Avatar answered May 05 '26 22:05

Nim



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!