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... | |
void | operator= (const switchType sw) |
Assignment to enumerated value. More... | |
void | operator= (const bool b) |
Assignment to 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... | |
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 |
Construct null as false.
Definition at line 119 of file Switch.H.
Referenced by Switch::Switch().
|
inline |
|
inline |
Construct from integer values (treats integer as bool value)
Definition at line 137 of file Switch.H.
References Switch::asText(), Switch::lookupOrAddToDict(), Switch::readIfPresent(), Switch::Switch(), and Switch::valid().
|
inline |
|
inline |
Construct from Istream.
Definition at line 31 of file SwitchIO.C.
|
static |
Construct from dictionary, supplying default value so that if the.
value is not found, it is added into the dictionary.
Definition at line 105 of file Switch.C.
References dictionary::lookupOrAddDefault(), and Foam::name().
Referenced by Switch::Switch().
bool valid | ( | ) | const |
Return true if the Switch has a valid value.
Definition at line 117 of file Switch.C.
References Switch::NONE.
Referenced by IOstream::compressionEnum(), and Switch::Switch().
const char * asText | ( | ) | const |
Return a text representation of the Switch.
Definition at line 123 of file Switch.C.
References Switch::names.
Referenced by Switch::Switch(), and polyMeshFilterSettings::writeSettings().
bool readIfPresent | ( | const word & | name, |
const dictionary & | dict | ||
) |
Update the value of the Switch if it is found in the dictionary.
Definition at line 129 of file Switch.C.
References Foam::name(), and dictionary::readIfPresent().
Referenced by qZeta::read(), and Switch::Switch().
|
inline |
|
inline |
Assignment to bool.
Definition at line 196 of file Switch.H.
References Switch::FALSE, Switch::operator<<, Switch::operator>>, and Switch::TRUE.
Referenced by Switch::operator=().
Referenced by Switch::operator=().
|
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 Switch::asText(), and Foam::operator<<().