42#ifndef Foam_expressions_exprValue_H
43#define Foam_expressions_exprValue_H
53#undef FOR_ALL_EXPR_VALUE_TYPES
54#define FOR_ALL_EXPR_VALUE_TYPES(Macro, ...) \
55 Macro(scalar, __VA_ARGS__) \
56 Macro(vector, __VA_ARGS__) \
57 Macro(tensor, __VA_ARGS__) \
58 Macro(symmTensor, __VA_ARGS__) \
59 Macro(sphericalTensor, __VA_ARGS__) \
60 Macro(label, __VA_ARGS__) \
61 Macro(bool, __VA_ARGS__)
87 #undef declareUnionMember
88 #define declareUnionMember(Type, UnusedParam) \
94 #undef declareUnionMember
108 inline const Type*
get() const
noexcept {
return nullptr; }
112 inline void set(
const Type& val)
noexcept
122#undef defineMultiTypeValueUnionMethods
123#define defineMultiTypeValueUnionMethods(Type, UnusedParam) \
127inline const Type* exprValueUnion::get<Type>() const noexcept \
129 return &(Type##Value); \
134inline void exprValueUnion::set<Type>(const Type& val) noexcept \
141#undef defineMultiTypeValueUnionMethods
166 inline void fill_zero();
183 inline explicit exprValue(
const Type& val);
189 inline static bool good
282 inline
bool set(const Type& val);
286 inline const Type&
get() const;
291 #undef defineUnionMethods
292 #define defineUnionMethods(Type, UnusedParam) \
295 bool is_##Type() const noexcept \
297 return (typeCode_ == exprTypeTraits<Type>::value); \
301 void operator=(const Type& val) { this->set<Type>(val); }
304 #undef defineUnionMethods
319 return reinterpret_cast<const char*
>(
this);
325 return reinterpret_cast<char*
>(
this);
351 InfoProxy<exprValue>
info()
const {
return *
this; }
360 void write(Ostream&
os,
bool prune =
false)
const;
An input stream of tokens.
A helper class for outputting values to Ostream.
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 polymorphic typed union of simple primitive and VectorSpace types. It uses a 'fatter' representatio...
void operator=(Foam::zero)
Assign from zero. Changes value but not type.
exprValue()
Default construct (zero-initialized) as 'none'.
bool set(const Type &val)
Assign from type. Returns false and sets to 'none' for unsupported types.
bool is_integral() const noexcept
True if the value type is an integral (bool or label).
const Type & get() const
Return the value. Return pTraits zero if the types mismatch.
char * data_bytes() noexcept
Pointer to the data content as byte data.
InfoProxy< exprValue > info() const
Return info proxy for printing information to a stream.
bool operator!=(const exprValue &rhs) const
Compare (type,value) for inequality.
word listCompoundName() const
The name for the compound token (for a List of values). Eg, List<scalar>, List<vector> ....
static expressions::valueTypeCode peekType(const ITstream &is)
Detect the type from the available tokens.
int compare(const exprValue &rhs) const
Compare (type,value).
bool good() const noexcept
True if the value type is not none/invalid.
static bool supportedType()
True if the specified type is supported.
void operator=(const scalar &val)
const Type * isA() const noexcept
Return non-null pointer to the data element (if types match). Can also be tested as a bool.
expressions::valueTypeCode typeCode() const noexcept
The value type code.
static bool read(const std::string &str, exprValue &val)
Read entire string as a exprValue, skipping leading/trailing whitespace.
bool readTokens(ITstream &is)
Guess type and read tokens (if possible).
word valueTypeName() const
The name for the value type. Similar to pTraits typeName.
direction nComponents() const noexcept
The number of components associated with the value type.
direction rank() const noexcept
The vector-space rank associated with the value type.
bool operator==(const exprValue &rhs) const
Compare (type,value) for equality.
const char * cdata_bytes() const noexcept
Pointer to the data content as byte data.
void operator=(const exprValue &rhs)
Copy assignment.
static constexpr unsigned size_bytes() noexcept
Size of the (contiguous) data content as byte data is compile-time constant.
bool operator<(const exprValue &rhs) const
Compare (type,value).
A class for handling words, derived from Foam::string.
A class representing the concept of 0 (zero) that can be used to avoid manipulating objects known to ...
#define defineMultiTypeValueUnionMethods(Type, UnusedParam)
#define defineUnionMethods(Type, UnusedParam)
#define FOR_ALL_EXPR_VALUE_TYPES(Macro,...)
#define declareUnionMember(Type, UnusedParam)
OBJstream os(runTime.globalPath()/outputName)
A namespace for expression-related classes/traits etc.
valueTypeCode
An enumeration of known and expected expression value types.
@ NONE
No type, or default initialized type.
bool read(const char *buf, int32_t &val)
Same as readInt32.
Ostream & operator<<(Ostream &, const boundaryPatch &p)
Write boundaryPatch as dictionary entries (without surrounding braces).
const Type * isA(const U &obj)
Attempt dynamic_cast to Type.
Istream & operator>>(Istream &, directionInfo &)
void rhs(fvMatrix< typename Expr::value_type > &m, const Expr &expression)
A template class to specify that a data type can be considered as being contiguous in memory.
The data content (as a union).
const Type * get() const noexcept
Return read pointer to typed union member, which is nullptr for unspecialized versions.
void set(const Type &val) noexcept
No generic set(), only specialized methods.
static void notSpecialized(const std::string &msg) noexcept
Runtime 'assert' for unimplemented generic methods.