Boost logo

Boost Users :

From: Pascal Vizeli (pascal_at_[hidden])
Date: 2006-04-29 07:30:04


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::value<std::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<char *>(), "IRC Server IP")
     ("nick", bpo::value<std::string>(), "Bot Nick")
     ("user", bpo::value<std::string>(),
      "username hostname servername :realname")
     ("nickserv", bpo::value<std::string>(), "Nickserv Identify string")
     ("oper-pw", bpo::value<std::string>(), "Oper Password")
     ("mode", bpo::value<std::string>(), "Mode for Bot")
     ("logchan", bpo::value<std::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::value<std::string>(), "Invite Command")
     ("re-chan", bpo::value<int>(), "Refresh Channellist until SEC")
     ("logfile", bpo::value<std::string>(), "File for logs")
     ("chroot", bpo::value<char *>(), "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"].as<std::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]


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net