Go to the documentation of this file.
72 Ostream&
operator<<(Ostream& is,
const Switch& sw);
104 unsigned char value_;
111 static switchType parse(
const std::string&
str,
const bool failOnError);
128 constexpr
Switch() noexcept
140 constexpr
Switch(
const bool b) noexcept
142 value_(
b ? switchType::TRUE : switchType::FALSE)
146 constexpr
Switch(
const int i) noexcept
148 value_(i ? switchType::TRUE : switchType::FALSE)
161 explicit Switch(
const float val,
const float tol=0.5);
165 explicit Switch(
const double val,
const double tol=0.5);
188 const bool failsafe =
false
203 const Switch deflt = switchType::FALSE
210 static const char*
name(
const bool b) noexcept;
217 static bool found(
const std::string&
str);
223 bool good() const noexcept;
226 bool bad() const noexcept {
return !
good(); }
236 const
char*
c_str() const noexcept;
239 std::
string str() const;
252 operator
bool() const noexcept
254 return (value_ & 0x1);
277 Switch(const std::
string&
str,
bool allowBad);
287 bool valid() const noexcept
297 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.
auto key(const Type &t) -> typename std::enable_if< std::is_enum< Type >::value, typename std::underlying_type< Type >::type >::type
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.
void negate() noexcept
Flip the type, so OFF becomes ON, etc.
static Switch getOrAddToDict(const word &key, dictionary &dict, const Switch deflt=switchType::FALSE)