35bool Foam::primitiveEntry::acceptToken
38 const dictionary&
dict,
42 bool accept = tok.good();
44 if (tok.isDirective())
49 const word&
key = tok.wordToken();
55 || !expandFunction(
key.substr(1),
dict, is)
58 else if (tok.isExpression())
63 const string&
key = tok.stringToken();
79 else if (tok.isVariable())
85 const string&
key = tok.stringToken();
91 || !expandVariable(
key.substr(1),
dict)
99bool Foam::primitiveEntry::expandFunction
101 const word& functionName,
102 const dictionary&
dict,
124 uint64_t balanced = 0u;
136 const char c = tok.
pToken();
141 if (depth >= 0 && depth < 61)
143 balanced &= ~(1u << depth);
151 if (depth >= 0 && depth < 61)
153 balanced |= (1u << depth);
167 "Too many closing ')' ... was a ';' forgotten?"
170 else if (depth < 61 && ((balanced >> depth) & 1u))
173 reportReadWarning(is,
"Imbalanced '{' with ')'");
186 "Too many closing '}' ... was a ';' forgotten?"
189 else if (depth < 61 && !((balanced >> depth) & 1u))
192 reportReadWarning(is,
"Imbalanced '(' with '}'");
199 if (acceptToken(tok,
dict, is))
201 newElmt(tokenIndex()++) = std::move(tok);
212 reportReadWarning(is,
"Imbalanced brackets");
222 const label keywordLineNumber = is.
lineNumber();
232 std::ostringstream
os;
233 os <<
"ill defined primitiveEntry starting at keyword '"
235 <<
" on line " << keywordLineNumber
259 is.
name() +
'.' + key,
283 bool addSpace =
false;
284 for (
const token& tok : *
this)
306 this->
write(os,
false);
323 const label nPrintTokens = 10;
325 os <<
" primitiveEntry '" <<
e.keyword() <<
"' comprises ";
327 for (label i=0; i<
min(
e.
size(), nPrintTokens); ++i)
332 if (
e.
size() > nPrintTokens)
InfoProxy< IOobject > info() const
Return info proxy, for printing information to a stream.
The IOstreamOption is a simple container for options an IOstream can normally have.
label lineNumber() const noexcept
Const access to the current stream line number.
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.
A helper class for outputting values to Ostream.
An Istream is an abstract base class for all input systems (streams, files, token lists etc)....
virtual Istream & read(token &)=0
Return next token from stream.
virtual Ostream & write(const char c)
Write character.
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
virtual Ostream & writeKeyword(const keyType &kw)
Write the keyword followed by an appropriate indentation.
virtual bool read()
Re-read model coefficients if they have changed.
void size(const label n)
Older name for setAddressableSize.
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
A keyword and a list of tokens is an 'entry'.
static int disableFunctionEntries
Enable or disable use of function entries and variable expansions.
virtual bool execute()
Calculate the output fields.
virtual bool write()
Write the output fields.
A class for handling keywords in dictionaries.
A keyword and a list of tokens comprise a primitiveEntry. A primitiveEntry can be read,...
virtual const dictionary & dict() const
This entry is not a dictionary,.
A token holds an item read from Istream.
bool isPunctuation() const noexcept
Token is PUNCTUATION.
@ BEGIN_BLOCK
Begin block [isseparator].
@ END_BLOCK
End block [isseparator].
@ END_STATEMENT
End entry [isseparator].
@ NULL_TOKEN
Nul character.
@ BEGIN_LIST
Begin list [isseparator].
@ END_LIST
End list [isseparator].
punctuationToken pToken() const
Return punctuation character.
bool good() const noexcept
True if token is not UNDEFINED or ERROR.
#define SafeFatalIOErrorInFunction(ios, msg)
Report an error message using Foam::FatalIOError.
OBJstream os(runTime.globalPath()/outputName)
auto key(const Type &t) -> typename std::enable_if< std::is_enum< Type >::value, typename std::underlying_type< Type >::type >::type
bool read(const char *buf, int32_t &val)
Same as readInt32.
Ostream & endl(Ostream &os)
Add newline and flush stream.
label min(const labelHashSet &set, label minValue=labelMax)
Find the min value in labelHashSet, optionally limited by second argument.
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for INVALID.
constexpr char nl
The newline '\n' character (0x0a)
points setSize(newPointi)