From 31bc3f3bf72b31ce3884354902e7e38f5c74050b Mon Sep 17 00:00:00 2001 From: Brett Date: Sat, 30 Mar 2024 17:23:23 -0400 Subject: [PATCH] add doubles, floats and longs to argparse --- include/blt/parse/argparse.h | 2 +- libraries/parallel-hashmap | 2 +- src/blt/parse/argparse.cpp | 15 ++++++++++++--- 3 files changed, 14 insertions(+), 5 deletions(-) diff --git a/include/blt/parse/argparse.h b/include/blt/parse/argparse.h index 6636514..0b16f48 100644 --- a/include/blt/parse/argparse.h +++ b/include/blt/parse/argparse.h @@ -20,7 +20,7 @@ namespace blt { - typedef std::variant arg_data_internal_t; + typedef std::variant arg_data_internal_t; typedef std::vector arg_data_vec_t; typedef std::variant arg_data_t; diff --git a/libraries/parallel-hashmap b/libraries/parallel-hashmap index 65775fa..67c2461 160000 --- a/libraries/parallel-hashmap +++ b/libraries/parallel-hashmap @@ -1 +1 @@ -Subproject commit 65775fa09fecaa65d0b0022ab6bf091c0e509445 +Subproject commit 67c24619e4f5ab2097b74cc397732c17a25d6944 diff --git a/src/blt/parse/argparse.cpp b/src/blt/parse/argparse.cpp index 92daea9..ded24bb 100644 --- a/src/blt/parse/argparse.cpp +++ b/src/blt/parse/argparse.cpp @@ -106,14 +106,23 @@ namespace blt std::string to_string(const arg_data_internal_t& v) { return std::visit(blt::lambda_visitor{ - [&](const std::string& str) { + [](const std::string& str) { return str; }, - [&](bool b) { + [](bool b) { return std::string(b ? "True" : "False"); }, - [&](int32_t i) { + [](int32_t 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); }