diff --git a/.gitignore b/.gitignore index 259148f..4712be4 100644 --- a/.gitignore +++ b/.gitignore @@ -30,3 +30,5 @@ *.exe *.out *.app + +build \ No newline at end of file diff --git a/README.md b/README.md index dd6dc94..92b5031 100644 --- a/README.md +++ b/README.md @@ -136,8 +136,3 @@ Or, may be you can join us. ## Forkers [![Forkers repo roster for @ZhengqiaoWang/JArgsParser](https://reporoster.com/forks/ZhengqiaoWang/JArgsParser)](https://github.com/ZhengqiaoWang/JArgsParser/network/members) - -## TODO - -- [x] UT 20221015 -- [ ] DOCS diff --git a/interface/jargs_parser_api.hpp b/interface/jargs_parser_api.hpp index afabc40..bf03ed1 100644 --- a/interface/jargs_parser_api.hpp +++ b/interface/jargs_parser_api.hpp @@ -1,8 +1,8 @@ /** * @file jargs_parser_api.hpp * @brief A header-only c++ argument parser lib - * @version 0.0.2 - * @date 2022-10-16 + * @version 1.0.0 + * @date 2022-10-26 * * @url https://github.com/ZhengqiaoWang/JArgsParser * @@ -270,9 +270,9 @@ namespace Joger ArgsDesc(const std::string &key, const ArgsValType &arg_val_type, const std::string description) : key(key), + arg_type(ArgsType::POSITION), arg_val_type(arg_val_type), description(description), - arg_type(ArgsType::POSITION), required(true) { arg_width = key.size(); @@ -290,12 +290,12 @@ namespace Joger const std::string &short_name, const std::string &full_name, const std::string description) : key(key), + arg_type(ArgsType::FLAG), + arg_val_type(ArgsValType::NOTYPE), short_name(short_name), full_name(full_name), description(description), - arg_type(ArgsType::FLAG), - required(false), - arg_val_type(ArgsValType::NOTYPE) + required(false) { arg_width = short_name.size() + full_name.size() + 1; } @@ -316,12 +316,12 @@ namespace Joger const ArgsValType &arg_val_type, const std::string description, bool required = true) : key(key), + arg_type(ArgsType::VALUE), + arg_val_type(arg_val_type), short_name(short_name), full_name(full_name), - required(required), description(description), - arg_val_type(arg_val_type), - arg_type(ArgsType::VALUE) + required(required) { arg_width = short_name.size() + full_name.size() + 1; } @@ -340,13 +340,13 @@ namespace Joger const std::string &full_name, const std::function &action, const std::string description) : key(key), + arg_type(ArgsType::ACTION), + arg_val_type(ArgsValType::NOTYPE), short_name(short_name), full_name(full_name), description(description), - action(action), - arg_type(ArgsType::ACTION), required(false), - arg_val_type(ArgsValType::NOTYPE) + action(action) { arg_width = short_name.size() + full_name.size() + 1; } @@ -356,15 +356,15 @@ namespace Joger } public: - std::string key; ///< primary key for get arg value - ArgsType arg_type; ///< arg type - ArgsValType arg_val_type; ///< arg value type - std::string short_name; ///< short arg - std::string full_name; ///< full(long) arg - std::string description; ///< arg info - bool required{false}; ///< required flag + std::string key{""}; ///< primary key for get arg value + ArgsType arg_type{ArgsType::POSITION}; ///< arg type + ArgsValType arg_val_type{ArgsValType::STRING}; ///< arg value type + std::string short_name{""}; ///< short arg + std::string full_name{""}; ///< full(long) arg + std::string description{""}; ///< arg info + bool required{true}; ///< required flag std::function action; ///< what function after action arg called - int arg_width{0}; ///< store the width of both short_name and full_name to display help + size_t arg_width{0}; ///< store the width of both short_name and full_name to display help }; static bool isInterger(const std::string &in_val); @@ -926,7 +926,6 @@ namespace Joger { return false; } - auto &desc = getArgsDesc(key); auto &result_vec = m_key_val[key]; if (result_vec.empty()) { @@ -1040,7 +1039,7 @@ namespace Joger static bool isInterger(const std::string &in_val) { - for (int i = 0; i < in_val.size(); ++i) + for (size_t i = 0; i < in_val.size(); ++i) { if (in_val.at(i) == '-' && in_val.size() > 0) { @@ -1057,7 +1056,7 @@ namespace Joger static bool isFloat(const std::string &in_val) { int dot_cnt{0}; - for (int i = 0; i < in_val.size(); ++i) + for (size_t i = 0; i < in_val.size(); ++i) { if (in_val.at(i) == '-' && in_val.size() > 0) { @@ -1085,7 +1084,7 @@ namespace Joger std::vector result; int start_pos{0}; - for (int i = 0; i < in_val.size(); ++i) + for (size_t i = 0; i < in_val.size(); ++i) { if (in_val.at(i) == spliter) {