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/any. More...
Public Types | |
enum | switchType : unsigned char { False = 0, True = 1, off = 2, on = 3, no = 4, yes = 5, n = 6, y = 7, f = 8, t = 9, none = 10, any = 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 unsigned char | toInt (const switchType x) |
Convert switchType to integer (unsigned char) More... | |
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 unsigned char | nSwitchType |
Number of switchTypes. More... | |
Friends | |
switchType | operator++ (switchType &x) |
Increment the switchType counter. More... | |
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/any.
|
strong |
|
inline |
Construct null as false.
Definition at line 128 of file Switch.H.
Referenced by Switch::Switch().
|
inline |
|
inline |
Construct from integer values (treats integer as bool value)
Definition at line 146 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.
|
inlinestatic |
Convert switchType to integer (unsigned char)
Definition at line 90 of file Switch.H.
References x.
Referenced by Switch::asText(), and Switch::operator bool().
|
static |
Construct from dictionary, supplying default value so that if the.
value is not found, it is added into the dictionary.
Definition at line 111 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 123 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 129 of file Switch.C.
References Switch::toInt().
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 135 of file Switch.C.
References Foam::name(), and dictionary::readIfPresent().
Referenced by qZeta::read(), and Switch::Switch().
|
inline |
Conversion to bool.
Definition at line 193 of file Switch.H.
References Switch::toInt().
|
inline |
|
inline |
Assignment to bool.
Definition at line 205 of file Switch.H.
References Switch::False, Switch::operator<<, Switch::operator>>, and Switch::True.
|
friend |
Referenced by Switch::operator=().
Referenced by Switch::operator=().
|
static |
Number of switchTypes.