diff options
author | Taylor C. Richberger <Taywee@gmx.com> | 2016-05-05 16:11:24 -0600 |
---|---|---|
committer | Taylor C. Richberger <Taywee@gmx.com> | 2016-05-05 16:11:24 -0600 |
commit | 8b87e2d4a63dc24dd744b62524bd3565a5a2f5de (patch) | |
tree | bb4c85bfc5d8a740bf8a78d92d317e0708c7da2c | |
parent | fix doxygenation version (diff) | |
download | args.hxx-8b87e2d4a63dc24dd744b62524bd3565a5a2f5de.tar.xz |
improve some of the logic1.1.1
-rw-r--r-- | README.md | 3 | ||||
-rw-r--r-- | args.hxx | 13 |
2 files changed, 8 insertions, 8 deletions
@@ -6,6 +6,9 @@ about 1.2K lines of code. This is designed to somewhat replicate the behavior of Python's argparse, but in C++, with static type checking, and hopefully a lot faster. +It's probably slower than some other C++ argument-parsing libraries (especially +with its heavy use of inheritence), but it should be more flexible than most. + UTF-8 support is limited at best. No normalization is performed, so non-ascii characters are very best kept out of flags, and combined glyphs are probably going to mess up help output if you use it. @@ -277,7 +277,10 @@ namespace args std::get<1>(description) = help; return description; } - + virtual std::string Name() const + { + return name; + } }; /** Base class for all flag arguments @@ -315,7 +318,6 @@ namespace args virtual std::tuple<std::string, std::string> GetDescription(const std::string &shortPrefix, const std::string &longPrefix) const override { std::tuple<std::string, std::string> description; - const std::string upperName(name); const std::vector<std::string> optStrings(matcher.GetOptionStrings(shortPrefix, longPrefix)); std::ostringstream flagstream; for (auto it = std::begin(optStrings); it != std::end(optStrings); ++it) @@ -344,7 +346,6 @@ namespace args virtual std::tuple<std::string, std::string> GetDescription(const std::string &shortPrefix, const std::string &longPrefix) const override { std::tuple<std::string, std::string> description; - const std::string upperName(name); const std::vector<std::string> optStrings(matcher.GetOptionStrings(shortPrefix, longPrefix)); std::ostringstream flagstream; for (auto it = std::begin(optStrings); it != std::end(optStrings); ++it) @@ -353,7 +354,7 @@ namespace args { flagstream << ", "; } - flagstream << *it << ' ' << upperName; + flagstream << *it << ' ' << name; } std::get<0>(description) = flagstream.str(); std::get<1>(description) = help; @@ -378,10 +379,6 @@ namespace args } virtual void ParseArg(const std::string &value) = 0; - virtual std::string Name() const - { - return name; - } }; /** Class for all kinds of validating groups, including ArgumentParser |