aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTaylor C. Richberger <taywee@gmx.com>2016-05-06 15:37:31 -0400
committerTaylor C. Richberger <taywee@gmx.com>2016-05-06 15:37:31 -0400
commitbf7a88f84dee02c6219a0e9f1c5fbaee93690711 (patch)
tree0a4b0f9dcdda60e399dbe7d7dd8ade008887575b
parentMerge branch '8-argumentparser-help-should-be-overloaded-and-should-also-have... (diff)
parentupdate parseargs to be properly overloaded (diff)
downloadargs.hxx-bf7a88f84dee02c6219a0e9f1c5fbaee93690711.tar.xz
Merge branch '7-parseargs-should-be-overloaded' into 'master'
update parseargs to be properly overloaded Closes #7 See merge request !6
-rw-r--r--args.hxx23
1 files changed, 17 insertions, 6 deletions
diff --git a/args.hxx b/args.hxx
index d5165f6..da5f267 100644
--- a/args.hxx
+++ b/args.hxx
@@ -868,17 +868,18 @@ namespace args
/** Parse all arguments.
*
- * \param args an iterable of the arguments
+ * \param begin an iterator to the beginning of the argument list
+ * \param end an iterator to the past-the-end element of the argument list
*/
- template <typename T>
- void ParseArgs(const T &args)
+ template <typename It>
+ void ParseArgs(It begin, It end)
{
// Reset all Matched statuses to false, for validation. Don't reset values.
ResetMatched();
bool terminated = false;
// Check all arg chunks
- for (auto it = std::begin(args); it != std::end(args); ++it)
+ for (auto it = begin; it != end; ++it)
{
const std::string &chunk = *it;
@@ -907,7 +908,7 @@ namespace args
} else
{
++it;
- if (it == std::end(args))
+ if (it == end)
{
std::ostringstream problem;
problem << "Argument " << arg << " requires an argument but received none";
@@ -950,7 +951,7 @@ namespace args
} else
{
++it;
- if (it == std::end(args))
+ if (it == end)
{
std::ostringstream problem;
problem << "Flag '" << arg << "' requires an argument but received none";
@@ -992,6 +993,16 @@ namespace args
}
}
+ /** Parse all arguments.
+ *
+ * \param args an iterable of the arguments
+ */
+ template <typename T>
+ void ParseArgs(const T &args)
+ {
+ ParseArgs(std::begin(args), std::end(args));
+ }
+
/** Convenience function to parse the CLI from argc and argv
*
* Just assigns the program name and vectorizes arguments for passing into ParseArgs()