Boost logo

Boost Users :

Subject: Re: [Boost-users] boost.program_options - reloading configuration file
From: Aljaz (aljaz.fajmut_at_[hidden])
Date: 2008-10-16 08:13:52

I tried clearing m_variables map by doing m_variables.clear() (which is a
member of configuration class) - but after that some variables from the
configuration file wont be read.

If I constrct new variables map each time I want to reload configuration
file it works just fine.

Is there any other way around this problem?
I would like to be able to use one variables map so that I could use
functions read_command_line() and read_config_file() which are both members
of configuration class.

Many thanks!

"Aljaz" <aljaz.fajmut_at_[hidden]> wrote in message
> Hello
> I want to implement function in my application which would allow me to
> reload the configuration file.
> At the moment I have all neccessary program_options objects inside a
> configuration class, and when I do:
> bool configuration::reload_config_file(std::string filename) {
> try {
> std::ifstream ifs(filename.c_str());
> if (!ifs.is_open()) return false;
> boost::program_options::store(boost::program_options::parse_config_file(ifs,
> m_config), m_variables);
> boost::program_options::notify(m_variables);
> ifs.close();
> }
> catch (std::exception &e) {
> return false;
> }
> return true;
> }
> The options will stay the same although the configuration file is
> different.
> Should I somehow clear the m_variables object?
> Many thanks in advance!

Boost-users list run by williamkempf at, kalb at, bjorn.karlsson at, gregod at, wekempf at