Boost logo

Boost :

From: Tony Han Bao (tonybao_at_[hidden])
Date: 2004-11-30 08:18:17


Hi all,

Can anyone tell me the precise definition or behaviour of the order of
execution of the user supplied functions to handle command line options
defined in boost program options library.

For example, my option menu was defined as follows

  boost::program_options::options_description menu("Valid Options");
     menu.add_options()
       ("help,h", "Display this menu.")
       ("time,t", boost::program_options::value<double>(&time_arg_value)
-> notifier(&my_function1) "Description of option")
       ("memory,m",
boost::program_options::value<double>(&memory_arg_value) ->
notifier(&my_function2), "Description of option")
       ("file,f", boost::program_options::value<std::vector<std::string>
>(&file_arg_value) -> composing() ->
notifier(&file_arg_handler<std::vector<std::string> >), "Something");

     boost::program_options::variables_map menu_map;
      
boost::program_options::store(boost::program_options::
parse_command_line(argc, argv, menu), menu_map);
     boost::program_options::notify(menu_map);

Question is: Will the following two calls to the program result in
different behaviour?

>./Test --time 76 --memory 97 --help
>./Test --memory 97 --time 76 --help

I want my two functions for time and memory be independent of each
other but I would like the function be called in the same order as the
options specified on the command line. Sure I can test but can someone
guarantee that what I discovered will remain valid in the future
release of the library.

Another question: What will happen if this program was called on the
command line with the following options.

>./Test --file myfile1 --time 87 --file myfile2

Will the file_arg_handler be called first with composed arguments and
then time function (my_function1) or will the time function
(my_function1) be called first and then the
file_arg_handler function. Can I count on it that what happens will
always happen in the future? Is there definitions for the order of
execution guarantee by the library?

Thanks in advance for your help!

Best Regards,

Tony Han Bao
tonybao_at_[hidden]


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk