Switch Class ReferenceA simple wrapper around bool so that it can be read as a word: true/false, on/off, yes/no or y/n or none.
More...
List of all members.
|
Public Types |
| enum | switchType {
FALSE = 0,
TRUE = 1,
OFF = 2,
ON = 3,
NO = 4,
YES = 5,
NO_1 = 6,
YES_1 = 7,
NONE = 8,
PLACEHOLDER = 9,
INVALID
} |
| | The various text representations for a switch value. More...
|
Public Member Functions |
| | Switch () |
| | Construct null as false.
|
| | Switch (const bool value) |
| | Construct from bool.
|
| | Switch (const int value) |
| | Construct from integer values (treats integer as bool value).
|
| | Switch (const std::string &value) |
| | Construct from std::string, string, word.
|
| | Switch (const char *value) |
| | Construct from character array.
|
| | Switch (Istream &is) |
| | Construct from Istream.
|
| | operator bool () const |
| | Conversion to bool.
|
| const Switch & | operator= (const bool b) |
| | Assignment from bool.
|
| bool | readIfPresent (const word &, const dictionary &) |
| | Update the value of the Switch if it is found in the dictionary.
|
Static Public Member Functions |
| static switchType | asEnum (const bool) |
| | Return a switchType representation of a bool.
|
| static switchType | asEnum (const std::string &, const bool allowInvalid=false) |
| | Return a switchType representation of a word.
|
| static bool | asBool (const switchType) |
| | Return a bool representation of a switchType.
|
| static bool | asBool (const std::string &, const bool allowInvalid=false) |
| | Return a bool representation of a word.
|
| static const char * | asText (const bool) |
| | Return a text representation of a bool value.
|
| static const char * | asText (const switchType) |
| | Return a text representation of a switchType.
|
| static Switch | lookupOrAddToDict (const word &, dictionary &, const Switch &defaultValue=false) |
| | Construct from dictionary, supplying default value so that if the.
|
Static Public Attributes |
| static const char * | names [INVALID+1] |
| | The set of names corresponding to the switchType enumeration.
|
Friends |
| Istream & | operator>> (Istream &, Switch &) |
| Ostream & | operator<< (Ostream &, const Switch &) |
Detailed Description
A simple wrapper around bool so that it can be read as a word: true/false, on/off, yes/no or y/n or none.
- Source files
-
Definition at line 56 of file Switch.H.
Member Enumeration Documentation
The various text representations for a switch value.
These also correspond to the entries in names. - Enumerator:
-
| FALSE |
|
| TRUE |
|
| OFF |
|
| ON |
|
| NO |
|
| YES |
|
| NO_1 |
|
| YES_1 |
|
| NONE |
|
| PLACEHOLDER |
|
| INVALID |
|
Definition at line 73 of file Switch.H.
Constructor & Destructor Documentation
Construct null as false.
Definition at line 131 of file Switch.H.
| Switch |
( |
const bool |
value |
) |
[inline] |
Construct from bool.
Definition at line 137 of file Switch.H.
| Switch |
( |
const int |
value |
) |
[inline] |
Construct from integer values (treats integer as bool value).
Definition at line 143 of file Switch.H.
| Switch |
( |
const std::string & |
value |
) |
[inline] |
| Switch |
( |
const char * |
value |
) |
[inline] |
Construct from character array.
Definition at line 155 of file Switch.H.
Member Function Documentation
Return a switchType representation of a bool.
Definition at line 39 of file Switch.C.
Return a bool representation of a switchType.
Definition at line 82 of file Switch.C.
| bool asBool |
( |
const std::string & |
str, |
|
|
const bool |
allowInvalid = false | |
|
) |
| | [static] |
Return a bool representation of a word.
Optionally allow bad words, and catch the error elsewhere
Definition at line 90 of file Switch.C.
| const char * asText |
( |
const bool |
b |
) |
[static] |
Return a text representation of a bool value.
Definition at line 115 of file Switch.C.
| const char * asText |
( |
const switchType |
sw |
) |
[static] |
Return a text representation of a switchType.
Definition at line 121 of file Switch.C.
| operator bool |
( |
|
) |
const [inline] |
| const Switch& operator= |
( |
const bool |
b |
) |
[inline] |
Assignment from bool.
Definition at line 184 of file Switch.H.
Friends And Related Function Documentation
Member Data Documentation
const char * names [static] |
Initial value:
{
"false", "true",
"off", "on",
"no", "yes",
"n", "y",
"none", "true",
"invalid"
}
The set of names corresponding to the switchType enumeration.
Includes an extra entry for "invalid".
Definition at line 90 of file Switch.H.
Referenced by Switch::lookupOrAddToDict().
The documentation for this class was generated from the following files:
- src/OpenFOAM/primitives/bools/Switch/Switch.H
- src/OpenFOAM/primitives/bools/Switch/Switch.C
- src/OpenFOAM/primitives/bools/Switch/SwitchIO.C
Copyright © 2000-2009 OpenCFD Ltd
|