diff --git a/src/OpenFOAM/primitives/bools/Switch/Switch.C b/src/OpenFOAM/primitives/bools/Switch/Switch.C index caf3cebf98..9b7b449a22 100644 --- a/src/OpenFOAM/primitives/bools/Switch/Switch.C +++ b/src/OpenFOAM/primitives/bools/Switch/Switch.C @@ -46,7 +46,7 @@ const char* Foam::Switch::names[Foam::Switch::INVALID+1] = Foam::Switch::switchType Foam::Switch::asEnum(const bool val) { - return val ? Switch::FALSE : Switch::TRUE; + return val ? Switch::TRUE : Switch::FALSE; } diff --git a/src/OpenFOAM/primitives/bools/bool/boolIO.C b/src/OpenFOAM/primitives/bools/bool/boolIO.C index a78cfbb7b8..bfd087dda7 100644 --- a/src/OpenFOAM/primitives/bools/bool/boolIO.C +++ b/src/OpenFOAM/primitives/bools/bool/boolIO.C @@ -39,63 +39,11 @@ Description Foam::Istream& Foam::operator>>(Istream& is, bool& b) { - // we could also process everything via Switch - // The error messages are the problem: they are from SwitchIO.C -// Switch sw(is); -// -// if (is.good()) -// { -// b = sw; -// } -// -// return is; -// -// - token t(is); - - if (!t.good()) + if (is.good()) { - is.setBad(); - return is; + b = Switch(is); } - if (t.isLabel()) - { - b = bool(t.labelToken()); - } - else if (t.isWord()) - { - // allow invalid values, but catch after for correct error message - Switch::switchType sw = Switch::asEnum(t.wordToken(), true); - - if (sw == Switch::INVALID) - { - is.setBad(); - FatalIOErrorIn("operator>>(Istream&, bool&)", is) - << "expected 'true/false', 'on/off', found " << t.wordToken() - << exit(FatalIOError); - - return is; - } - else - { - b = Switch::asBool(sw); - } - } - else - { - is.setBad(); - FatalIOErrorIn("operator>>(Istream&, bool/Switch&)", is) - << "wrong token type - expected bool found " << t - << exit(FatalIOError); - - return is; - } - - - // Check state of Istream - is.check("Istream& operator>>(Istream&, bool&)"); - return is; }