diff --git a/src/OpenFOAM/primitives/bools/Switch/Switch.C b/src/OpenFOAM/primitives/bools/Switch/Switch.C index 0b87ca6e2764648ded5bc6113dde8fc88f9687cc..3a227f99b4a42fd69466a8d73e795ebb1bc7466c 100644 --- a/src/OpenFOAM/primitives/bools/Switch/Switch.C +++ b/src/OpenFOAM/primitives/bools/Switch/Switch.C @@ -37,6 +37,7 @@ const char* Foam::Switch::names[Foam::Switch::INVALID+1] = "off", "on", "no", "yes", "n", "y", + "f", "t", "none", "true", // is there a reasonable counterpart to "none"? "invalid" }; @@ -54,18 +55,39 @@ Foam::Switch::switchType Foam::Switch::asEnum { if (str == names[sw]) { - // convert n/y to no/yes - perhaps should deprecate y/n - if (sw == Switch::NO_1 || sw == Switch::NONE) + // handle aliases + switch (sw) { - return Switch::NO; - } - else if (sw == Switch::YES_1) - { - return Switch::YES; - } - else - { - return switchType(sw); + case Switch::NO_1: + case Switch::NONE: + { + return Switch::NO; + break; + } + + case Switch::YES_1: + { + return Switch::YES; + break; + } + + case Switch::FALSE_1: + { + return Switch::FALSE; + break; + } + + case Switch::TRUE_1: + { + return Switch::TRUE; + break; + } + + default: + { + return switchType(sw); + break; + } } } } diff --git a/src/OpenFOAM/primitives/bools/Switch/Switch.H b/src/OpenFOAM/primitives/bools/Switch/Switch.H index e68be1a2de8db66503617be0dcc6d2308dfcf3af..027d313a0aa68258c728359a1907e0863bb7e2fd 100644 --- a/src/OpenFOAM/primitives/bools/Switch/Switch.H +++ b/src/OpenFOAM/primitives/bools/Switch/Switch.H @@ -26,7 +26,7 @@ Class Description A simple wrapper around bool so that it can be read as a word: - true/false, on/off, yes/no or y/n or none. + true/false, on/off, yes/no, y/n, t/f, or none. SourceFiles Switch.C @@ -78,6 +78,8 @@ public: #undef YES #undef NO_1 #undef YES_1 + #undef FALSE_1 + #undef TRUE_1 #undef NONE #undef PLACEHOLDER #undef INVALID @@ -86,11 +88,12 @@ public: // These also correspond to the entries in names. enum switchType { - FALSE = 0, TRUE = 1, - OFF = 2, ON = 3, - NO = 4, YES = 5, - NO_1 = 6, YES_1 = 7, - NONE = 8, PLACEHOLDER = 9, + FALSE = 0, TRUE = 1, + OFF = 2, ON = 3, + NO = 4, YES = 5, + NO_1 = 6, YES_1 = 7, + FALSE_1 = 8, TRUE_1 = 9, + NONE = 10, PLACEHOLDER = 11, INVALID };