On Wed, 5 Apr 2006, Andrew Schweitzer wrote:
Stephan Stiglmayr wrote:
I'm looking for a way to "iterate" through a variable_map after the command line options were stored, in order to print out all the options, or all with newly values.
[...]
I know that you can test if a specific options was read with the "count()" method, but this is cumbersome. [...] Is there a possiblity to do that?
I wrote a wrapper class that adds options to a list as they are added to program_options, then you can print the list. This is a hack.
Also, another 'hack' is that, looking in the code, you can notice that variables_map inherits from std::map as well (though it's not documented as such). You can thus use standard STL iterators, e.g. for ( variables_map::iterator i = vm.begin() ; i != vm.end() ; ++ i ) { //... } The type of values iterated over are pairs of std::string and boost::program_options::variable_value. -- François Duranleau LIGUM, Université de Montréal "You only think you understand. But people cannot perfectly understand each other. The self is an ambiguous thing." - Kaji, in _Neon Genesis Evangelion_