
-----
To: boost-users@lists.boost.org From: Caleb Cushing
Date: 09/30/2009 09:07PM Subject: Re: [Boost-users] problems with program_opsitons::parse_environment can't figure out how to do what I want. On Wed, Sep 30, 2009 at 9:04 PM, Caleb Cushing
wrote: variables_map vm_env; store(parse_environment(desc, "HOME"), vm_env); notify(vm_env);
if(vm_env.count("HOME")) { path rcfile = ".koramarc"; path home; home = vm_env["HOME"].as<path>(); path tmp = home / rcfile; cout << "check" << endl; // just a retarted test to see if we're actually reaching the end of this... }
whoops... my code never enters the if statement and I'm not sure why.
I've never used parse_environment, but looking at the docs http://www.boost.org/doc/libs/1_40_0/doc/html/boost/program_options/parse_en..., this sounds like the problem: "Takes all environment variables which start with 'prefix'. The option name is obtained from variable name by removing the prefix and converting the remaining string into lower case." So, the HOME environmental is getting stored in the variable map under an empty key, if at all. I'm not sure how to fix it though. Maybe something like using "HOM" as the string for parse environment and "e" for the option name. Or you can use the other form of parse_environment that takes a function that maps variable names to option names. http://www.boost.org/doc/libs/1_40_0/doc/html/boost/program_options/parse_en... -- Anthony Foglia Princeton Consultants (609) 987-8787 x233