A simple wrapper around bool so that it can be read as a word: true/false, on/off, yes/no, y/n, t/f, or none. More...
Public Types | |
enum | switchType { 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 } |
The various text representations for a switch value. More... | |
Public Member Functions | |
Switch () | |
Construct null as false. More... | |
Switch (const switchType sw) | |
Construct from enumerated value. More... | |
Switch (const bool b) | |
Construct from bool. More... | |
Switch (const int i) | |
Construct from integer values (treats integer as bool value) More... | |
Switch (const std::string &str, const bool allowInvalid=false) | |
Construct from std::string, string, word. More... | |
Switch (const char *str, const bool allowInvalid=false) | |
Construct from character array. More... | |
Switch (Istream &is) | |
Construct from Istream. More... | |
bool | valid () const |
Return true if the Switch has a valid value. More... | |
const char * | asText () const |
Return a text representation of the Switch. More... | |
bool | readIfPresent (const word &, const dictionary &) |
Update the value of the Switch if it is found in the dictionary. More... | |
operator bool () const | |
Conversion to bool. More... | |
const Switch & | operator= (const switchType sw) |
Assignment from enumerated value. More... | |
const Switch & | operator= (const bool b) |
Assignment from bool. More... | |
Static Public Member Functions | |
static Switch | lookupOrAddToDict (const word &, dictionary &, const Switch &defaultValue=false) |
Construct from dictionary, supplying default value so that if the. More... | |
Static Public Attributes | |
static const char * | names [INVALID+1] |
The set of names corresponding to the switchType enumeration. More... | |
Static Private Member Functions | |
static switchType | asEnum (const std::string &, const bool allowInvalid) |
Return a switchType representation of a word. More... | |
Private Attributes | |
unsigned char | switch_ |
The logic and enumerated text representation stored as a single byte. More... | |
Friends | |
Istream & | operator>> (Istream &, Switch &) |
Ostream & | operator<< (Ostream &, const Switch &) |
A simple wrapper around bool so that it can be read as a word: true/false, on/off, yes/no, y/n, t/f, or none.
enum switchType |
|
inline |
|
inline |
|
inline |
|
inline |
Construct from Istream.
Definition at line 31 of file SwitchIO.C.
|
staticprivate |
Return a switchType representation of a word.
Definition at line 49 of file Switch.C.
References Foam::abort(), Foam::FatalError, FatalErrorInFunction, INVALID, and Foam::nl.
|
static |
Construct from dictionary, supplying default value so that if the.
value is not found, it is added into the dictionary.
Definition at line 107 of file Switch.C.
References dict, and Foam::name().
bool valid | ( | ) | const |
Return true if the Switch has a valid value.
Definition at line 119 of file Switch.C.
References Switch::NONE, and Switch::switch_.
Referenced by IOstream::compressionEnum(), and Foam::operator>>().
const char * asText | ( | ) | const |
bool readIfPresent | ( | const word & | name, |
const dictionary & | dict | ||
) |
Update the value of the Switch if it is found in the dictionary.
Definition at line 131 of file Switch.C.
References dict, Foam::name(), and dictionary::readIfPresent().
Referenced by qZeta::read().
|
inline |
|
inline |
Assignment from enumerated value.
Definition at line 190 of file Switch.H.
References Switch::switch_.
|
inline |
Assignment from bool.
Definition at line 197 of file Switch.H.
References Foam::constant::physicoChemical::b, Switch::FALSE, Switch::switch_, and Switch::TRUE.
|
private |
The logic and enumerated text representation stored as a single byte.
Definition at line 65 of file Switch.H.
Referenced by Switch::operator bool(), Switch::operator=(), and Switch::valid().
|
static |
The set of names corresponding to the switchType enumeration.
Includes an extra entry for "invalid".
Definition at line 103 of file Switch.H.
Referenced by Foam::operator<<().
Copyright © 2011-2018 OpenFOAM | OPENFOAM® is a registered trademark of OpenCFD Ltd.