mirror of
https://github.com/CLIUtils/CLI11.git
synced 2025-05-01 21:23:52 +00:00
Using empty instead of 0 size
This commit is contained in:
parent
60934c8a27
commit
1ee22ec9ff
@ -1,6 +1,6 @@
|
|||||||
#Checks: '*,-clang-analyzer-alpha.*'
|
#Checks: '*,-clang-analyzer-alpha.*'
|
||||||
#Checks: '-*,google-readability-casting,llvm-namespace-comment,performance-unnecessary-value-param,llvm-include-order,misc-throw-by-value-catch-by-reference,readability-container-size-empty,google-runtime-references,modernize*'
|
#Checks: '-*,google-readability-casting,llvm-namespace-comment,performance-unnecessary-value-param,llvm-include-order,misc-throw-by-value-catch-by-reference,readability-container-size-empty,google-runtime-references,modernize*'
|
||||||
Checks: '-*,llvm-namespace-comment,llvm-include-order'
|
Checks: '-*,llvm-namespace-comment,llvm-include-order,readability-container-size-empty'
|
||||||
HeaderFilterRegex: '.*hpp'
|
HeaderFilterRegex: '.*hpp'
|
||||||
CheckOptions:
|
CheckOptions:
|
||||||
- key: readability-braces-around-statements.ShortStatementLines
|
- key: readability-braces-around-statements.ShortStatementLines
|
||||||
|
@ -602,7 +602,7 @@ public:
|
|||||||
for(const Option_p &opt : options_) {
|
for(const Option_p &opt : options_) {
|
||||||
|
|
||||||
// Only process option with a long-name
|
// Only process option with a long-name
|
||||||
if(opt->lnames_.size() > 0) {
|
if(!opt->lnames_.empty()) {
|
||||||
std::string name = prefix + opt->lnames_[0];
|
std::string name = prefix + opt->lnames_[0];
|
||||||
|
|
||||||
// Non-flags
|
// Non-flags
|
||||||
@ -644,7 +644,7 @@ public:
|
|||||||
prev += " " + name_;
|
prev += " " + name_;
|
||||||
|
|
||||||
auto selected_subcommands = get_subcommands();
|
auto selected_subcommands = get_subcommands();
|
||||||
if(selected_subcommands.size() > 0)
|
if(!selected_subcommands.empty())
|
||||||
return selected_subcommands.at(0)->help(wid, prev);
|
return selected_subcommands.at(0)->help(wid, prev);
|
||||||
|
|
||||||
std::stringstream out;
|
std::stringstream out;
|
||||||
@ -676,7 +676,7 @@ public:
|
|||||||
pos=true;
|
pos=true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(subcommands_.size() > 0) {
|
if(!subcommands_.empty()) {
|
||||||
if(require_subcommand_ != 0)
|
if(require_subcommand_ != 0)
|
||||||
out << " SUBCOMMAND";
|
out << " SUBCOMMAND";
|
||||||
else
|
else
|
||||||
@ -715,7 +715,7 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Subcommands
|
// Subcommands
|
||||||
if(subcommands_.size()> 0) {
|
if(!subcommands_.empty()) {
|
||||||
out << "Subcommands:" << std::endl;
|
out << "Subcommands:" << std::endl;
|
||||||
for(const App_p &com : subcommands_)
|
for(const App_p &com : subcommands_)
|
||||||
detail::format_help(out, com->get_name(), com->description_, wid);
|
detail::format_help(out, com->get_name(), com->description_, wid);
|
||||||
@ -829,7 +829,7 @@ protected:
|
|||||||
parsed_ = true;
|
parsed_ = true;
|
||||||
bool positional_only = false;
|
bool positional_only = false;
|
||||||
|
|
||||||
while(args.size()>0) {
|
while(!args.empty()) {
|
||||||
_parse_single(args, positional_only);
|
_parse_single(args, positional_only);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -842,7 +842,7 @@ protected:
|
|||||||
if (config_ptr_ != nullptr && config_name_ != "") {
|
if (config_ptr_ != nullptr && config_name_ != "") {
|
||||||
try {
|
try {
|
||||||
std::vector<detail::ini_ret_t> values = detail::parse_ini(config_name_);
|
std::vector<detail::ini_ret_t> values = detail::parse_ini(config_name_);
|
||||||
while(values.size() > 0) {
|
while(!values.empty()) {
|
||||||
if(!_parse_ini(values)) {
|
if(!_parse_ini(values)) {
|
||||||
throw ExtrasINIError(values.back().fullname);
|
throw ExtrasINIError(values.back().fullname);
|
||||||
}
|
}
|
||||||
@ -888,7 +888,7 @@ protected:
|
|||||||
}
|
}
|
||||||
|
|
||||||
auto selected_subcommands =get_subcommands();
|
auto selected_subcommands =get_subcommands();
|
||||||
if(require_subcommand_ < 0 && selected_subcommands.size() == 0)
|
if(require_subcommand_ < 0 && selected_subcommands.empty())
|
||||||
throw RequiredError("Subcommand required");
|
throw RequiredError("Subcommand required");
|
||||||
else if(require_subcommand_ > 0 && static_cast<int>( selected_subcommands.size()) != require_subcommand_)
|
else if(require_subcommand_ > 0 && static_cast<int>( selected_subcommands.size()) != require_subcommand_)
|
||||||
throw RequiredError(std::to_string(require_subcommand_) + " subcommand(s) required");
|
throw RequiredError(std::to_string(require_subcommand_) + " subcommand(s) required");
|
||||||
@ -1081,11 +1081,11 @@ protected:
|
|||||||
|
|
||||||
|
|
||||||
if(num == -1) {
|
if(num == -1) {
|
||||||
while(args.size()>0 && _recognize(args.back()) == detail::Classifer::NONE) {
|
while(!args.empty() && _recognize(args.back()) == detail::Classifer::NONE) {
|
||||||
op->add_result(args.back());
|
op->add_result(args.back());
|
||||||
args.pop_back();
|
args.pop_back();
|
||||||
}
|
}
|
||||||
} else while(num>0 && args.size() > 0) {
|
} else while(num>0 && !args.empty()) {
|
||||||
num--;
|
num--;
|
||||||
std::string current_ = args.back();
|
std::string current_ = args.back();
|
||||||
args.pop_back();
|
args.pop_back();
|
||||||
@ -1137,11 +1137,11 @@ protected:
|
|||||||
}
|
}
|
||||||
|
|
||||||
if(num == -1) {
|
if(num == -1) {
|
||||||
while(args.size() > 0 && _recognize(args.back()) == detail::Classifer::NONE) {
|
while(!args.empty() && _recognize(args.back()) == detail::Classifer::NONE) {
|
||||||
op->add_result(args.back());
|
op->add_result(args.back());
|
||||||
args.pop_back();
|
args.pop_back();
|
||||||
}
|
}
|
||||||
} else while(num>0 && args.size()>0) {
|
} else while(num>0 && !args.empty()) {
|
||||||
num--;
|
num--;
|
||||||
op->add_result(args.back());
|
op->add_result(args.back());
|
||||||
args.pop_back();
|
args.pop_back();
|
||||||
|
@ -354,12 +354,12 @@ public:
|
|||||||
}
|
}
|
||||||
if(envname_ != "")
|
if(envname_ != "")
|
||||||
out << " (env:" << envname_ << ")";
|
out << " (env:" << envname_ << ")";
|
||||||
if(requires_.size() > 0) {
|
if(!requires_.empty()) {
|
||||||
out << " Requires:";
|
out << " Requires:";
|
||||||
for(const Option* opt : requires_)
|
for(const Option* opt : requires_)
|
||||||
out << " " << opt->get_name();
|
out << " " << opt->get_name();
|
||||||
}
|
}
|
||||||
if(excludes_.size() > 0) {
|
if(!excludes_.empty()) {
|
||||||
out << " Excludes:";
|
out << " Excludes:";
|
||||||
for(const Option* opt : excludes_)
|
for(const Option* opt : excludes_)
|
||||||
out << " " << opt->get_name();
|
out << " " << opt->get_name();
|
||||||
@ -377,7 +377,7 @@ public:
|
|||||||
void run_callback() const {
|
void run_callback() const {
|
||||||
if(!callback_(results_))
|
if(!callback_(results_))
|
||||||
throw ConversionError(get_name() + "=" + detail::join(results_));
|
throw ConversionError(get_name() + "=" + detail::join(results_));
|
||||||
if(validators_.size()>0) {
|
if(!validators_.empty()) {
|
||||||
for(const std::string & result : results_)
|
for(const std::string & result : results_)
|
||||||
for(const std::function<bool(std::string)> &vali : validators_)
|
for(const std::function<bool(std::string)> &vali : validators_)
|
||||||
if(!vali(result))
|
if(!vali(result))
|
||||||
@ -486,7 +486,7 @@ public:
|
|||||||
///@{
|
///@{
|
||||||
/// Can print positional name detailed option if true
|
/// Can print positional name detailed option if true
|
||||||
bool _has_help_positional() const {
|
bool _has_help_positional() const {
|
||||||
return get_positional() && (has_description() || requires_.size()>0 || excludes_.size()>0 );
|
return get_positional() && (has_description() || !requires_.empty() || !excludes_.empty() );
|
||||||
}
|
}
|
||||||
///@}
|
///@}
|
||||||
};
|
};
|
||||||
|
@ -136,7 +136,7 @@ bool valid_later_char(T c) {
|
|||||||
|
|
||||||
/// Verify an option name
|
/// Verify an option name
|
||||||
inline bool valid_name_string(const std::string &str) {
|
inline bool valid_name_string(const std::string &str) {
|
||||||
if(str.size()<1 || !valid_first_char(str[0]))
|
if(str.empty() || !valid_first_char(str[0]))
|
||||||
return false;
|
return false;
|
||||||
for(auto c : str.substr(1))
|
for(auto c : str.substr(1))
|
||||||
if(!valid_later_char(c))
|
if(!valid_later_char(c))
|
||||||
@ -160,7 +160,7 @@ inline std::vector<std::string> split_up(std::string str) {
|
|||||||
|
|
||||||
std::vector<std::string> output;
|
std::vector<std::string> output;
|
||||||
|
|
||||||
while(str.size() > 0) {
|
while(!str.empty()) {
|
||||||
if(str[0] == '\'') {
|
if(str[0] == '\'') {
|
||||||
auto end = str.find('\'', 1);
|
auto end = str.find('\'', 1);
|
||||||
if(end != std::string::npos) {
|
if(end != std::string::npos) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user