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...
#include <exprValue.H>
Public Member Functions | |
| exprValue () | |
| Default construct (zero-initialized) as 'none'. | |
| exprValue (const exprValue &rhs) | |
| Copy construct (deep copy). | |
| template<class Type> | |
| exprValue (const Type &val) | |
| Construct from Type. Fatal for unsupported types. | |
| expressions::valueTypeCode | typeCode () const noexcept |
| The value type code. | |
| bool | good () const noexcept |
| True if the value type is not none/invalid. | |
| bool | is_integral () const noexcept |
| True if the value type is an integral (bool or label). | |
| 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. | |
| word | valueTypeName () const |
| The name for the value type. Similar to pTraits typeName. | |
| word | listCompoundName () const |
The name for the compound token (for a List of values). Eg, List<scalar>, List<vector> ... | |
| void | clear () |
| Reset to 'none'. | |
| bool | read (Istream &is) |
| Read read tokens (if possible). | |
| bool | readTokens (ITstream &is) |
| Guess type and read tokens (if possible). | |
| int | compare (const exprValue &rhs) const |
| Compare (type,value). | |
| 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. | |
| template<class Type> | |
| bool | set (const Type &val) |
| Assign from type. Returns false and sets to 'none' for unsupported types. | |
| template<class Type> | |
| const Type & | get () const |
| Return the value. Return pTraits zero if the types mismatch. | |
| 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. | |
| void | operator= (Foam::zero) |
| Assign from zero. Changes value but not type. | |
| const char * | cdata_bytes () const noexcept |
| Pointer to the data content as byte data. | |
| char * | data_bytes () noexcept |
| Pointer to the data content as byte data. | |
| bool | operator== (const exprValue &rhs) const |
| Compare (type,value) for equality. | |
| bool | operator!= (const exprValue &rhs) const |
| Compare (type,value) for inequality. | |
| bool | operator< (const exprValue &rhs) const |
| Compare (type,value). | |
| InfoProxy< exprValue > | info () const |
| Return info proxy for printing information to a stream. | |
| void | write (Ostream &os, bool prune=false) const |
| Write the (type-specific) content. | |
Static Public Member Functions | |
| static bool | good (const expressions::valueTypeCode) noexcept |
| True if valueTypeCode is not none/invalid. | |
| static bool | is_integral (const expressions::valueTypeCode) noexcept |
| True if valueTypeCode is bool/label. | |
| static direction | nComponents (const expressions::valueTypeCode) noexcept |
| The number of components associated with the valueTypeCode. | |
| static direction | rank (const expressions::valueTypeCode) noexcept |
| The vector-space rank associated with the valueTypeCode. | |
| template<class Type> | |
| static bool | supportedType () |
| True if the specified type is supported. | |
| static expressions::valueTypeCode | peekType (const ITstream &is) |
| Detect the type from the available tokens. | |
| static bool | read (const std::string &str, exprValue &val) |
| Read entire string as a exprValue, skipping leading/trailing whitespace. | |
| static constexpr unsigned | size_bytes () noexcept |
| Size of the (contiguous) data content as byte data is compile-time constant. | |
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().
Referenced by compare(), exprValue(), operator!=(), operator<(), operator=(), operator==(), read(), and size_bytes().


|
inline |
Copy construct (deep copy).
Definition at line 98 of file exprValueI.H.
References exprValue(), and Foam::rhs().

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

|
inlinestaticnoexcept |
True if valueTypeCode is not none/invalid.
Definition at line 25 of file exprValueI.H.
References Foam::expressions::INVALID, and Foam::expressions::NONE.
Referenced by compare(), exprValue(), and listCompoundName().

|
inlinestaticnoexcept |
True if valueTypeCode is bool/label.
Definition at line 38 of file exprValueI.H.
References Foam::expressions::type_bool, and Foam::expressions::type_label.
|
inlinestaticnoexcept |
The number of components associated with the valueTypeCode.
Definition at line 51 of file exprValueI.H.
References Foam::expressions::Detail::nComponents().

|
inlinestaticnoexcept |
The vector-space rank associated with the valueTypeCode.
Definition at line 60 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, and exprTypeTraits< Type >::value.
|
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 135 of file exprValue.C.
References token::BEGIN_LIST, token::END_LIST, good(), token::good(), ITstream::hasPutback(), Foam::expressions::INVALID, token::isLabel(), token::isNumber(), token::isPunctuation(), token::isScalar(), Foam::expressions::NONE, ITstream::peek(), UList< T >::size(), ITstream::tokenIndex(), and exprTypeTraits< Type >::value.
Referenced by readTokens().


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

|
inlinenoexcept |
|
inlinenoexcept |
True if the value type is not none/invalid.
Definition at line 123 of file exprValueI.H.
References good(), and Foam::noexcept.
Referenced by good(), and peekType().


|
inlinenoexcept |
True if the value type is an integral (bool or label).
Definition at line 129 of file exprValueI.H.
References is_integral(), and Foam::noexcept.
Referenced by is_integral().


|
inlinenoexcept |
The number of components associated with the value type.
Definition at line 136 of file exprValueI.H.
References Foam::expressions::Detail::nComponents(), and Foam::noexcept.

|
inlinenoexcept |
The vector-space rank associated with the value type.
Definition at line 143 of file exprValueI.H.
References Foam::noexcept, and 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 good(), and Foam::name().

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

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


| int compare | ( | const exprValue & | rhs | ) | const |
Compare (type,value).
Definition at line 471 of file exprValue.C.
References doLocalCode, exprValue(), FOR_ALL_EXPR_VALUE_TYPES, good(), and Foam::rhs().
Referenced by operator<().


|
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.
References Foam::noexcept, and exprTypeTraits< Type >::value.
|
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, Foam::expressions::NONE, and exprTypeTraits< Type >::value.
Referenced by exprValue().


|
inline |
Return the value. Return pTraits zero if the types mismatch.
Definition at line 191 of file exprValueI.H.
References Foam::isA().

|
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 |
|
inline |
Assign from bool
Definition at line 368 of file exprValue.H.
|
inline |
Copy assignment.
Definition at line 375 of file exprValue.H.
References exprValue(), and Foam::rhs().

|
inline |
Assign from zero. Changes value but not type.
Definition at line 380 of file exprValue.H.
|
inlinenoexcept |
Pointer to the data content as byte data.
Definition at line 388 of file exprValue.H.
References Foam::noexcept.
|
inlinenoexcept |
Pointer to the data content as byte data.
Definition at line 396 of file exprValue.H.
References Foam::noexcept.
|
inlinestaticconstexprnoexcept |
Size of the (contiguous) data content as byte data is compile-time constant.
Definition at line 405 of file exprValue.H.
References exprValue(), and Foam::noexcept.

| bool operator== | ( | const exprValue & | rhs | ) | const |
Compare (type,value) for equality.
Definition at line 525 of file exprValue.C.
References doLocalCode, exprValue(), FOR_ALL_EXPR_VALUE_TYPES, and Foam::rhs().

|
inline |
Compare (type,value) for inequality.
Definition at line 421 of file exprValue.H.
References exprValue(), and Foam::rhs().

| bool operator< | ( | const exprValue & | rhs | ) | const |
Compare (type,value).
Definition at line 561 of file exprValue.C.
References compare(), exprValue(), and Foam::rhs().

Return info proxy for printing information to a stream.
Definition at line 434 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 323 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().
