Boost Users :
From: Marty Fried (public.forums_at_[hidden])
Date: 2008-06-26 13:51:03
I've got program_options working for a program that has a configuration
file. Aside for some program options, the file contains one or more aliases
that the user defines for a server/port value, and we don't know what the
alias might be until they run the program; then we search for the alias and
use its value.
I seems like the collect_unrecognized function would be convenient for us,
but I can't seem to make it work. I passed it the parsed_options.options
member, and I can see the values in there, with the string_key set
correctly, and the value set correctly, and the unregistered flag set to
true. But the string array result is empty. My code looks something like
parsed_options parsed = parse_config_file(ifs, options_desc, true);
vector<string> unregistered = collect_unrecognized(parsed.options,
What would really be convenient would be a flag to allow the unrecognized
entries to be added to the map, so then, when the user enters the alias, I
could just retrieve that entry from the map.
Should this work for a config file? If so, what might I be doing wrong?
And if not, any suggestions for how I might get it to work, aside from just
parsing the file again?
Thanks for your help,
-- Marty Fried Senior software engineer Aldon http://www.aldon.com