41 "Switch::switchType does not have 9 entries"
46static const char*
names[9] =
67 os <<
"Bad token - could not get bool/switch" <<
nl;
71 os <<
"Expected true/false, on/off... found "
76 os <<
"Wrong token - expected bool/switch, found "
89 const std::string& str,
90 const bool failOnError
135 <<
"Unknown switch " <<
str <<
nl
147 return names[(
b ? 1 : 0)];
153 return Switch(parse(str,
false));
159 return (switchType::INVALID != parse(str,
false));
178 value_(parse(str, true))
184 value_(parse(str, true))
190 value_(parse(str, !allowBad))
196 value_(parse(str, !allowBad))
281 <<
"using failsafe " << deflt.
c_str() <<
endl;
302 return (value_ < switchType::INVALID);
314 if (value_ < switchType::INVALID)
324 return names[(value_ & 0x0F)];
330 return names[(value_ & 0x0F)];
virtual bool check(const char *operation) const
Check IOstream status for given operation.
void setBad()
Set stream state to be 'bad'.
An Istream is an abstract base class for all input systems (streams, files, token lists etc)....
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
A simple wrapper around bool so that it can be read as a word: true/false, on/off,...
switchType
Switch enumerations corresponding to common text representations.
void negate() noexcept
Flip the type, so OFF becomes ON, etc.
bool readIfPresent(const word &key, const dictionary &dict)
Update the value of the Switch if it is found in the dictionary.
constexpr Switch() noexcept
Default construct as false.
bool good() const noexcept
True if the Switch represents a valid enumeration.
switchType type() const noexcept
The underlying enumeration value.
static Switch getOrAddToDict(const word &key, dictionary &dict, const Switch deflt=switchType::FALSE)
static Switch find(const std::string &str)
const char * c_str() const noexcept
A C-string representation of the Switch value.
std::string str() const
A string representation of the Switch value.
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
T get(const word &keyword, enum keyType::option matchOpt=keyType::REGEX) const
bool readIfPresent(const word &keyword, T &val, enum keyType::option matchOpt=keyType::REGEX) const
T getOrAdd(const word &keyword, const T &deflt, enum keyType::option matchOpt=keyType::REGEX)
A token holds an item read from Istream.
bool isBool() const noexcept
Token is BOOL.
bool isLabel() const noexcept
Token is LABEL.
bool good() const noexcept
True if token is not UNDEFINED or ERROR.
label labelToken() const
Return label value.
InfoProxy< token > info() const
Return info proxy for printing token information to a stream.
bool boolToken() const
Return boolean token value.
const word & wordToken() const
Return const reference to the word contents.
bool isWord() const noexcept
Token is word-variant (WORD, DIRECTIVE)
A class for handling words, derived from Foam::string.
#define FatalIOErrorInFunction(ios)
Report an error message using Foam::FatalIOError.
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
OBJstream os(runTime.globalPath()/outputName)
#define IOWarningInFunction(ios)
Report an IO warning using Foam::Warning.
List< word > names(const UPtrList< T > &list, const UnaryMatchPredicate &matcher)
Ostream & operator<<(Ostream &, const boundaryPatch &p)
Write boundaryPatch as dictionary entries (without surrounding braces)
Ostream & endl(Ostream &os)
Add newline and flush stream.
dimensioned< typename typeOfMag< Type >::type > mag(const dimensioned< Type > &dt)
Istream & operator>>(Istream &, directionInfo &)
errorManip< error > abort(error &err)
static OS & printTokenError(OS &os, const token &tok)
errorManipArg< error, int > exit(error &err, const int errNo=1)
constexpr char nl
The newline '\n' character (0x0a)