mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-12-28 03:37:59 +00:00
ENH: provision for delayed reading of compound tokens (#2953)
- the construction of compound tokens is now split into two stages:
- default construct
- read contents
This permits a larger variety of handling.
- the new token::readCompoundToken(..) method allows for simpler
more failsafe invocations.
- forward resize(), read() methods for compound tokens to support
separate read and population.
Top-level refCompoundToken() method for modify access.
ENH: split off a private readCompoundToken() method within ISstream
- this allows overloading and alternative tokenisation handling for
derived classes
This commit is contained in:
@ -69,6 +69,19 @@ inline static label byteAlign(const label pos, const size_t align)
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
// Read into compound token (assumed to be a known type)
|
||||
inline static bool readCompoundToken
|
||||
(
|
||||
token& tok,
|
||||
const word& compoundType,
|
||||
Istream& is
|
||||
)
|
||||
{
|
||||
// The isCompound() check is not needed (already checked by caller)
|
||||
return tok.readCompoundToken(compoundType, is);
|
||||
}
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
|
||||
@ -339,11 +352,11 @@ Foam::Istream& Foam::UIPstreamBase::read(token& t)
|
||||
word val;
|
||||
if (readString(val))
|
||||
{
|
||||
if (token::compound::isCompound(val))
|
||||
{
|
||||
t = token::compound::New(val, *this).ptr();
|
||||
}
|
||||
else
|
||||
if
|
||||
(
|
||||
!token::compound::isCompound(val)
|
||||
|| !readCompoundToken(t, val, *this)
|
||||
)
|
||||
{
|
||||
t = std::move(val);
|
||||
t.setType(token::tokenType(c));
|
||||
|
||||
Reference in New Issue
Block a user