Go to the documentation of this file.
71 Ostream&
operator<<(Ostream& is,
const Switch& sw);
103 unsigned char value_;
110 static switchType parse(
const std::string&
str,
const bool failOnError);
127 constexpr
Switch() noexcept
139 constexpr
Switch(
const bool b) noexcept
141 value_(
b ? switchType::TRUE : switchType::FALSE)
145 constexpr
Switch(
const int i) noexcept
147 value_(i ? switchType::TRUE : switchType::FALSE)
160 explicit Switch(
const float val,
const float tol=0.5);
164 explicit Switch(
const double val,
const double tol=0.5);
187 const bool failsafe =
false
202 const Switch deflt = switchType::FALSE
209 static const char*
name(
const bool b) noexcept;
216 static bool found(
const std::string&
str);
222 bool good() const noexcept;
225 bool bad() const noexcept {
return !
good(); }
231 const
char*
c_str() const noexcept;
234 std::
string str() const;
247 operator
bool() const noexcept
249 return (value_ & 0x1);
272 Switch(const std::
string&
str,
bool allowBad);
282 bool valid() const noexcept
292 const Switch deflt = switchType::FALSE
Switch & operator=(const Switch &) noexcept=default
Copy assignment.
A simple wrapper around bool so that it can be read as a word: true/false, on/off,...
A class for handling words, derived from Foam::string.
static Switch lookupOrAddToDict(const word &name, dictionary &dict, const Switch deflt=switchType::FALSE)
Same as getOrAddToDict()
Switch & operator=(const switchType sw) noexcept
Assignment from enumerated value.
Switch & operator=(const bool b) noexcept
Assignment from bool.
std::string str() const
A string representation of the Switch value.
Istream & operator>>(Istream &, directionInfo &)
A token holds an item read from Istream.
constexpr Switch(const int i) noexcept
Construct from int (treat integer as bool value)
bool good() const noexcept
True if the Switch represents a valid enumeration.
FOAM_DEPRECATED_FOR(2019-02, "good() or static found() method") bool valid() const noexcept
Deprecated(2020-01) Use good() method, or static found() method.
static Switch find(const std::string &str)
constexpr Switch(const switchType sw) noexcept
Construct from enumerated value.
bool readIfPresent(const word &key, const dictionary &dict)
Update the value of the Switch if it is found in the dictionary.
static bool found(const std::string &str)
Test if there is a switch type corresponding to the given string.
Ostream & operator<<(Ostream &, const boundaryPatch &p)
Write boundaryPatch as dictionary entries (without surrounding braces)
const dimensionedScalar b
Wien displacement law constant: default SI units: [m.K].
An Istream is an abstract base class for all input systems (streams, files, token lists etc)....
const char * c_str() const noexcept
A C-string representation of the Switch value.
static const char * name(const bool b) noexcept
A string representation of bool as "false" / "true".
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
switchType type() const noexcept
The underlying enumeration value.
constexpr Switch() noexcept
Default construct as false.
constexpr Switch(const bool b) noexcept
Construct from bool.
bool bad() const noexcept
True if the Switch does not represent a valid enumeration.
switchType
Switch enumerations corresponding to common text representations.
static Switch getOrAddToDict(const word &key, dictionary &dict, const Switch deflt=switchType::FALSE)