From 101c926dacf4dd79894909f6557dcd09f629b6b3 Mon Sep 17 00:00:00 2001 From: Henry Fredrick Schreiner Date: Wed, 31 May 2017 07:38:22 -0400 Subject: [PATCH] Adding tidy cleanups (modernize) --- include/CLI/App.hpp | 9 +++++---- include/CLI/Ini.hpp | 6 +++--- include/CLI/Option.hpp | 9 +++++---- include/CLI/Split.hpp | 2 +- include/CLI/StringTools.hpp | 2 +- include/CLI/Timer.hpp | 9 +++++---- tests/AppTest.cpp | 2 +- tests/CreationTest.cpp | 2 +- tests/HelpTest.cpp | 2 +- tests/HelpersTest.cpp | 14 +++++++------- tests/IniTest.cpp | 8 ++++---- tests/NewParseTest.cpp | 2 +- tests/SimpleTest.cpp | 2 +- 13 files changed, 36 insertions(+), 33 deletions(-) diff --git a/include/CLI/App.hpp b/include/CLI/App.hpp index 720b9ff7..8cf30a6e 100644 --- a/include/CLI/App.hpp +++ b/include/CLI/App.hpp @@ -12,6 +12,7 @@ #include #include #include +#include #include @@ -33,7 +34,7 @@ struct AppFriend; class App; -typedef std::unique_ptr App_p; +using App_p = std::unique_ptr; /// Creates a command line program, with very few defaults. /** To use, create a new `Program()` instance with `argc`, `argv`, and a help description. The templated @@ -122,7 +123,7 @@ protected: /// Special private constructor for subcommand App(std::string description_, bool help, detail::enabler) - : description_(description_) { + : description_(std::move(description_)) { if(help) help_ptr_ = add_flag("-h,--help", "Print this help message and exit"); @@ -514,7 +515,7 @@ public: name_ = argv[0]; std::vector args; for(int i=argc-1; i>0; i--) - args.push_back(argv[i]); + args.emplace_back(argv[i]); return parse(args); } @@ -949,7 +950,7 @@ protected: try { size_t ui = std::stoul(val); for (size_t i=0; iresults_.push_back(""); + op->results_.emplace_back(""); } catch (const std::invalid_argument &) { throw ConversionError(current.fullname + ": Should be true/false or a number"); } diff --git a/include/CLI/Ini.hpp b/include/CLI/Ini.hpp index 252a87c7..e29142c1 100644 --- a/include/CLI/Ini.hpp +++ b/include/CLI/Ini.hpp @@ -24,10 +24,10 @@ inline std::string inijoin(std::vector args) { auto it = std::find_if(arg.begin(), arg.end(), [](char ch){ return std::isspace(ch , std::locale());}); if(it == arg.end()) s << arg; - else if(arg.find("\"") == std::string::npos) - s << "\"" << arg << "\""; + else if(arg.find(R"(")") == std::string::npos) + s << R"(")" << arg << R"(")"; else - s << "\'" << arg << "\'"; + s << R"(')" << arg << R"(')"; } return s.str(); diff --git a/include/CLI/Option.hpp b/include/CLI/Option.hpp index 0e03d7db..98090b38 100644 --- a/include/CLI/Option.hpp +++ b/include/CLI/Option.hpp @@ -5,6 +5,7 @@ #include #include +#include #include #include #include @@ -17,13 +18,13 @@ namespace CLI { -typedef std::vector results_t; -typedef std::function callback_t; +using results_t = std::vector; +using callback_t = std::function; class Option; class App; -typedef std::unique_ptr