diff options
| author | Taylor C. Richberger <taywee@gmx.com> | 2016-05-06 15:37:31 -0400 | 
|---|---|---|
| committer | Taylor C. Richberger <taywee@gmx.com> | 2016-05-06 15:37:31 -0400 | 
| commit | bf7a88f84dee02c6219a0e9f1c5fbaee93690711 (patch) | |
| tree | 0a4b0f9dcdda60e399dbe7d7dd8ade008887575b | |
| parent | Merge branch '8-argumentparser-help-should-be-overloaded-and-should-also-have... (diff) | |
| parent | update parseargs to be properly overloaded (diff) | |
| download | args.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.hxx | 23 | 
1 files changed, 17 insertions, 6 deletions
| @@ -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() | 
