[Boost-bugs] [Boost C++ Libraries] #7067: The same options in the different groups cause exception while parsing configuration file.

Subject: [Boost-bugs] [Boost C++ Libraries] #7067: The same options in the different groups cause exception while parsing configuration file.
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2012-07-03 12:30:56


#7067: The same options in the different groups cause exception while parsing
configuration file.
---------------------------------------------------------+------------------
 Reporter: Grzegorz Andrejczuk <g.andrejczuk@…> | Owner: vladimir_prus
     Type: Bugs | Status: new
Milestone: To Be Determined | Component: program_options
  Version: Boost 1.49.0 | Severity: Problem
 Keywords: |
---------------------------------------------------------+------------------
 Preconditions:
 There are two option descriptions defined, containing the same options.
 The options are stored in the configuration file and grouped by the group.

 Result:
 options_descriptions add method adds two groups
 parse method throws unknown option exception with cat1.op1


 namespace po::boost::program_options;
 void test()
 {
 po::options_description cat1("cat1");
 cat1.add_options()
     ("op1", po::value<std::string>(), "op1")
     ("op2", po::value<std::string>(), "op2")
     ("op3", po::value<std::string>(), "op3")
     ("op4", po::value<std::string>(), "op4");
 po::options_description cat2("cat2");
 cat2.add_options()
     ("op1", po::value<std::string>(), "op1")
     ("op2", po::value<std::string>(), "op2")
     ("op3", po::value<std::string>(), "op3")
     ("op4", po::value<std::string>(), "op4");
 po::options_description full("full");
 full.add(cat1).add(cat2);

 po::variables_map map;

 boost::filesystem::path path("option.ini");

 try
 {
     po::store(po::parse_config_file<char>("option.ini", full), map);
 //exception is thrown "Unknown option cat1.op1"
     po::notify(map);
 }
 catch(std::exception & ex)
 {
     std::cout << ex.what() << std::endl;
 }

 option.ini:

 [cat1]
    op1=v1
    op2=v2
    op3=v3
    op4=v4
 [cat2]
    op1=v5
    op2=v6
    op3=v7
    op4=v8

-- 
Ticket URL: <https://svn.boost.org/trac/boost/ticket/7067>
Boost C++ Libraries <http://www.boost.org/>
Boost provides free peer-reviewed portable C++ source libraries.

This archive was generated by hypermail 2.1.7 : 2017-02-16 18:50:09 UTC