Boost logo

Boost Users :

Subject: Re: [Boost-users] problems with program_opsitons::parse_environment can't figure out how to do what I want.
From: AFoglia_at_[hidden]
Date: 2009-10-01 22:55:23


-----<boost-users-bounces_at_[hidden]> wrote: -----

>To: boost-users_at_[hidden]
>From: Caleb Cushing <xenoterracide_at_[hidden]>
>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
><xenoterracide_at_[hidden]> 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_environment_id968658.html>,
 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_environment_id914437.html>

--
Anthony Foglia
Princeton Consultants
(609) 987-8787 x233

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