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))
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();
237 std::ostringstream
os;
238 os <<
"ill defined primitiveEntry starting at keyword '" 240 <<
" on line " << keywordLineNumber
257 const dictionary&
dict,
264 static_cast<IOstreamOption>(is),
290 bool started =
false;
291 for (
const token& tok : *
this)
319 this->
write(os,
false);
329 const InfoProxy<primitiveEntry>& iproxy
332 const auto&
e = *iproxy;
336 const label nPrintTokens =
Foam::min(label(10), label(
e.size()));
338 os <<
" primitiveEntry '" <<
e.keyword() <<
"' comprises ";
340 for (label i = 0; i < nPrintTokens; ++i)
342 os <<
nl <<
" " <<
e[i].info();
void add_tokens(const token &tok)
Copy append a token at the current tokenIndex, incrementing the index.
Begin block [isseparator].
bool good() const noexcept
True if token is not UNDEFINED or ERROR.
A class for handling keywords in dictionaries.
bool isPunctuation() const noexcept
Token is PUNCTUATION.
punctuationToken pToken() const
Return punctuation character.
static bool execute(const word &functionName, dictionary &parentDict, Istream &is)
Execute the functionEntry in a sub-dict context.
A class for handling file names.
bool bad() const noexcept
True if stream is corrupted.
virtual Ostream & write(const char c) override
Write character.
void resize(const label len)
Adjust allocated size of list.
A list of keyword definitions, which are a keyword followed by a number of values (eg...
An Istream is an abstract base class for all input systems (streams, files, token lists etc)...
constexpr char nl
The newline '\n' character (0x0a)
bool empty() const noexcept
True if List is empty (ie, size() is zero)
A token holds an item read from Istream.
Ostream & endl(Ostream &os)
Add newline and flush stream.
Begin list [isseparator].
bool read(const char *buf, int32_t &val)
Same as readInt32.
A keyword and a list of tokens comprise a primitiveEntry. A primitiveEntry can be read...
void write(vtk::formatter &fmt, const Type &val, const label n=1)
Component-wise write of a value (N times)
static int disableFunctionEntries
Enable or disable use of function entries and variable expansions.
const dimensionedScalar e
Elementary charge.
virtual Istream & read(token &)=0
Return next token from stream.
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for expressions::valueTypeCode::INVALID.
static bool execute(const dictionary &parentDict, primitiveEntry &thisEntry, Istream &is)
Execute in a primitiveEntry context, extracts token or line.
virtual void write(Ostream &os) const
Write.
label min(const labelHashSet &set, label minValue=labelMax)
Find the min value in labelHashSet, optionally limited by second argument.
An Ostream is an abstract base class for all output systems (streams, files, token lists...
OBJstream os(runTime.globalPath()/outputName)
virtual const dictionary & dict() const
This entry is not a dictionary, calling this function generates a FatalError.
label lineNumber() const noexcept
Const access to the current stream line number.
bool fatalCheck(const char *operation) const
Check IOstream status for given operation.
auto key(const Type &t) -> typename std::enable_if< std::is_enum< Type >::value, typename std::underlying_type< Type >::type >::type
const dimensionedScalar c
Speed of light in a vacuum.
primitiveEntry(const keyType &key)
Construct from keyword and no tokens.
virtual Ostream & endEntry()
Write end entry (';') followed by newline.
virtual bool read(const dictionary &dict, Istream &is)
Read tokens from the given stream.
void seek(label pos) noexcept
Move tokenIndex to the specified position and adjust the stream status (open/good/eof ...
virtual Ostream & writeKeyword(const keyType &kw)
Write the keyword followed by an appropriate indentation.
#define SafeFatalIOErrorInFunction(ios, msg)
Report an error message using Foam::FatalIOError.