سؤال

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 );
هل كانت مفيدة؟

المحلول

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top