$include_dir="/home/hyper-archives/boost-users/include"; include("$include_dir/msg-header.inc") ?>
Subject: [Boost-users]  Using program_options from a string?
From: boostnewbie (saabophile2_at_[hidden])
Date: 2009-03-08 21:36:06
Hello all.  I am using the boost::program_options library for configuration
files with great success.  I'm wondering if it's possible to use the library
using a string as a source, instead of a config file.
 
I read the configuration file with code like this:
        if (vm.count("config")) {
            string f = vm["config"].as<string>() ;
            ifstream ifs(f.c_str());
            store(parse_config_file(ifs, config_file_options), vm);
            po::notify(vm);
        }
but what I'd also like to do is something along these lines, with a string
as the original source instead of a file specified with my 'config' command
line option:
        string str = "port = 3000 \n tmpdir = /tmp \n";  // something like
this. this is what's in the config file.
        istringstream iss(str, istringstream::in);
        store(parse_config_file(iss, config_file_options), vm);
        po::notify(vm);
These lines compile and execute without error but don't actually appear to
update the 'vm'.  Am I doing something wrong or is this not possible with
the current incarnation of program_options?
Thanks!
-- View this message in context: http://www.nabble.com/Using-program_options-from-a-string--tp22405416p22405416.html Sent from the Boost - Users mailing list archive at Nabble.com.