From 4d40f00ba87a559932c7ac3d5d1fb4f6b0f240ca Mon Sep 17 00:00:00 2001 From: StephenCzarnecki Date: Wed, 18 Dec 2024 19:24:54 -0500 Subject: [PATCH] Changed enumFromString to be case insensitive. Needed because sometime lenth units are 'Meter' and sometimes 'meter'. --- include/fileParse/StringConversion.hxx | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/include/fileParse/StringConversion.hxx b/include/fileParse/StringConversion.hxx index 8f2ba2d..6dda0d4 100644 --- a/include/fileParse/StringConversion.hxx +++ b/include/fileParse/StringConversion.hxx @@ -64,6 +64,19 @@ namespace FileParse return from_string(str); } + inline std::string toLower(std::string s) + { +#ifdef _MSC_VER +# pragma warning(push) +# pragma warning(disable : 4244) +#endif + std::transform(s.begin(), s.end(), s.begin(), ::tolower); +#ifdef _MSC_VER +# pragma warning(pop) +#endif + return s; + } + /// Enumerator to string conversion routines. /// Converts an enumerator value to a string. @@ -77,9 +90,10 @@ namespace FileParse const std::array & values, EnumType defaultValue) { + auto nameLower = toLower(std::string(name)); for(std::size_t i = 0; i < values.size(); ++i) { - if(values[i] == name) + if(toLower(values[i]) == nameLower) { return static_cast(i); }