72 Ostream&
operator<<(Ostream& is,
const Switch sw);
104 unsigned char value_;
111 static switchType parse(
const std::string&
str,
const bool failOnError);
142 value_(
b ? switchType::TRUE : switchType::FALSE)
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 warnOnly =
false 202 const Switch deflt = switchType::FALSE
211 const Switch deflt = switchType::FALSE
262 return (value_ & 0x1);
void negate() noexcept
Flip the type, so OFF becomes ON, etc.
bool good() const noexcept
True if the Switch represents a valid enumeration.
static bool contains(const std::string &str)
True if there is a switch type corresponding to the given string.
std::string str() const
A string representation of the Switch value.
switchType
Switch enumerations corresponding to common text representations.
bool bad() const noexcept
True if the Switch does not represent a valid enumeration.
A list of keyword definitions, which are a keyword followed by a number of values (eg...
const char * c_str() const noexcept
A C-string representation of the Switch value.
An Istream is an abstract base class for all input systems (streams, files, token lists etc)...
A token holds an item read from Istream.
A simple wrapper around bool so that it can be read as a word: true/false, on/off, yes/no, any/none. Also accepts 0/1 as a string and shortcuts t/f, y/n.
static Switch getOrDefault(const word &key, const dictionary &dict, const Switch deflt=switchType::FALSE)
Construct Switch from dictionary, with default value.
static Switch getOrAddToDict(const word &key, dictionary &dict, const Switch deflt=switchType::FALSE)
Construct from dictionary, supplying default value so that if the value is not found, it is added into the dictionary.
static bool found(const std::string &str)
Same as contains()
static const char * name(const bool b) noexcept
A string representation of bool as "false" / "true".
constexpr Switch(const bool b) noexcept
Implicit construct from bool.
const dimensionedScalar b
Wien displacement law constant: default SI units: [m.K].
A class for handling words, derived from Foam::string.
Istream & operator>>(Istream &, directionInfo &)
#define FOAM_DEPRECATED_STRICT(since, replacement)
constexpr Switch() noexcept
Default construct as false.
switchType type() const noexcept
The underlying enumeration value.
Ostream & operator<<(Ostream &, const boundaryPatch &p)
Write boundaryPatch as dictionary entries (without surrounding braces)
auto key(const Type &t) -> typename std::enable_if< std::is_enum< Type >::value, typename std::underlying_type< Type >::type >::type
FOAM_DEPRECATED_FOR(2019-02, "good() or static contains() method") bool valid() const noexcept
Deprecated(2020-01) Use good() method, or static contains() method.
Includes some standard C++ headers, defines global macros and templates used in multiple places by Op...
Switch & operator=(const Switch &) noexcept=default
Copy assignment.
static Switch lookupOrAddToDict(const word &name, dictionary &dict, const Switch deflt=switchType::FALSE)
Same as getOrAddToDict()
constexpr Switch(const int i) noexcept
Implicit construct from int (treat integer as bool value)
bool readIfPresent(const word &key, const dictionary &dict)
Update the value of the Switch if it is found in the dictionary.
static Switch find(const std::string &str)
Find switchType for the given string, returning as a Switch that can be tested for good() or bad()...