aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTaylor C. Richberger <Taywee@gmx.com>2016-05-06 13:36:53 -0600
committerTaylor C. Richberger <Taywee@gmx.com>2016-05-06 13:36:53 -0600
commit8fde146b047a99c52f0e0269b58ce8ffae6b415b (patch)
tree0a4b0f9dcdda60e399dbe7d7dd8ade008887575b
parentMerge branch '8-argumentparser-help-should-be-overloaded-and-should-also-have... (diff)
downloadargs.hxx-8fde146b047a99c52f0e0269b58ce8ffae6b415b.tar.xz
update parseargs to be properly overloaded
-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()