Hi,
I habe a problem with store(parse_config_file(...), ...);
I don't know why...
That isn't my first program with program_options but
it is my first program with parse_command_line and parse_config_file in one.
Here is my code.
First I parse the command line, second I parse the config file.
Is it a very simple script.
With my debuger (gdb and ddd) I can see, that the problem
is here: bpo::store(bpo::parse_config_file(conf_file, desc_file), vm); (at the "end" from script).
vm is global definiert. The Namspace bpo ist boost::program_options
I use the gcc 3.3.5 and I compile static with: /usr/local/lib/libboost_program_options-gcc-1_33_1.a
My OS is OpenBSD
What I make false? My script is at the end.
Sorry for my bad english.
I thanks for Help,
Dear, Pascal Vizeli
[cpp]
bpo::variables_map vm_cmd;
bpo::options_description desc_file("config file"),
desc_cmd("command line");
// Make options descriptions
desc_cmd.add_options()
("config,c", bpo::valuestd::string(), "The Config file")
("help,h", "produce help message")
;
desc_file.add_options()
("port", bpo::value<int>()->default_value(6667), "IRC Server Port")
("server", bpo::value(), "IRC Server IP")
("nick", bpo::valuestd::string(), "Bot Nick")
("user", bpo::valuestd::string(),
"username hostname servername :realname")
("nickserv", bpo::valuestd::string(), "Nickserv Identify string")
("oper-pw", bpo::valuestd::string(), "Oper Password")
("mode", bpo::valuestd::string(), "Mode for Bot")
("logchan", bpo::valuestd::string(), "A #Chan for logs")
("logchan_status", bpo::value<int>(), "Logchan On or Off")
("invite-chan", bpo::value<int>(), "Invite for logchan?")
("invite-command", bpo::valuestd::string(), "Invite Command")
("re-chan", bpo::value<int>(), "Refresh Channellist until SEC")
("logfile", bpo::valuestd::string(), "File for logs")
("chroot", bpo::value(), "Set the chroot dir (path)")
;
// Parse CMD
bpo::store(bpo::parse_command_line(argc, argv, desc_cmd), vm_cmd);
bpo::notify(vm_cmd);
if(vm_cmd.count("help")){
std::cout << desc_cmd << std::endl;
std::cout << desc_file << std::endl;
exit(0);
}
if(!vm_cmd.count("config")){
printo_err("Config file not found! Use --help for Infos");
exit(0);
}
// Open Config file
std::ifstream conf_file(vm_cmd["config"].asstd::string().c_str());
if(conf_file.is_open()){
// Parse Config file
bpo::store(bpo::parse_config_file(conf_file, desc_file), vm); //
Here is the false say my debuger
bpo::notify(vm);
}else{
printo_err("can't open the conf file!");
exit(0);
}
[/cpp]