From 93670e7091c99572b4512f2e07198bfbfb173690 Mon Sep 17 00:00:00 2001 From: Dan Smith Date: Wed, 15 Nov 2023 11:38:39 -0500 Subject: [PATCH] latest from CODA-OSS --- externals/coda-oss/modules/c++/CMakeLists.txt | 7 +++++-- .../coda-oss/modules/c++/coda-oss.vcxproj | 4 ++-- .../modules/c++/str/include/str/Convert.h | 3 ++- .../modules/c++/str/source/Convert.cpp | 21 +++++++------------ 4 files changed, 16 insertions(+), 19 deletions(-) diff --git a/externals/coda-oss/modules/c++/CMakeLists.txt b/externals/coda-oss/modules/c++/CMakeLists.txt index d30fb5766..694e037aa 100644 --- a/externals/coda-oss/modules/c++/CMakeLists.txt +++ b/externals/coda-oss/modules/c++/CMakeLists.txt @@ -3,8 +3,11 @@ set(TARGET_LANGUAGE c++) if (MSVC) # By default, there is a /W3 on the command-line from somewhere (?); adding # /Wn results in a compiler warning. - #add_compile_options(/W4) # /Wall - string(REGEX REPLACE "/W[0-4]" "/W4" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}") # /Wall + # + # https://github.com/microsoft/STL/wiki/Changelog#vs-2022-179-preview-1 + # > *Note*: `/Wall` is not intended for regular production use, as it contains a large number of + # > extremely noisy and low-value warnings. In general, the STL does not attempt to be `/Wall` clean. + string(REGEX REPLACE "/W[0-4]" "/W4" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}") # add_compile_options(/W4) elseif (UNIX) # https://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html diff --git a/externals/coda-oss/modules/c++/coda-oss.vcxproj b/externals/coda-oss/modules/c++/coda-oss.vcxproj index e2b2a306d..77af044c5 100644 --- a/externals/coda-oss/modules/c++/coda-oss.vcxproj +++ b/externals/coda-oss/modules/c++/coda-oss.vcxproj @@ -564,7 +564,7 @@ - EnableAllWarnings + Level4 true _DEBUG;_LIB;%(PreprocessorDefinitions);CODA_OSS_EXPORTS;CODA_OSS_DLL;MT_DEFAULT_PINNING=0;RE_ENABLE_STD_REGEX=1 pch.h @@ -593,7 +593,6 @@ - Level3 true true true @@ -609,6 +608,7 @@ true /Zc:__cplusplus %(AdditionalOptions) AdvancedVectorExtensions2 + Level3 diff --git a/externals/coda-oss/modules/c++/str/include/str/Convert.h b/externals/coda-oss/modules/c++/str/include/str/Convert.h index c701580c4..ca154a6a1 100644 --- a/externals/coda-oss/modules/c++/str/include/str/Convert.h +++ b/externals/coda-oss/modules/c++/str/include/str/Convert.h @@ -63,7 +63,7 @@ std::string toString_(const T& value) return buf.str(); } template -inline auto toString(const T& value) +inline std::string toString(const T& value) { return toString_(value); } @@ -105,6 +105,7 @@ inline auto toString(long double value) { return toString_(value); } + inline std::string toString(uint8_t value) { return toString(gsl::narrow(value)); diff --git a/externals/coda-oss/modules/c++/str/source/Convert.cpp b/externals/coda-oss/modules/c++/str/source/Convert.cpp index f2ae3d9f9..b8a2bc741 100644 --- a/externals/coda-oss/modules/c++/str/source/Convert.cpp +++ b/externals/coda-oss/modules/c++/str/source/Convert.cpp @@ -42,32 +42,25 @@ template<> std::string str::toType(const std::string& s) template<> bool str::toType(const std::string& s) { - std::string ss = s; - str::lower(ss); - - if (ss == "true") + if (eq(s, "true")) // case-insensitive compare { return true; } - else if (ss == "false") + if (eq(s, "false")) // case-insensitive compare { return false; } - else if (str::isNumeric(ss)) + + // no need for lower(), digits don't have case + if (str::isNumeric(s)) { int value(0); - std::stringstream buf(ss); + std::stringstream buf(s); buf >> value; return (value != 0); } - else - { - throw except::BadCastException(except::Context(__FILE__, __LINE__, - std::string(""), std::string(""), - std::string("Invalid bool: '") + s + std::string("'"))); - } - return false; + throw except::BadCastException(except::Context(__FILE__, __LINE__, "", "", "Invalid bool: '" + s + "'")); } long long str::strtoll(const char *str, char **endptr, int base)