diff --git a/Makefile b/Makefile index 1587264f0124611d63afc5bf62dcaa0eea926052..e7e2e1d6940152d6c0c4bc75c619600370bf4b36 100644 --- a/Makefile +++ b/Makefile @@ -8,7 +8,7 @@ ARFLAGS = rcs PREFIX ?= /usr def: - @echo Run make install + @echo This library is header-only, and no need to compile. Run make install if you would like. install_header: [ ! -d $(PREFIX)/include/rlib ] || rm -rf $(PREFIX)/include/rlib diff --git a/opt.hpp b/opt.hpp index 3654fdf97f81073b25007613b3826babb5ac4343..905ae264f49676915f5f3b52588c9c7b3682c92e 100644 --- a/opt.hpp +++ b/opt.hpp @@ -79,20 +79,8 @@ namespace rlib { } } - rlib::string getValueArg(const std::string &longName, const char *shortName) - { //getValueArg("--long", "-l") may be converted to getValueArg("--long", true). - return getValueArg(longName, shortName, true); - } - - bool getBoolArg(const std::string &argName) - { //Return if it's defined. - auto pos = std::find(args.cbegin(), args.cend(), argName); - if(pos == args.cend()) return false; - args.erase(pos); - return true; - } - - rlib::string getValueArg(const std::string &longName, const std::string &shortName, bool required = true, const std::string &def = std::string()) + // rlib::string getValueArg(const std::string &longName, const std::string &shortName, bool required = true, const std::string &def = std::string()) // MSVC doesn't allow this overload. + rlib::string getValueArg(const std::string &longName, const std::string &shortName, bool required, const std::string &def) { using rlib::literals::operator "" _format; std::string valueL = getValueArg(longName, false); @@ -107,6 +95,25 @@ namespace rlib { } return std::move(value); } + rlib::string getValueArg(const std::string &longName, const std::string &shortName, bool required) { + return getValueArg(longName, shortName, required, std::string()); + } + rlib::string getValueArg(const std::string &longName, const std::string &shortName) { + return getValueArg(longName, shortName, true, std::string()); + } + + rlib::string getValueArg(const std::string &longName, const char *shortName) + { //getValueArg("--long", "-l") may be converted to getValueArg("--long", true). + return getValueArg(longName, shortName, true); + } + + bool getBoolArg(const std::string &argName) + { //Return if it's defined. + auto pos = std::find(args.cbegin(), args.cend(), argName); + if(pos == args.cend()) return false; + args.erase(pos); + return true; + } bool getBoolArg(const std::string &longName, const std::string &shortName) {