Go to the documentation of this file.
41 "Switch::switchType does not have 9 entries"
46 static 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
99 case '0':
case 'f':
return switchType::FALSE;
100 case '1':
case 't':
return switchType::TRUE;
101 case 'n':
return switchType::NO;
102 case 'y':
return switchType::YES;
108 if (
str ==
names[switchType::NO])
return switchType::NO;
109 if (
str ==
names[switchType::ON])
return switchType::ON;
114 if (
str ==
names[switchType::OFF])
return switchType::OFF;
115 if (
str ==
names[switchType::YES])
return switchType::YES;
116 if (
str ==
names[switchType::ANY])
return switchType::ANY;
121 if (
str ==
names[switchType::NONE])
return switchType::NONE;
122 if (
str ==
names[switchType::TRUE])
return switchType::TRUE;
127 if (
str ==
names[switchType::FALSE])
return switchType::FALSE;
135 <<
"Unknown switch " <<
str <<
nl
139 return switchType::INVALID;
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))
214 value_(switchType::INVALID)
240 value_(switchType::INVALID)
281 <<
"using failsafe " << deflt.
c_str() <<
endl;
302 return (value_ < switchType::INVALID);
314 if (value_ < switchType::INVALID)
330 return names[(value_ & 0x0F)];
A simple wrapper around bool so that it can be read as a word: true/false, on/off,...
bool isLabel() const noexcept
A class for handling words, derived from Foam::string.
bool isBool() const noexcept
T getOrAdd(const word &keyword, const T &deflt, enum keyType::option matchOpt=keyType::REGEX)
auto key(const Type &t) -> typename std::enable_if< std::is_enum< Type >::value, typename std::underlying_type< Type >::type >::type
Istream & operator>>(Istream &, directionInfo &)
Ostream & endl(Ostream &os)
A token holds an item read from Istream.
T get(const word &keyword, enum keyType::option matchOpt=keyType::REGEX) const
bool good() const noexcept
static Switch find(const std::string &str)
bool readIfPresent(const word &key, const dictionary &dict)
static bool found(const std::string &str)
bool isWord() const noexcept
Ostream & operator<<(Ostream &, const boundaryPatch &p)
const dimensionedScalar b
InfoProxy< token > info() const
An Istream is an abstract base class for all input systems (streams, files, token lists etc)....
const char * c_str() const noexcept
static const char * name(const bool b) noexcept
virtual bool check(const char *operation) const
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
static OS & printTokenError(OS &os, const token &tok)
OBJstream os(runTime.globalPath()/outputName)
errorManip< error > abort(error &err)
const word & wordToken() const
errorManipArg< error, int > exit(error &err, const int errNo=1)
switchType type() const noexcept
bool good() const noexcept
#define FatalErrorInFunction
dimensioned< typename typeOfMag< Type >::type > mag(const dimensioned< Type > &dt)
constexpr Switch() noexcept
#define FatalIOErrorInFunction(ios)
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
#define IOWarningInFunction(ios)
List< word > names(const UPtrList< T > &list, const UnaryMatchPredicate &matcher)
bool readIfPresent(const word &keyword, T &val, enum keyType::option matchOpt=keyType::REGEX) const
static Switch getOrAddToDict(const word &key, dictionary &dict, const Switch deflt=switchType::FALSE)