Commit 770804ec authored by Christopher Subich's avatar Christopher Subich
Browse files

Add vector-valued options to the config file

This change modifeis Options.hpp to add the possibility of
vector-valued options to the config file and command line.
From the 'case' code, this option is used by (for example)

std::vector<int> intvec;
add_option("Name",&intvec,"Description);

When run, options of the form --Name 1 2 3 4 (at the command
line) or Name = 1 2 3 4 (in the config file) will be added
to the vector 'intvec' as separate entries.

Because add_option is a template function, this works
identically for double (floating point)-valued options.  It
has not been tested with string options.

Since an empty vector is a perfectly cromulent and
unambiguous possibility, vector-valued options do *not*
permit the specification of defaults.
parent 0f06c74a
......@@ -44,6 +44,13 @@ void add_option(
const char * name, string * location,
const char * def_value, const char * description);
// Overload for vector list (no default value)
template <class t> void add_option(
const char * name, std::vector<t> * location, const char * description) {
categories.back()->add_options()
(name,popt::value< std::vector<t> >(location)->multitoken(),description);
}
// Wrapper for adding a "switch" option that is either present (true) or
// not present (false).
void add_switch(const char * name, bool * location, const char * description);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment