Go to the documentation of this file.
42 "Switch::switchType does not have 9 entries"
47 static const char* names[9] =
62 return names[(
b ? 1 : 0)];
68 const std::string& str,
78 case 'f':
return switchType::FALSE;
79 case 'n':
return switchType::NO;
80 case 't':
return switchType::TRUE;
81 case 'y':
return switchType::YES;
87 if (
str == names[switchType::NO])
return switchType::NO;
88 if (
str == names[switchType::ON])
return switchType::ON;
93 if (
str == names[switchType::OFF])
return switchType::OFF;
94 if (
str == names[switchType::YES])
return switchType::YES;
95 if (
str == names[switchType::ANY])
return switchType::ANY;
100 if (
str == names[switchType::NONE])
return switchType::NONE;
101 if (
str == names[switchType::TRUE])
return switchType::TRUE;
106 if (
str == names[switchType::FALSE])
return switchType::FALSE;
114 <<
"Unknown switch word " <<
str <<
nl
118 return switchType::INVALID;
155 (*this) = parse(str,
true);
160 <<
"Expected 'true/false', 'on/off' ... found " << str <<
nl
181 (*this) = parse(str,
true);
188 <<
"Expected 'true/false', 'on/off' ... found " << str <<
nl
205 return switch_ != switchType::INVALID;
217 return names[(switch_ & 0x0F)];
223 return names[(switch_ & 0x0F)];
242 <<
"Bad token - could not get bool"
260 <<
"Expected 'true/false', 'on/off' ... found "
270 <<
"Wrong token type - expected bool, found "
A keyword and a list of tokens is an 'entry'.
label labelToken() const
Return label value.
label ListType::const_reference val
A simple wrapper around bool so that it can be read as a word: true/false, on/off,...
Useful combination of include files which define Sin, Sout and Serr and the use of IO streams general...
A class for handling words, derived from Foam::string.
T getOrAdd(const word &keyword, const T &deflt, enum keyType::option matchOpt=keyType::REGEX)
bool valid() const noexcept
True if the Switch represents a valid enumeration.
std::string str() const
A string representation of the Switch value.
Istream & operator>>(Istream &, directionInfo &)
A token holds an item read from Istream.
T get(const word &keyword, enum keyType::option matchOpt=keyType::REGEX) const
bool good() const
True if token is not UNDEFINED or ERROR.
bool isLabel() const
Token is LABEL.
const dimensionedScalar b
Wien displacement law constant: default SI units: [m.K].
InfoProxy< token > info() const
Return info proxy for printing token information to a stream.
An Istream is an abstract base class for all input systems (streams, files, token lists etc)....
word name(const complex &c)
Return string representation of complex.
const char * c_str() const noexcept
A string representation of the Switch value.
static const char * name(const bool b) noexcept
A string representation of bool as "false" / "true".
bool readIfPresent(const word &name, const dictionary &dict)
Update the value of the Switch if it is found in the dictionary.
virtual bool check(const char *operation) const
Check IOstream status for given operation.
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
bool isWord() const
Token is WORD.
errorManip< error > abort(error &err)
const word & wordToken() const
Return const reference to the word contents.
errorManipArg< error, int > exit(error &err, const int errNo=1)
switchType type() const noexcept
The underlying enumeration value.
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
dimensioned< typename typeOfMag< Type >::type > mag(const dimensioned< Type > &dt)
entry * findEntry(const word &keyword, enum keyType::option matchOpt=keyType::REGEX)
Find for an entry (non-const access) with the given keyword.
constexpr Switch() noexcept
Null constructible as false.
void setBad()
Set stream to be bad.
#define FatalIOErrorInFunction(ios)
Report an error message using Foam::FatalIOError.
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
switchType
Switch enumerations corresponding to common text representations.
static Switch getOrAddToDict(const word &name, dictionary &dict, const Switch deflt=switchType::FALSE)
Ostream & operator<<(Ostream &, const boundaryPatch &)
bool readIfPresent(const word &keyword, T &val, enum keyType::option matchOpt=keyType::REGEX) const