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();
66 const word& key = tok.wordToken();
73 !(key[0] ==
'$' && expandVariable(key.substr(1),
dict))
74 && !(key[0] ==
'#' && expandFunction(key.substr(1),
dict, is))
78 else if (tok.isVariable())
80 const string& key = tok.stringToken();
86 || !(key[0] ==
'$' && expandVariable(key.substr(1),
dict))
94 bool Foam::primitiveEntry::expandFunction
96 const word& functionName,
97 const dictionary&
dict,
119 uint64_t balanced = 0u;
136 if (depth >= 0 && depth < 61)
138 balanced &= ~(1u << depth);
146 if (depth >= 0 && depth < 61)
148 balanced |= (1u << depth);
162 "Too many closing ')' ... was a ';' forgotten?"
165 else if (depth < 61 && ((balanced >> depth) & 1u))
168 safeIOWarning(is,
"Imbalanced '{' with ')'");
181 "Too many closing '}' ... was a ';' forgotten?"
184 else if (depth < 61 && !((balanced >> depth) & 1u))
187 safeIOWarning(is,
"Imbalanced '(' with '}'");
194 if (acceptToken(tok,
dict, is))
196 newElmt(tokenIndex()++) = std::move(tok);
202 tok = token::punctuationToken::NULL_TOKEN;
207 safeIOWarning(is,
"Imbalanced brackets");
227 std::ostringstream os;
228 os <<
"ill defined primitiveEntry starting at keyword '"
230 <<
" on line " << keywordLineNumber
254 is.
name() +
'.' + key,
279 bool addSpace =
false;
280 for (
const token& tok : *
this)
303 this->
write(os,
false);
320 const label nPrintTokens = 10;
322 os <<
" primitiveEntry '" <<
e.keyword() <<
"' comprises ";
324 for (
label i=0; i<
min(
e.size(), nPrintTokens); ++i)
326 os <<
nl <<
" " <<
e[i].info();
329 if (
e.size() > nPrintTokens)
A keyword and a list of tokens is an 'entry'.
points setSize(newPointi)
void fatalCheck(const char *operation) const
Check IOstream status for given operation.
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, Istream &is)
Construct from keyword and a Istream.
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.
bool good() const
True if token is not UNDEFINED or ERROR.
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.
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
An input stream of tokens.
An Istream is an abstract base class for all input systems (streams, files, token lists etc)....
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.
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,...
bool isPunctuation() const
Token is PUNCTUATION.
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.