ENH: subdict output with leading name (issue #255)

- Introduce dictionary::writeEntries for better code-reuse.

  Before
  ======
      os << nl << indent << "name";
      dict.write(os);

  After
  =====
      dict.write(os, "name");
This commit is contained in:
Mark Olesen
2016-06-09 18:33:56 +01:00
parent 06f22a9bf3
commit 6d5db96ad9
4 changed files with 40 additions and 19 deletions

View File

@ -48,14 +48,13 @@ int main(int argc, char *argv[])
{
dictionary dict;
dict.add("aaOPENMPIcc", 1);
dict.add(word("aa" + getEnv("WM_MPLIB") + "cc"), 16);
string s("DDD${aa${WM_MPLIB}cc}EEE");
stringOps::inplaceExpand(s, dict, true, false);
Info<< "variable expansion:" << s << endl;
}
Info<< nl
<< "FOAM_CASE=" << getEnv("FOAM_CASE") << nl
<< "FOAM_CASENAME=" << getEnv("FOAM_CASENAME") << nl
@ -65,7 +64,9 @@ int main(int argc, char *argv[])
{
{
dictionary dict1(IFstream("testDict")());
Info<< "dict1: " << dict1 << nl
dict1.writeEntry("dict1", Info);
Info<< nl
<< "toc: " << dict1.toc() << nl
<< "keys: " << dict1.keys() << nl
<< "patterns: " << dict1.keys(true) << endl;
@ -89,14 +90,14 @@ int main(int argc, char *argv[])
<< "no = " << dict4.name() << " " << dict4.toc() << endl;
}
IOobject::writeDivider(Info);
{
dictionary dict(IFstream("testDictRegex")());
dict.add(keyType("fooba[rz]", true), "anything");
Info<< "dict:" << dict << nl
dict.writeEntry("testDictRegex", Info);
Info<< nl
<< "toc: " << dict.toc() << nl
<< "keys: " << dict.keys() << nl
<< "patterns: " << dict.keys(true) << endl;