A simple wrapper around bool so that it can be read as a word: true/false, on/off, yes/no, any/none. Also accepts 0/1 as a string and shortcuts t/f, y/n. More...
Public Types | |
enum | switchType : unsigned char { FALSE = 0, TRUE = 1, NO = 2, YES = 3, OFF = 4, ON = 5, NONE = 6, ANY = 7, INVALID = 8 } |
Public Member Functions | |
Switch (const Switch &) noexcept=default | |
Switch & | operator= (const Switch &) noexcept=default |
constexpr | Switch () noexcept |
constexpr | Switch (const switchType sw) noexcept |
constexpr | Switch (const bool b) noexcept |
constexpr | Switch (const int i) noexcept |
Switch (const std::string &str) | |
Switch (const char *str) | |
Switch (const float val, const float tol=0.5) | |
Switch (const double val, const double tol=0.5) | |
Switch (const token &tok) | |
Switch (const word &key, const dictionary &dict) | |
Switch (const word &key, const dictionary &dict, const Switch deflt, const bool failsafe=false) | |
Switch (Istream &is) | |
bool | good () const noexcept |
bool | bad () const noexcept |
switchType | type () const noexcept |
void | negate () noexcept |
const char * | c_str () const noexcept |
std::string | str () const |
bool | readIfPresent (const word &key, const dictionary &dict) |
operator bool () const noexcept | |
Switch & | operator= (const switchType sw) noexcept |
Switch & | operator= (const bool b) noexcept |
Switch (const std::string &str, bool allowBad) | |
Switch (const char *str, bool allowBad) | |
FOAM_DEPRECATED_FOR (2019-02, "good() or static found() method") bool valid() const noexcept | |
Static Public Member Functions | |
static Switch | getOrAddToDict (const word &key, dictionary &dict, const Switch deflt=switchType::FALSE) |
static const char * | name (const bool b) noexcept |
static Switch | find (const std::string &str) |
static bool | found (const std::string &str) |
static Switch | lookupOrAddToDict (const word &name, dictionary &dict, const Switch deflt=switchType::FALSE) |
A simple wrapper around bool so that it can be read as a word: true/false, on/off, yes/no, any/none. Also accepts 0/1 as a string and shortcuts t/f, y/n.
enum switchType : unsigned char |
|
inlineconstexprnoexcept |
|
explicit |
Definition at line 208 of file Switch.C.
References bool, token::boolToken(), token::good(), token::isBool(), token::isLabel(), token::isWord(), token::labelToken(), and token::wordToken().
Switch | ( | const word & | key, |
const dictionary & | dict | ||
) |
key | Lookup key. Uses LITERAL (not REGEX) |
dict | dictionary |
Definition at line 231 of file Switch.C.
References dict, Foam::exit(), Foam::FatalIOError, FatalIOErrorInFunction, dictionary::get(), Switch::good(), Foam::glTF::key(), keyType::LITERAL, and Foam::printTokenError().
Switch | ( | const word & | key, |
const dictionary & | dict, | ||
const Switch | deflt, | ||
const bool | failsafe = false |
||
) |
key | Lookup key. Uses LITERAL (not REGEX) |
dict | dictionary |
deflt | fallback if not found |
failsafe | Warn only on bad input |
Definition at line 255 of file Switch.C.
References Switch::c_str(), dict, Foam::endl(), Foam::exit(), Foam::FatalIOError, FatalIOErrorInFunction, Switch::good(), IOWarningInFunction, Foam::glTF::key(), keyType::LITERAL, Foam::printTokenError(), and dictionary::readIfPresent().
|
static |
key | Lookup key. Uses LITERAL (not REGEX) |
dict | dictionary |
deflt | default value to add |
Definition at line 160 of file Switch.C.
References dict, dictionary::getOrAdd(), Foam::glTF::key(), and keyType::LITERAL.
Referenced by Switch::lookupOrAddToDict().
|
staticnoexcept |
Definition at line 141 of file Switch.C.
References Foam::constant::physicoChemical::b, and Foam::PtrListOps::names().
Referenced by boolEntry::evaluate(), Switch::lookupOrAddToDict(), ensightMesh::options::print(), profilingInformation::write(), mappedPatchBase::write(), and attachDetach::writeDict().
|
static |
Definition at line 147 of file Switch.C.
Referenced by isTrue(), scalarRange::parse(), and error::useAbort().
|
noexcept |
Definition at line 296 of file Switch.C.
Referenced by argList::argList(), Switch::bad(), IOstreamOption::compressionEnum(), Switch::FOAM_DEPRECATED_FOR(), isoSurfaceParams::getFilterType(), isTrue(), Foam::operator>>(), scalarRange::parse(), functionObjectList::read(), and Switch::Switch().
|
inlinenoexcept |
Definition at line 225 of file Switch.H.
References Switch::good().
|
noexcept |
|
noexcept |
Definition at line 318 of file Switch.C.
References Foam::PtrListOps::names().
Referenced by Foam::operator<<(), and Switch::Switch().
std::string str | ( | ) | const |
Definition at line 324 of file Switch.C.
References Foam::PtrListOps::names().
bool readIfPresent | ( | const word & | key, |
const dictionary & | dict | ||
) |
key | Lookup key. Uses LITERAL (not REGEX) |
dict | dictionary |
Definition at line 331 of file Switch.C.
References dict, Foam::glTF::key(), keyType::LITERAL, and dictionary::readIfPresent().
Referenced by qZeta::read().
|
inlinenoexcept |
Definition at line 264 of file Switch.H.
References Foam::constant::physicoChemical::b, Switch::FALSE, and Switch::TRUE.
|
inlinenoexcept |
Definition at line 285 of file Switch.H.
References Switch::good().
|
inlinestatic |
Definition at line 293 of file Switch.H.
References dict, Switch::getOrAddToDict(), and Switch::name().
Copyright © 2011-2018 OpenFOAM | OPENFOAM® is a registered trademark of OpenCFD Ltd.