ENH: improve infrastructure for detecting excess tokens (issue #762)

- Always used for optional dictionary entries, since these are individual
  values, and not meant to be embedded in a larger stream of tokens.

  Methods:
     - lookupOrDefault, lookupOrAddDefault, lookupOrDefaultCompat
     - readIfPresent, readIfPresentCompat

- Handling mandatory dictionary entries is slightly more complex,
  since these may be part of larger stream of tokens, and are often
  used in a constructor context. For example,

      word modelType(dict.lookup("type"));

  Or they are used without a definite context. For example,

      dict.lookup("format") >> outputFormat;

  Newly introduced methods for mandatory dictionary entries:
     - get, getCompat
     - read, readCompat

  In a constructor or assignment context:

      word modelType(dict.get<word>("type"));
      outputFormat = dict.lookup("format");

  without copy/move (similar to readIfPresent):

      dict.read("format", outputFormat);
This commit is contained in:
Mark Olesen
2018-06-01 11:55:57 +02:00
parent a6f524b1df
commit 511b35629d
8 changed files with 279 additions and 220 deletions

View File

@ -139,15 +139,15 @@ void Foam::IOerror::SafeFatalIOError
else
{
std::cerr
<< std::endl
<< "--> FOAM FATAL IO ERROR:" << std::endl
<< nl
<< "--> FOAM FATAL IO ERROR:" << nl
<< msg
<< std::endl
<< nl
<< "file: " << ioStream.name()
<< " at line " << ioStream.lineNumber() << '.'
<< std::endl << std::endl
<< nl << nl
<< " From function " << functionName
<< std::endl
<< nl
<< " in file " << sourceFileName
<< " at line " << sourceFileLineNumber << '.'
<< std::endl;