Go to the documentation of this file.
35 bool 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)
99 bool Foam::primitiveEntry::expandFunction
101 const word& functionName,
102 const dictionary&
dict,
124 uint64_t balanced = 0u;
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);
207 tok = token::punctuationToken::NULL_TOKEN;
212 reportReadWarning(is,
"Imbalanced brackets");
220 void Foam::primitiveEntry::readEntry(
const dictionary&
dict, Istream& is)
222 const label keywordLineNumber = is.lineNumber();
232 std::ostringstream
os;
233 os <<
"ill defined primitiveEntry starting at keyword '"
235 <<
" on line " << keywordLineNumber
252 const dictionary&
dict,
283 bool addSpace =
false;
284 for (
const token& tok : *
this)
306 this->
write(os,
false);
316 const InfoProxy<primitiveEntry>& ip
319 const primitiveEntry&
e = ip.t_;
323 const label nPrintTokens = 10;
325 os <<
" primitiveEntry '" <<
e.keyword() <<
"' comprises ";
327 for (label i=0; i<
min(
e.size(), nPrintTokens); ++i)
329 os <<
nl <<
" " <<
e[i].info();
332 if (
e.size() > nPrintTokens)
A keyword and a list of tokens is an 'entry'.
points setSize(newPointi)
A keyword and a list of tokens comprise a primitiveEntry. A primitiveEntry can be read,...
A helper class for outputting values to Ostream.
bool read(const char *buf, int32_t &val)
primitiveEntry(const keyType &key)
auto key(const Type &t) -> typename std::enable_if< std::is_enum< Type >::value, typename std::underlying_type< Type >::type >::type
bool fatalCheck(const char *operation) const
label lineNumber() const noexcept
virtual bool read(const dictionary &dict, Istream &is)
Ostream & endl(Ostream &os)
A token holds an item read from Istream.
virtual void write(Ostream &os) const
virtual Ostream & write(const char c)
label min(const labelHashSet &set, label minValue=labelMax)
punctuationToken pToken() const
A class for handling keywords in dictionaries.
virtual const fileName & name() const
An input stream of tokens.
An Istream is an abstract base class for all input systems (streams, files, token lists etc)....
The IOstreamOption is a simple container for options an IOstream can normally have.
bool isPunctuation() const noexcept
@ END_STATEMENT
End entry [isseparator].
@ END_BLOCK
End block [isseparator].
#define SafeFatalIOErrorInFunction(ios, msg)
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
OBJstream os(runTime.globalPath()/outputName)
bool bad() const noexcept
virtual Ostream & writeKeyword(const keyType &kw)
static int disableFunctionEntries
@ BEGIN_BLOCK
Begin block [isseparator].
List< token > tokenList
List of tokens, used for a IOdictionary entry.
bool good() const noexcept
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
const dimensionedScalar e
virtual const dictionary & dict() const
void write(vtk::formatter &fmt, const Type &val, const label n=1)
@ END_LIST
End list [isseparator].
static bool execute(const dictionary &parentDict, primitiveEntry &thisEntry, Istream &is)
const dimensionedScalar c
word name(const expressions::valueTypeCode typeCode)
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
@ BEGIN_LIST
Begin list [isseparator].
static bool execute(const word &functionName, dictionary &parentDict, Istream &is)
virtual Istream & read(token &)=0