Boost logo

Boost Users :

Subject: Re: [Boost-users] boost::program options - why no allow_unregistered() for environmental variable parser?
From: Vladimir Prus (vladimir_at_[hidden])
Date: 2008-10-15 03:56:04


Ivan Godard wrote:

> The environment seems to be the one place that is guaranteed to have
> unregistered options, because it is full of things (like
> $LD_LIBRARY_PATH) of no interest to the program doing the parsing. A
> call on parse_environment always throws on these. As far as I can see in
> the code, the way to avoid the throw is to pass parse_enviroment a
> function that checks for each of the options that are actually wanted
> and returns the null string for the rest. Of course, this duplicates
> what the parser just did.
>
> Is there a better way?

The recommended way is to use some name prefix for environment variables
affecting your program -- say MY_PROG_. Then, pass this prefix to
parse_environement and all variables without that prefix will be ignored.

Does this help?

- Volodya


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