A polymorphic typed union of simple primitive and VectorSpace types. It uses a 'fatter' representation that includes standard VectorSpace types, which avoids heap allocations at the expense of more storage. This is mostly not an issue since lists and fields would box/unbox an entire field, not individual values. More...
Public Member Functions | |
| exprValue () | |
| Default construct (zero-initialized) as 'none'. More... | |
| exprValue (const exprValue &rhs) | |
| Copy construct (deep copy) More... | |
| template<class Type > | |
| exprValue (const Type &val) | |
| Construct from Type. Fatal for unsupported types. More... | |
| expressions::valueTypeCode | typeCode () const noexcept |
| The value type code. More... | |
| bool | good () const noexcept |
| True if the value type is not none/invalid. More... | |
| bool | is_integral () const noexcept |
| True if the value type is an integral (bool or label) More... | |
| direction | nComponents () const noexcept |
| The number of components associated with the value type. More... | |
| direction | rank () const noexcept |
| The vector-space rank associated with the value type. More... | |
| word | valueTypeName () const |
| The name for the value type. Similar to pTraits typeName. More... | |
| word | listCompoundName () const |
The name for the compound token (for a List of values). Eg, List<scalar>, List<vector> ... More... | |
| void | clear () |
| Reset to 'none'. More... | |
| bool | read (Istream &is) |
| Read read tokens (if possible) More... | |
| bool | readTokens (ITstream &is) |
| Guess type and read tokens (if possible) More... | |
| int | compare (const exprValue &rhs) const |
| Compare (type,value) More... | |
| template<class Type > | |
| const Type * | isA () const noexcept |
| Return non-null pointer to the data element (if types match). Can also be tested as a bool. More... | |
| template<class Type > | |
| bool | set (const Type &val) |
| Assign from type. Returns false and sets to 'none' for unsupported types. More... | |
| template<class Type > | |
| const Type & | get () const |
| Return the value. Return pTraits zero if the types mismatch. More... | |
| bool | is_scalar () const noexcept |
| void | operator= (const scalar &val) |
| bool | is_vector () const noexcept |
| void | operator= (const vector &val) |
| bool | is_tensor () const noexcept |
| void | operator= (const tensor &val) |
| bool | is_symmTensor () const noexcept |
| void | operator= (const symmTensor &val) |
| bool | is_sphericalTensor () const noexcept |
| void | operator= (const sphericalTensor &val) |
| bool | is_label () const noexcept |
| void | operator= (const label &val) |
| bool | is_bool () const noexcept |
| void | operator= (const bool &val) |
| void | operator= (const exprValue &rhs) |
| Copy assignment. More... | |
| void | operator= (const Foam::zero) |
| Assign from zero. Changes value but not type. More... | |
| const char * | cdata_bytes () const noexcept |
| Pointer to the data content as byte data. More... | |
| char * | data_bytes () noexcept |
| Pointer to the data content as byte data. More... | |
| bool | operator== (const exprValue &rhs) const |
| Compare (type,value) for equality. More... | |
| bool | operator!= (const exprValue &rhs) const |
| Compare (type,value) for inequality. More... | |
| bool | operator< (const exprValue &rhs) const |
| Compare (type,value) More... | |
| InfoProxy< exprValue > | info () const |
| Return info proxy for printing information to a stream. More... | |
| void | write (Ostream &os, bool prune=false) const |
| Write the (type-specific) content. More... | |
Static Public Member Functions | |
| static bool | good (const expressions::valueTypeCode) noexcept |
| True if valueTypeCode is not none/invalid. More... | |
| static bool | is_integral (const expressions::valueTypeCode) noexcept |
| True if valueTypeCode is bool/label. More... | |
| static direction | nComponents (const expressions::valueTypeCode) noexcept |
| The number of components associated with the valueTypeCode. More... | |
| static direction | rank (const expressions::valueTypeCode) noexcept |
| The vector-space rank associated with the valueTypeCode. More... | |
| template<class Type > | |
| static bool | supportedType () |
| True if the specified type is supported. More... | |
| static expressions::valueTypeCode | peekType (const ITstream &is) |
| Detect the type from the available tokens. More... | |
| static bool | read (const std::string &str, exprValue &val) |
| Read entire string as a exprValue, skipping leading/trailing whitespace. More... | |
| static constexpr unsigned | size_bytes () noexcept |
| Size of the (contiguous) data content as byte data is compile-time constant. More... | |
A polymorphic typed union of simple primitive and VectorSpace types. It uses a 'fatter' representation that includes standard VectorSpace types, which avoids heap allocations at the expense of more storage. This is mostly not an issue since lists and fields would box/unbox an entire field, not individual values.
Forward declarations for Foam::expressions::exprValue etc.
Definition at line 157 of file exprValue.H.
|
inline |
Default construct (zero-initialized) as 'none'.
Definition at line 92 of file exprValueI.H.
References clear().

Copy construct (deep copy)
Definition at line 98 of file exprValueI.H.
|
inlineexplicit |
Construct from Type. Fatal for unsupported types.
Definition at line 105 of file exprValueI.H.
References Foam::abort(), clear(), Foam::FatalError, FatalErrorInFunction, Foam::name(), and Foam::nl.

|
inlinestaticnoexcept |
True if valueTypeCode is not none/invalid.
Definition at line 26 of file exprValueI.H.
|
inlinestaticnoexcept |
True if valueTypeCode is bool/label.
Definition at line 39 of file exprValueI.H.
|
inlinestaticnoexcept |
The number of components associated with the valueTypeCode.
Definition at line 52 of file exprValueI.H.
References Foam::expressions::Detail::nComponents().

|
inlinestaticnoexcept |
The vector-space rank associated with the valueTypeCode.
Definition at line 61 of file exprValueI.H.
References Foam::expressions::Detail::rank().

|
inlinestatic |
True if the specified type is supported.
Definition at line 70 of file exprValueI.H.
References Foam::expressions::INVALID.
|
static |
Detect the type from the available tokens.
Possible ambiguity between label and scalar.
InfoErr << "check token: " << (endCmpti-firstCmpti) << " : " << is[endCmpti].name() << nl;
InfoErr<< "check token: " << tok0.info() << nl;
Definition at line 150 of file exprValue.C.
References token::BEGIN_LIST, token::END_LIST, Switch::good(), token::good(), ITstream::hasPutback(), Foam::expressions::INVALID, token::isLabel(), token::isNumber(), token::isPunctuation(), token::isScalar(), Foam::expressions::NONE, ITstream::peek(), UList< T >::size(), and ITstream::tokenIndex().
Referenced by exprValue::readTokens().


|
static |
Read entire string as a exprValue, skipping leading/trailing whitespace.
Definition at line 248 of file exprValue.C.
References ITstream::nRemainingTokens(), and exprValue::readTokens().
Referenced by Foam::operator>>().


|
inlinenoexcept |
The value type code.
Definition at line 270 of file exprValue.H.
|
inlinenoexcept |
True if the value type is not none/invalid.
Definition at line 123 of file exprValueI.H.
|
inlinenoexcept |
True if the value type is an integral (bool or label)
Definition at line 129 of file exprValueI.H.
|
inlinenoexcept |
The number of components associated with the value type.
Definition at line 136 of file exprValueI.H.
References Foam::expressions::Detail::nComponents().

|
inlinenoexcept |
The vector-space rank associated with the value type.
Definition at line 143 of file exprValueI.H.
References Foam::expressions::Detail::rank().

|
inline |
The name for the value type. Similar to pTraits typeName.
Definition at line 150 of file exprValueI.H.
References Foam::name().

|
inline |
The name for the compound token (for a List of values). Eg, List<scalar>, List<vector> ...
Definition at line 156 of file exprValueI.H.
References Foam::name().

| void clear | ( | ) |
Reset to 'none'.
Definition at line 262 of file exprValue.C.
| bool read | ( | Istream & | is | ) |
Read read tokens (if possible)
Definition at line 389 of file exprValue.C.
References ITstream::add_tokens(), token::BEGIN_LIST, token::END_LIST, IOstream::fatalCheck(), FUNCTION_NAME, token::good(), token::isPunctuation(), List< T >::resize(), ITstream::seek(), and ITstream::tokenIndex().

| bool readTokens | ( | ITstream & | is | ) |
Guess type and read tokens (if possible)
Definition at line 438 of file exprValue.C.
References IOstream::bad(), clear(), doLocalCode, FOR_ALL_EXPR_VALUE_TYPES, Foam::expressions::INVALID, token::isWord(), Foam::expressions::NONE, ITstream::peek(), exprValue::peekType(), and ITstream::skip().
Referenced by exprValue::read().


| int compare | ( | const exprValue & | rhs | ) | const |
Compare (type,value)
Definition at line 487 of file exprValue.C.
References doLocalCode, and FOR_ALL_EXPR_VALUE_TYPES.
|
inlinenoexcept |
Return non-null pointer to the data element (if types match). Can also be tested as a bool.
Definition at line 209 of file exprValueI.H.
|
inline |
Assign from type. Returns false and sets to 'none' for unsupported types.
Definition at line 169 of file exprValueI.H.
References clear(), Foam::expressions::INVALID, and Foam::expressions::NONE.
Referenced by exprValueFieldTag::set(), exprValueFieldTag::set_value(), and exprValueFieldTag::set_zero().


|
inline |
Return the value. Return pTraits zero if the types mismatch.
Definition at line 191 of file exprValueI.H.
|
inlinenoexcept |
True if value is a scalar
Definition at line 368 of file exprValue.H.
|
inline |
Assign from scalar
Definition at line 368 of file exprValue.H.
|
inlinenoexcept |
True if value is a vector
Definition at line 368 of file exprValue.H.
|
inline |
Assign from vector
Definition at line 368 of file exprValue.H.
|
inlinenoexcept |
True if value is a tensor
Definition at line 368 of file exprValue.H.
|
inline |
Assign from tensor
Definition at line 368 of file exprValue.H.
|
inlinenoexcept |
True if value is a symmTensor
Definition at line 368 of file exprValue.H.
|
inline |
Assign from symmTensor
Definition at line 368 of file exprValue.H.
|
inlinenoexcept |
True if value is a sphericalTensor
Definition at line 368 of file exprValue.H.
|
inline |
Assign from sphericalTensor
Definition at line 368 of file exprValue.H.
|
inlinenoexcept |
True if value is a label
Definition at line 368 of file exprValue.H.
|
inline |
Assign from label
Definition at line 368 of file exprValue.H.
|
inlinenoexcept |
True if value is a bool
Definition at line 368 of file exprValue.H.
|
inline |
Assign from bool
Definition at line 368 of file exprValue.H.
|
inline |
Copy assignment.
Definition at line 374 of file exprValue.H.
|
inline |
Assign from zero. Changes value but not type.
Definition at line 379 of file exprValue.H.
|
inlinenoexcept |
Pointer to the data content as byte data.
Definition at line 387 of file exprValue.H.
|
inlinenoexcept |
Pointer to the data content as byte data.
Definition at line 395 of file exprValue.H.
|
inlinestaticnoexcept |
Size of the (contiguous) data content as byte data is compile-time constant.
Definition at line 404 of file exprValue.H.
| bool operator== | ( | const exprValue & | rhs | ) | const |
Compare (type,value) for equality.
Definition at line 540 of file exprValue.C.
References doLocalCode, and FOR_ALL_EXPR_VALUE_TYPES.
|
inline |
Compare (type,value) for inequality.
Definition at line 420 of file exprValue.H.
| bool operator< | ( | const exprValue & | rhs | ) | const |
Compare (type,value)
Definition at line 576 of file exprValue.C.
Return info proxy for printing information to a stream.
Definition at line 433 of file exprValue.H.
| void write | ( | Ostream & | os, |
| bool | prune = false |
||
| ) | const |
Write the (type-specific) content.
For none : emits pair of brackets. For invalid : emits "bad".
Use OTstream for the stream to recover as tokens.
| prune | suppress the output for none/invalid |
Definition at line 338 of file exprValue.C.
References token::BEGIN_LIST, doLocalCode, token::END_LIST, FOR_ALL_EXPR_VALUE_TYPES, Foam::expressions::INVALID, Foam::expressions::NONE, and os().
Referenced by Foam::operator<<().

