add doubles, floats and longs to argparse

v1
Brett 2024-03-30 17:23:23 -04:00
parent f100e95a30
commit 31bc3f3bf7
3 changed files with 14 additions and 5 deletions

View File

@ -20,7 +20,7 @@
namespace blt namespace blt
{ {
typedef std::variant<std::string, bool, int32_t> arg_data_internal_t; typedef std::variant<std::string, bool, int32_t, float, double, int64_t> arg_data_internal_t;
typedef std::vector<arg_data_internal_t> arg_data_vec_t; typedef std::vector<arg_data_internal_t> arg_data_vec_t;
typedef std::variant<arg_data_internal_t, arg_data_vec_t> arg_data_t; typedef std::variant<arg_data_internal_t, arg_data_vec_t> arg_data_t;

@ -1 +1 @@
Subproject commit 65775fa09fecaa65d0b0022ab6bf091c0e509445 Subproject commit 67c24619e4f5ab2097b74cc397732c17a25d6944

View File

@ -106,14 +106,23 @@ namespace blt
std::string to_string(const arg_data_internal_t& v) std::string to_string(const arg_data_internal_t& v)
{ {
return std::visit(blt::lambda_visitor{ return std::visit(blt::lambda_visitor{
[&](const std::string& str) { [](const std::string& str) {
return str; return str;
}, },
[&](bool b) { [](bool b) {
return std::string(b ? "True" : "False"); return std::string(b ? "True" : "False");
}, },
[&](int32_t i) { [](int32_t i) {
return std::to_string(i); return std::to_string(i);
},
[](float f){
return std::to_string(f);
},
[](int64_t i) {
return std::to_string(i);
},
[](double f){
return std::to_string(f);
} }
}, v); }, v);
} }