From 2a9e68c2bf30ff4e698d926a3eb91fd5b90c3a44 Mon Sep 17 00:00:00 2001 From: Mark Olesen Date: Wed, 24 Aug 2022 13:01:48 +0200 Subject: [PATCH] ENH: add -opt-switch support for strings (eg, named enums) - issue #2222 --- .../global/debug/simpleObjectRegistry.C | 33 ++++++++++++------- 1 file changed, 21 insertions(+), 12 deletions(-) diff --git a/src/OpenFOAM/global/debug/simpleObjectRegistry.C b/src/OpenFOAM/global/debug/simpleObjectRegistry.C index 70d7d5aff2..5636a7bca5 100644 --- a/src/OpenFOAM/global/debug/simpleObjectRegistry.C +++ b/src/OpenFOAM/global/debug/simpleObjectRegistry.C @@ -5,7 +5,7 @@ \\ / A nd | www.openfoam.com \\/ M anipulation | ------------------------------------------------------------------------------- - Copyright (C) 2019-2021 OpenCFD Ltd. + Copyright (C) 2019-2022 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -107,21 +107,30 @@ void Foam::simpleObjectRegistry::setNamedValue if (eq != std::string::npos) { - std::string strval(name.substr(eq+1)); + string strval(name.substr(eq+1)); name.erase(eq); // Truncate the name - float fvalue(val); + // Treat 'name=' like 'name' (ie, default value) + if (strval.length()) + { + float fvalue(0); - if (Foam::readInt(strval, val)) - { - tok = static_cast