|
Boost : |
From: Neal D. Becker (nbecker_at_[hidden])
Date: 2003-08-08 10:01:54
I'm lost with trying to use the (unreleased) program_options lib.
I have no problem to use with just command line, but I'd like to have both
command line and config file.
Here's what I tried:
try {
options_description desc("Allowed options");
desc.add_options()
("help", "", "produce help message")
("esNodB,e", parameter<double> ("value", &esnodB), "Es/No(dB)")
("maxBursts,m", parameter<int> ("value", &maxBursts), "stop after
#bursts")
("maxErrors,M", parameter<int> ("value", &maxErrors), "stop after
#errors")
;
options_and_arguments opts = parse_command_line(argc, argv, desc);
variables_map vm;
store(opts, vm, desc);
ifstream ifs("TestUWP.cfg");
options_and_arguments opts2 = parse_config_file(ifs, desc);
variables_map cfg_file_vm;
store(opts2, cfg_file_vm, desc);
vm.next(&cfg_file_vm);
if (vm.count("help")) {
std::clog << desc << "\n";
return 1;
}
}
catch(std::exception& e) {
std::cerr << "error: " << e.what() << "\n";
return 1;
}
I get this message:
error: config file options should have required parameter
I tried various variations, and also referred to the multiple_sources example,
but I still can't find out what's wrong. Any clues?
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk