106 unsigned char value_;
113 static switchType parse(
const char*
s,
size_t len)
noexcept;
157 explicit Switch(
const char*
s);
161 explicit Switch(
const std::string&
s);
165 explicit Switch(std::string_view
s);
169 explicit Switch(
const float val,
const float tol=0.5);
173 explicit Switch(
const double val,
const double tol=0.5);
196 const bool warnOnly =
false
226 static const char*
name(
bool b)
noexcept;
229 static bool contains(std::string_view
s)
noexcept;
293 return (value_ & 0x1);
319 Switch(const std::
string&
str,
bool allowBad);
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.
static Switch find(std::string_view s) noexcept
Find switchType for the given string, returning a Switch that can be tested for good() or bad().
static Switch lookupOrAddToDict(const word &name, dictionary &dict, const Switch deflt=switchType::FALSE)
Same as getOrAddToDict().
FOAM_DEPRECATED_FOR(2019-02, "good() or static contains() method") bool valid() const noexcept
Deprecated(2020-01) Use good() method, or static contains() method.
static Switch getOrDefault(const word &key, const dictionary &dict, const Switch deflt=switchType::FALSE)
Construct Switch from dictionary, with default value.
static Switch find(const std::string &s) noexcept
Find switchType for the given string, returning a Switch that can be tested for good() or bad().
static bool contains(std::string_view s) noexcept
True if there is a switch type corresponding to the given string.
constexpr Switch(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.
constexpr Switch() noexcept
Default construct as false.
Switch(const char *s)
Construct from character array - catches bad input.
Switch(const double val, const double tol=0.5)
Construct from double with rounding to zero given by the tolerance (default: 0.5).
bool good() const noexcept
True if the Switch represents a valid enumeration.
Switch(Istream &is)
Construct from Istream by reading a token.
bool bad() const noexcept
True if the Switch does not represent a valid enumeration.
Switch(std::string_view s)
Construct from string_view - catches bad input.
bool is_any() const noexcept
Test for 'any' type.
constexpr Switch(switchType sw) noexcept
Implicit construct from enumerated 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,...
static Switch find(const char *s)
Find switchType for the given string, returning a Switch that can be tested for good() or bad().
Switch & operator=(bool b) noexcept
Assignment from bool.
switchType type() const noexcept
The underlying enumeration value.
static bool found(const std::string &str)
Same as contains().
Switch(const word &key, const dictionary &dict, const Switch deflt, const bool warnOnly=false)
Find the key in the dictionary and use the corresponding switch value or the default if not found in ...
Switch(const token &tok)
Construct from token. Handles bool/label/word types.
bool is_none() const noexcept
Test for 'none' type.
Switch & operator=(const Switch &) noexcept=default
Copy assignment.
Switch & operator=(switchType sw) noexcept
Assignment from enumerated value.
constexpr Switch(bool b) noexcept
Implicit construct from bool.
const char * c_str() const noexcept
A C-string representation of the Switch value.
Switch(const float val, const float tol=0.5)
Construct from float with rounding to zero given by the tolerance (default: 0.5).
Switch(const std::string &s)
Construct from string - catches bad input.
Switch(const word &key, const dictionary &dict)
Construct from dictionary lookup.
std::string str() const
A string representation of the Switch value.
static const char * name(bool b) noexcept
A string representation of bool as "false" / "true".
Switch(const Switch &) noexcept=default
Copy construct.
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
A token holds an item read from Istream.
A class for handling words, derived from Foam::string.
gmvFile<< "tracers "<< particles.size()<< nl;for(const passiveParticle &p :particles){ gmvFile<< p.position().x()<< " ";}gmvFile<< nl;for(const passiveParticle &p :particles){ gmvFile<< p.position().y()<< " ";}gmvFile<< nl;for(const passiveParticle &p :particles){ gmvFile<< p.position().z()<< " ";}gmvFile<< nl;forAll(lagrangianScalarNames, i){ word name=lagrangianScalarNames[i];IOField< scalar > s(IOobject(name, runTime.timeName(), cloud::prefix, mesh, IOobject::MUST_READ, IOobject::NO_WRITE))
Ostream & operator<<(Ostream &, const boundaryPatch &p)
Write boundaryPatch as dictionary entries (without surrounding braces).
Istream & operator>>(Istream &, directionInfo &)
Includes some common C++ headers, defines global macros and templates used in multiple places by Open...
#define FOAM_DEPRECATED_FOR(since, replacement)
#define FOAM_DEPRECATED_STRICT(since, replacement)