38 const std::string& msg
42 <<
"non-specialized: " << msg.c_str() <<
endl
56static void addTokens(
tokenList& toks,
const Type& val)
58 if constexpr (std::is_same_v<bool, Type>)
63 else if constexpr (std::is_arithmetic_v<Type>)
75 const label nOld = toks.
size();
76 toks.
resize(nOld + label(nCmpt + nParen));
78 auto iter = toks.
begin(nOld);
86 for (
direction cmpt = 0; cmpt < nCmpt; ++cmpt)
105static void putType(Ostream&
os,
const Type& val)
127 const auto oldflags =
os.setf(std::ios::showpoint);
155 for (label endCmpti = firstCmpti; endCmpti < is.
size(); ++endCmpti)
157 const token& tok = is[endCmpti];
168 switch (endCmpti - firstCmpti)
206 else if (tok0.
good())
237 const std::string& str,
252 std::memset(
static_cast<void*
>(
this),
'\0',
sizeof(*
this));
257void Foam::expressions::exprValue::deepCopy(
const exprValue&
rhs)
262 std::memcpy(
static_cast<void*
>(
this), &
rhs,
sizeof(*
this));
296 toks.emplace_back(word(
"bad"));
302 #define doLocalCode(Type, UnusedParam) \
304 case expressions::valueTypeCode::type_##Type : \
306 const Type* dataPtr = data_.get<Type>(); \
309 addTokens<Type>(toks, *dataPtr); \
356 #define doLocalCode(Type, UnusedParam) \
358 case expressions::valueTypeCode::type_##Type : \
360 const Type* dataPtr = data_.get<Type>(); \
363 putType(os, *dataPtr); \
422 return readTokens(*stream);
436 typeCode_ = whichCode;
444 typeCode_ = whichCode;
454 #define doLocalCode(Type, UnusedParam) \
456 case expressions::valueTypeCode::type_##Type : \
458 data_.set<Type>(pTraits<Type>(is)); \
459 typeCode_ = whichCode; \
479 if (typeCode_ !=
rhs.typeCode_)
482 return (
int(typeCode_) -
int(
rhs.typeCode_));
484 else if ((
this == &
rhs) || !good())
499 #define doLocalCode(Type, UnusedParam) \
501 case expressions::valueTypeCode::type_##Type : \
503 const Type* a = data_.get<Type>(); \
504 const Type* b = rhs.data_.get<Type>(); \
508 ? ((*a < *b) ? -1 : (*b < *a) ? 1 : 0) \
530 if (typeCode_ !=
rhs.typeCode_)
535 else if (
this == &
rhs)
543 #define doLocalCode(Type, UnusedParam) \
545 case expressions::valueTypeCode::type_##Type : \
547 const Type* a = data_.get<Type>(); \
548 const Type* b = rhs.data_.get<Type>(); \
549 return (a && b && (*a == *b)); \
566 return (this->compare(
rhs) < 0);
586 const expressions::exprValue& val
589 val.write(
os,
false);
601 const auto& val = *iproxy;
613 os << val.valueTypeName() <<
": ";
bool fatalCheck(const char *operation) const
Check IOstream status for given operation.
bool bad() const noexcept
True if stream is corrupted.
An input stream of tokens.
void add_tokens(const token &tok)
Copy append a token at the current tokenIndex, incrementing the index.
label tokenIndex() const noexcept
The current token index when reading, or the insertion point.
void seek(label pos) noexcept
Move tokenIndex to the specified position and adjust the stream status (open/good/eof ....
label nRemainingTokens() const noexcept
Number of tokens remaining.
bool skip(label n=1) noexcept
Move tokenIndex relative to the current position.
const token & peek() const noexcept
Failsafe peek at what the next read would return, including handling of any putback.
bool hasPutback() const noexcept
True if putback token is in use.
A helper class for outputting values to Ostream.
An Istream is an abstract base class for all input systems (streams, files, token lists etc)....
T & emplace_back(Args &&... args)
Construct an element at the end of the list, return reference to the new list element.
void resize(const label len)
Adjust allocated size of list.
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,...
iterator begin() noexcept
Return an iterator to begin traversing the UList.
void size(const label n)
Older name for setAddressableSize.
A polymorphic typed union of simple primitive and VectorSpace types. It uses a 'fatter' representatio...
exprValue()
Default construct (zero-initialized) as 'none'.
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 read(const std::string &str, exprValue &val)
Read entire string as a exprValue, skipping leading/trailing whitespace.
void write(Ostream &os, bool prune=false) const
Write the (type-specific) content.
bool readTokens(ITstream &is)
Guess type and read tokens (if possible).
bool operator==(const exprValue &rhs) const
Compare (type,value) for equality.
void clear()
Reset to 'none'.
static bool good(const expressions::valueTypeCode) noexcept
True if valueTypeCode is not none/invalid.
bool operator<(const exprValue &rhs) const
Compare (type,value).
A token holds an item read from Istream.
bool isNumber() const noexcept
Token is (signed/unsigned) integer type, FLOAT or DOUBLE.
bool isPunctuation() const noexcept
Token is PUNCTUATION.
@ BEGIN_LIST
Begin list [isseparator].
@ END_LIST
End list [isseparator].
bool isLabel() const noexcept
Integral token is convertible to Foam::label.
bool good() const noexcept
True if token is not UNDEFINED or ERROR.
bool isScalar() const noexcept
Token is FLOAT or DOUBLE.
bool isWord() const noexcept
Token is word-variant (WORD, DIRECTIVE).
static token boolean(bool on) noexcept
Create a bool token.
A class for handling words, derived from Foam::string.
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
#define FOR_ALL_EXPR_VALUE_TYPES(Macro,...)
OBJstream os(runTime.globalPath()/outputName)
#define doLocalCode(FieldType, Variable)
valueTypeCode
An enumeration of known and expected expression value types.
@ NONE
No type, or default initialized type.
@ INVALID
Invalid/unknown/error type.
static void putType(Ostream &os, const Type &val)
void component(FieldField< Field, typename FieldField< Field, Type >::cmptType > &sf, const FieldField< Field, Type > &f, const direction d)
void putType< scalar >(Ostream &os, const scalar &val)
Specialized for scalar. Write with '.' to avoid scalar/label ambiguity.
Ostream & endl(Ostream &os)
Add newline and flush stream.
constexpr bool is_vectorspace_v
The is_vectorspace value of Type.
errorManip< error > abort(error &err)
void rhs(fvMatrix< typename Expr::value_type > &m, const Expr &expression)
error FatalError
Error stream (stdout output on all processes), with additional 'FOAM FATAL ERROR' header text and sta...
List< token > tokenList
List of token, used for dictionary primitive entry (for example).
void putType< bool >(Ostream &os, const bool &val)
Specialized for bool. Write as (true/false) via Switch to avoid bool/label ambiguity.
static constexpr::Foam::expressions::valueTypeCode value
The vector-space number of components: default is 1.
static void notSpecialized(const std::string &msg) noexcept
Runtime 'assert' for unimplemented generic methods.