|
Boost Users : |
Subject: [Boost-users] boost::program_options - undocumented "*" feature
From: ST (smntov_at_[hidden])
Date: 2013-01-21 08:45:44
I recently discovered an undocumented feature of
`boost::program_options`, namely that it accepts "*" as a special
wildcard that allows declaration of a group of options with the same
prefix, like this:
configOptions.add_options()
("item_*", value<int>(), "items");
This declaration worked as expected and recognized `item_1`, `item_3`,
etc, while rejecting unknown options.
Well now the question is, how can I write a custom validate function
that will populate a map with options key and its value, like this:
map<string, int> itemsMap;
options_description items("items options");
items.add_options()
("item_*",value<map<string, int>>(&itemsMap)->multitoken(),
"items")
;
My question is - how do I get the key of the option being validated from
within validate() function?
template <typename T> void validate(boost::any& v, const
std::vector<std::string>& values, map<string, T> *, int)
Thank you,
Simone
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