Go to the documentation of this file.
37 inline void safeIOWarning
40 const std::string& msg
44 <<
"--> FOAM Warning :\n"
45 <<
" Reading \"" << is.
name() <<
"\" at line "
55 bool Foam::primitiveEntry::acceptToken
58 const dictionary&
dict,
62 bool accept = tok.good();
64 if (tok.isDirective())
67 const word& key = tok.wordToken();
73 || !expandFunction(key.substr(1),
dict, is)
76 else if (tok.isVariable())
79 const string& key = tok.stringToken();
85 || !expandVariable(key.substr(1),
dict)
93 bool Foam::primitiveEntry::expandFunction
95 const word& functionName,
96 const dictionary&
dict,
118 uint64_t balanced = 0u;
135 if (depth >= 0 && depth < 61)
137 balanced &= ~(1u << depth);
145 if (depth >= 0 && depth < 61)
147 balanced |= (1u << depth);
161 "Too many closing ')' ... was a ';' forgotten?"
164 else if (depth < 61 && ((balanced >> depth) & 1u))
167 safeIOWarning(is,
"Imbalanced '{' with ')'");
180 "Too many closing '}' ... was a ';' forgotten?"
183 else if (depth < 61 && !((balanced >> depth) & 1u))
186 safeIOWarning(is,
"Imbalanced '(' with '}'");
193 if (acceptToken(tok,
dict, is))
195 newElmt(tokenIndex()++) = std::move(tok);
201 tok = token::punctuationToken::NULL_TOKEN;
206 safeIOWarning(is,
"Imbalanced brackets");
216 const label keywordLineNumber = is.
lineNumber();
226 std::ostringstream os;
227 os <<
"ill defined primitiveEntry starting at keyword '"
229 <<
" on line " << keywordLineNumber
253 is.
name() +
'.' + key,
278 bool addSpace =
false;
279 for (
const token& tok : *
this)
302 this->
write(os,
false);
319 const label nPrintTokens = 10;
321 os <<
" primitiveEntry '" <<
e.keyword() <<
"' comprises ";
323 for (label i=0; i<
min(
e.size(), nPrintTokens); ++i)
325 os <<
nl <<
" " <<
e[i].info();
328 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)
Same as readInt32.
primitiveEntry(const keyType &key)
Construct from keyword and no tokens.
bool fatalCheck(const char *operation) const
Check IOstream status for given operation.
An IOstream is an abstract base class for all input/output systems; be they streams,...
streamFormat format() const noexcept
Get the current stream format.
virtual bool read(const dictionary &dict, Istream &is)
Read tokens from the given stream.
Ostream & endl(Ostream &os)
Add newline and flush stream.
A token holds an item read from Istream.
virtual void write(Ostream &os) const
Write.
virtual const dictionary & dict() const
This entry is not a dictionary,.
label min(const labelHashSet &set, label minValue=labelMax)
Find the min value in labelHashSet, optionally limited by second argument.
punctuationToken pToken() const
Return punctuation character.
A class for handling keywords in dictionaries.
An input stream of tokens.
An Istream is an abstract base class for all input systems (streams, files, token lists etc)....
bool isPunctuation() const noexcept
Token is PUNCTUATION.
virtual const fileName & name() const
Return the name of the stream.
versionNumber version() const noexcept
Get the stream version.
#define SafeFatalIOErrorInFunction(ios, msg)
Report an error message using Foam::FatalIOError.
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
bool bad() const
Return true if stream is corrupted.
virtual bool write(const token &tok)=0
Write token to stream or otherwise handle it.
virtual Ostream & writeKeyword(const keyType &kw)
Write the keyword followed by an appropriate indentation.
static int disableFunctionEntries
Enable or disable use of function entries and variable expansions.
Begin block [isseparator].
List< token > tokenList
List of tokens, used for a IOdictionary entry.
bool good() const noexcept
True if token is not UNDEFINED or ERROR.
const dimensionedScalar e
Elementary charge.
void write(vtk::formatter &fmt, const Type &val, const label n=1)
Component-wise write of a value (N times)
const dimensionedScalar c
Speed of light in a vacuum.
label lineNumber() const
Const access to the current stream line number.
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Begin list [isseparator].
static bool execute(const word &functionName, dictionary &parentDict, Istream &is)
Execute the functionEntry in a sub-dict context.
virtual Istream & read(token &)=0
Return next token from stream.