12#include "../TypeTools.hpp"
14#include "../StringTools.hpp"
32CLI11_INLINE std::int64_t to_flag_value(std::string val)
noexcept {
33 static const std::string trueString(
"true");
34 static const std::string falseString(
"false");
35 if(val == trueString) {
38 if(val == falseString) {
41 val = detail::to_lower(std::move(val));
44 if(val[0] >=
'1' && val[0] <=
'9') {
45 return (
static_cast<std::int64_t
>(val[0]) -
'0');
65 if(val == trueString || val ==
"on" || val ==
"yes" || val ==
"enable") {
67 }
else if(val == falseString || val ==
"off" || val ==
"no" || val ==
"disable") {
70 char *loc_ptr{
nullptr};
71 ret = std::strtoll(val.c_str(), &loc_ptr, 0);
72 if(loc_ptr != (val.c_str() + val.size()) && errno == 0) {
79CLI11_INLINE std::string sum_string_vector(
const std::vector<std::string> &values) {
84 for(
const auto &arg : values) {
86 if(!integral_conversion(arg, tv)) {
91 if((tv > 0 && ival > (std::numeric_limits<std::int64_t>::max)() - tv) ||
92 (tv < 0 && ival < (std::numeric_limits<std::int64_t>::min)() - tv)) {
99 return std::to_string(ival);
105 for(
const auto &arg : values) {
107 auto comp = lexical_cast(arg, tv);
110 auto fv = detail::to_flag_value(arg);
115 tv =
static_cast<double>(fv);
120 for(
const auto &arg : values) {
124 std::ostringstream out;