38 const std::string& msg
42 <<
"non-specialized: " << msg.c_str() <<
endl 56 static void addTokens(
tokenList& toks,
const Type& val)
61 const label nOld = toks.
size();
62 toks.
resize(nOld + label(nCmpt + nParen));
64 auto iter = toks.
begin(nOld);
72 for (
direction cmpt = 0; cmpt < nCmpt; ++cmpt)
88 void addTokens<bool>(
tokenList& toks,
const bool& val)
96 void addTokens<label>(
tokenList& toks,
const label& val)
98 toks.emplace_back() = val;
104 void addTokens<scalar>(
tokenList& toks,
const scalar& val)
106 toks.emplace_back() = val;
136 const auto oldflags =
os.
setf(std::ios::showpoint);
151 const token& tok0 = is.peek();
161 const label firstCmpti = (is.tokenIndex() + (is.hasPutback() ? 0 : 1));
164 for (label endCmpti = firstCmpti; endCmpti < is.size(); ++endCmpti)
166 const token& tok = is[endCmpti];
177 switch (endCmpti - firstCmpti)
215 else if (tok0.
good())
227 else if (Switch(tok0).good())
246 const std::string& str,
261 std::memset(static_cast<void*>(
this),
'\0',
sizeof(*
this));
266 void Foam::expressions::exprValue::deepCopy(
const exprValue& rhs)
271 std::memcpy(static_cast<void*>(
this), &rhs,
sizeof(*
this));
305 toks.emplace_back(word(
"bad"));
311 #define doLocalCode(Type, UnusedParam) \ 313 case expressions::valueTypeCode::type_##Type : \ 315 const Type* dataPtr = data_.get<Type>(); \ 318 addTokens<Type>(toks, *dataPtr); \ 365 #define doLocalCode(Type, UnusedParam) \ 367 case expressions::valueTypeCode::type_##Type : \ 369 const Type* dataPtr = data_.get<Type>(); \ 372 putType(os, *dataPtr); \ 431 return readTokens(*stream);
445 typeCode_ = whichCode;
453 typeCode_ = whichCode;
463 #define doLocalCode(Type, UnusedParam) \ 465 case expressions::valueTypeCode::type_##Type : \ 467 data_.set<Type>(pTraits<Type>(is)); \ 468 typeCode_ = whichCode; \ 488 if (typeCode_ != rhs.typeCode_)
491 return (
int(typeCode_) -
int(rhs.typeCode_));
493 else if ((
this == &rhs) || !good())
508 #define doLocalCode(Type, UnusedParam) \ 510 case expressions::valueTypeCode::type_##Type : \ 512 const Type* a = data_.get<Type>(); \ 513 const Type* b = rhs.data_.get<Type>(); \ 517 ? ((*a < *b) ? -1 : (*b < *a) ? 1 : 0) \ 539 if (typeCode_ != rhs.typeCode_)
544 else if (
this == &rhs)
552 #define doLocalCode(Type, UnusedParam) \ 554 case expressions::valueTypeCode::type_##Type : \ 556 const Type* a = data_.get<Type>(); \ 557 const Type* b = rhs.data_.get<Type>(); \ 558 return (a && b && (*a == *b)); \ 575 return (this->compare(rhs) < 0);
595 const expressions::exprValue& val
607 const InfoProxy<expressions::exprValue>& iproxy
610 const auto& val = *iproxy;
622 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 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.
Ostream & endl(Ostream &os)
Add newline and flush stream.
A traits class, which is primarily used for primitives and vector-space.
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.
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)
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.
static constexpr ::Foam::expressions::valueTypeCode value
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.