38 const std::string& msg
42 <<
"non-specialized: " << msg.c_str() <<
endl 56 static 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>)
73 2*(is_vectorspace_v<Type> || (nCmpt > 1) ? 1 : 0);
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)
105 static 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));
257 void 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);
598 const InfoProxy<expressions::exprValue>& iproxy
601 const auto& val = *iproxy;
613 os << val.valueTypeName() <<
": ";
void add_tokens(const token &tok)
Copy append a token at the current tokenIndex, incrementing the index.
bool good() const noexcept
True if token is not UNDEFINED or ERROR.
bool isPunctuation() const noexcept
Token is PUNCTUATION.
void size(const label n)
Older name for setAddressableSize.
bool good() const noexcept
True if the Switch represents a valid enumeration.
bool isWord() const noexcept
Token is word-variant (WORD, DIRECTIVE)
bool bad() const noexcept
True if stream is corrupted.
static void notSpecialized(const std::string &msg) noexcept
Runtime 'assert' for unimplemented generic methods.
void resize(const label len)
Adjust allocated size of list.
error FatalError
Error stream (stdout output on all processes), with additional 'FOAM FATAL ERROR' header text and sta...
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
A polymorphic typed union of simple primitive and VectorSpace types. It uses a 'fatter' representatio...
An Istream is an abstract base class for all input systems (streams, files, token lists etc)...
A token holds an item read from Istream.
The vector-space number of components: default is 1.
Ostream & endl(Ostream &os)
Add newline and flush stream.
No type, or default initialized type.
A simple wrapper around bool so that it can be read as a word: true/false, on/off, yes/no, any/none. Also accepts 0/1 as a string and shortcuts t/f, y/n.
Begin list [isseparator].
virtual std::ios_base::fmtflags flags() const override
Get current stream flags.
std::ios_base::fmtflags setf(std::ios_base::fmtflags f)
Set stream flag(s), return old stream flags.
label tokenIndex() const noexcept
The current token index when reading, or the insertion point.
label nRemainingTokens() const noexcept
Number of tokens remaining.
List< token > tokenList
List of token, used for dictionary primitive entry (for example)
bool isScalar() const noexcept
Token is FLOAT or DOUBLE.
Invalid/unknown/error type.
virtual Istream & read(token &)=0
Return next token from stream.
A class for handling words, derived from Foam::string.
static expressions::valueTypeCode peekType(const ITstream &is)
Detect the type from the available tokens.
bool hasPutback() const noexcept
True if putback token is in use.
static bool read(const std::string &str, exprValue &val)
Read entire string as a exprValue, skipping leading/trailing whitespace.
valueTypeCode
An enumeration of known and expected expression value types.
int compare(const exprValue &rhs) const
Compare (type,value)
virtual bool write(const token &tok)=0
Write token to stream or otherwise handle it.
errorManip< error > abort(error &err)
iterator begin() noexcept
Return an iterator to begin traversing the UList.
bool operator<(const exprValue &rhs) const
Compare (type,value)
void write(Ostream &os, bool prune=false) const
Write the (type-specific) content.
An Ostream is an abstract base class for all output systems (streams, files, token lists...
bool readTokens(ITstream &is)
Guess type and read tokens (if possible)
bool operator==(const exprValue &rhs) const
Compare (type,value) for equality.
OBJstream os(runTime.globalPath()/outputName)
T & emplace_back(Args &&... args)
Construct an element at the end of the list, return reference to the new list element.
Simple type identifiers for polymorphic expression values. The definitions are similar to std::integr...
#define doLocalCode(Type, UnusedParam)
void putType< scalar >(Ostream &os, const scalar &val)
Specialized for scalar. Write with '.' to avoid scalar/label ambiguity.
bool fatalCheck(const char *operation) const
Check IOstream status for given operation.
#define FOR_ALL_EXPR_VALUE_TYPES(Macro,...)
static token boolean(bool on) noexcept
Create a bool token.
const token & peek() const noexcept
Failsafe peek at what the next read would return, including handling of any putback.
bool isLabel() const noexcept
Token is LABEL.
void clear()
Reset to 'none'.
bool skip(label n=1) noexcept
Move tokenIndex relative to the current position.
static void putType(Ostream &os, const Type &val)
bool isNumber() const noexcept
Token is LABEL, FLOAT or DOUBLE.
void component(FieldField< Field, typename FieldField< Field, Type >::cmptType > &sf, const FieldField< Field, Type > &f, const direction d)
void putType< bool >(Ostream &os, const bool &val)
Specialized for bool. Write as (true/false) via Switch to avoid bool/label ambiguity.
void seek(label pos) noexcept
Move tokenIndex to the specified position and adjust the stream status (open/good/eof ...
An input stream of tokens.