summaryrefslogtreecommitdiff
path: root/src/parameters_parser.hh
diff options
context:
space:
mode:
authorMaxime Coste <frrrwww@gmail.com>2013-03-27 14:27:12 +0100
committerMaxime Coste <frrrwww@gmail.com>2013-03-27 14:27:12 +0100
commit29f79346c3297dc64045458ca2294cf68ad687da (patch)
tree0b22ffe692d0d288f4a944491b64e4af6da67d9c /src/parameters_parser.hh
parent3b059bafe523c7d777eb5f11d508d9fa30472fb3 (diff)
Move parameter count validation to the ParameterParser
Diffstat (limited to 'src/parameters_parser.hh')
-rw-r--r--src/parameters_parser.hh10
1 files changed, 9 insertions, 1 deletions
diff --git a/src/parameters_parser.hh b/src/parameters_parser.hh
index d91f436f..bedcfc93 100644
--- a/src/parameters_parser.hh
+++ b/src/parameters_parser.hh
@@ -24,6 +24,12 @@ struct missing_option_value: public runtime_error
: runtime_error("missing value for option '" + name + "'") {}
};
+struct wrong_argument_count : runtime_error
+{
+ wrong_argument_count() : runtime_error("wrong argument count") {}
+};
+
+
// ParameterParser provides tools to parse command parameters.
// There are 3 types of parameters:
// * unnamed options, which are accessed by position (ignoring named ones)
@@ -35,7 +41,9 @@ struct ParametersParser
// they are understood as string options, else they are understood as
// boolean option.
ParametersParser(const ParameterList& params,
- std::unordered_map<String, bool> options);
+ std::unordered_map<String, bool> options,
+ size_t min_positionals = 0,
+ size_t max_positionals = -1);
// check if a named option (either string or boolean) is specified
bool has_option(const String& name) const;