C++ – boost program options parse_config_file

boostboost-program-optionscqt

I want to save the settings (in a file) of my application in boost program_options way

This is my function

void MainWindow::saveSettings()
{
    po::options_description desc("Allowed options");
    desc.add_options()
        ("ip",deImPath->text().toStdString().c_str())
        ("cp",deCalPath->text().toStdString().c_str())
        ("sp",deSolPath->text().toStdString().c_str());
    po::variables_map vm;
    po::store(po::parse_config_file("settings.conf",desc),vm);
    po::notify(vm);
}

Unfortunately I get this error:

error C2784: 'boost::program_options::basic_parsed_options<charT>
 boost::program_options::parse_config_file(std::basic_istream<charT> &,
                                           const boost::program_options::options_description &,bool)' :
 could not deduce template argument for 'std::basic_istream<charT> &' from 'const char [14]'

How can I solve this problem?

Best Answer

boost::program_options purpose is to pass parameters to your program.

If you want to store a configuration that the program can write too, you can use Boost.PropertyTree or Qt's QSettings class.

Related Topic