foamDictionary.C
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration | Website: https://openfoam.org
5  \\ / A nd | Copyright (C) 2016-2025 OpenFOAM Foundation
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8 License
9  This file is part of OpenFOAM.
10 
11  OpenFOAM is free software: you can redistribute it and/or modify it
12  under the terms of the GNU General Public License as published by
13  the Free Software Foundation, either version 3 of the License, or
14  (at your option) any later version.
15 
16  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
17  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
19  for more details.
20 
21  You should have received a copy of the GNU General Public License
22  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
23 
24 Application
25  foamDictionary
26 
27 Description
28  Interrogates and manipulates dictionaries.
29 
30  Supports parallel operation for decomposed dictionary files associated with
31  a case. These may be mesh or field files or any other decomposed
32  dictionaries.
33 
34 Usage
35  \b foamDictionary [OPTION] dictionary
36 
37  - \par -case <dir>
38  Select a case directory instead of the current working directory
39 
40  - \par -parallel
41  Specify case as a parallel job
42 
43  - \par -doc
44  Display the documentation in browser
45 
46  - \par -srcDoc
47  Display the source documentation in browser
48 
49  - \par -help
50  Print the usage
51 
52  - \par -entry <name>
53  Selects an entry
54 
55  - \par -keywords <name>
56  Prints the keywords (of the selected entry or of the top level if
57  no entry was selected
58 
59  - \par -rename <newName>
60  Renames the entry selected by \c -entry
61 
62  - \par -rename <newNames>
63  Renames a list of entries specified in the form:
64  "<entryName0>=<newName0>, <entryName1>=<newName1>..."
65 
66  - \par -add <value>
67  Adds the entry (should not exist yet)
68 
69  - \par -set <value>
70  Adds or replaces the entry selected by \c -entry
71 
72  - \par -set <substitutions>
73  Applies the list of substitutions specified in the form:
74  "<entry0>=<value0>, <entry1>=<value1>..."
75 
76  - \par -merge <value>
77  Merges the entry
78 
79  - \par -dict
80  Set, add or merge entry from a dictionary
81 
82  - \par -remove
83  Remove the selected entry
84 
85  - \par -diff <dictionary>
86  Write differences with respect to the specified dictionary
87  (or sub entry if -entry specified)
88 
89  - \par -expand
90  Read the specified dictionary file, expand the macros etc.
91  Writes the expanded dictionary to the output dictionary if specified
92  otherwise to standard output
93 
94  - \par -includes
95  List the \c \#include and \c \#includeIfPresent files to standard output
96 
97  - \par -create
98  Create a new dictionary if the input dictionary does not exist.
99 
100  - \par -output
101  Path name of the output dictionary, defaults to the input dictionary
102 
103  - \par -quiet
104  Operate without outputting to the terminal or raising errors. Just use
105  an exit code to indicate success or failure.
106 
107  Example usage:
108  - Change simulation to run for one timestep only:
109  \verbatim
110  foamDictionary system/controlDict -entry stopAt -set writeNow
111  \endverbatim
112 
113  - Change solver:
114  \verbatim
115  foamDictionary system/fvSolution -entry solvers/p/solver -set PCG
116  \endverbatim
117 
118  - Print bc type:
119  \verbatim
120  foamDictionary 0/U -entry boundaryField/movingWall/type
121  \endverbatim
122 
123  - Change bc parameter:
124  \verbatim
125  foamDictionary 0/U -entry boundaryField/movingWall/value \
126  -set "uniform (2 0 0)"
127  \endverbatim
128 
129  - Change bc parameter in parallel:
130  \verbatim
131  mpirun -np 4 foamDictionary 0.5/U \
132  -entry boundaryField/movingWall/value \
133  -set "uniform (2 0 0)" -parallel
134  \endverbatim
135 
136  - Change whole bc type:
137  \verbatim
138  foamDictionary 0/U -entry boundaryField/movingWall \
139  -set "{type uniformFixedValue; uniformValue (2 0 0);}"
140  \endverbatim
141 
142  - Write the differences with respect to a template dictionary:
143  \verbatim
144  foamDictionary 0/U -diff $FOAM_ETC/templates/closedVolume/0/U
145  \endverbatim
146 
147  - Write the differences in boundaryField with respect to a
148  template dictionary:
149  \verbatim
150  foamDictionary 0/U -diff $FOAM_ETC/templates/closedVolume/0/U \
151  -entry boundaryField
152  \endverbatim
153 
154  - Change patch type:
155  \verbatim
156  foamDictionary constant/polyMesh/boundary \
157  -entry entry0/fixedWalls/type -set patch
158  \endverbatim
159  This uses special parsing of Lists which stores these in the
160  dictionary with keyword 'entryDDD' where DDD is the position
161  in the dictionary (after ignoring the FoamFile entry).
162 
163  - Substitute multiple entries:
164  \verbatim
165  foamDictionary system/controlDict -set "startTime=2000, endTime=3000"
166  \endverbatim
167 
168 \*---------------------------------------------------------------------------*/
169 
170 #include "argList.H"
171 #include "Time.H"
172 #include "localIOdictionary.H"
173 #include "Pair.H"
174 #include "IFstream.H"
175 #include "OFstream.H"
176 #include "includeEntry.H"
177 #include "mergeDictionaries.H"
178 
179 using namespace Foam;
180 
181 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
182 
183 //- Read dictionary from file and return
184 // Sets stream to binary mode if specified in the optional header
185 IOstream::streamFormat readDict
186 (
187  dictionary& dict,
188  const fileName& dictFileName,
189  const bool create = false
190 )
191 {
193 
194  // Read the first entry and if it is FoamFile set the file format
195  {
196  IFstream dictFile(dictFileName);
197 
198  if (!dictFile.good())
199  {
200  if (create)
201  {
202  return dictFormat;
203  }
204  else
205  {
207  << "Cannot open file " << dictFileName
208  << exit(FatalError, 1);
209  }
210  }
211 
212  // Check if the first token in the file is "FoamFile"
213  // to avoid problems if the first entry is a variable or function
214  token firstToken;
215  dictFile.read(firstToken);
216  if (firstToken.isWord() && firstToken.wordToken() == IOobject::foamFile)
217  {
218  dictFile.putBack(firstToken);
219 
220  // Read the first entry from the dictionary
221  autoPtr<entry> firstEntry(entry::New(dictFile()));
222 
223  // If the first entry is the "FoamFile" header
224  // read and set the stream format
225  if
226  (
227  firstEntry->isDict()
228  && firstEntry->keyword() == IOobject::foamFile
229  )
230  {
231  dictFormat = IOstream::formatEnum
232  (
233  firstEntry->dict().lookup("format")
234  );
235  }
236  }
237  }
238 
239  IFstream dictFile(dictFileName, dictFormat);
240 
241  // Read and add the rest of the dictionary entries
242  // preserving the IOobject::foamFile header dictionary if present
243  dict.read(dictFile(), true);
244 
245  return dictFormat;
246 }
247 
248 
249 void remove(dictionary& dict, const dictionary& removeDict)
250 {
251  forAllConstIter(dictionary, removeDict, iter)
252  {
253  entry* entPtr = dict.lookupEntryPtr
254  (
255  iter().keyword(),
256  false,
257  false
258  );
259 
260  if (entPtr)
261  {
262  if (entPtr->isDict())
263  {
264  if (iter().isDict())
265  {
266  remove(entPtr->dict(), iter().dict());
267 
268  // Check if dictionary is empty
269  if (!entPtr->dict().size())
270  {
271  dict.remove(iter().keyword());
272  }
273  }
274  }
275  else if (!iter().isDict())
276  {
277  if (*entPtr == iter())
278  {
279  dict.remove(iter().keyword());
280  }
281  }
282  }
283  }
284 }
285 
286 
287 void rename(dictionary& dict, const string& newNames)
288 {
291  dictArgList({newNames, 0}, args, namedArgs);
292 
293  forAll(namedArgs, i)
294  {
295  const Pair<word> dAk(dictAndKeyword(namedArgs[i].first()));
296  dictionary& subDict(dict.scopedDict(dAk.first()));
297  subDict.changeKeyword(dAk.second(), word(namedArgs[i].second()));
298  }
299 }
300 
301 
302 void substitute(dictionary& dict, const string& substitutions)
303 {
306  dictArgList({substitutions, 0}, args, namedArgs);
307 
308  forAll(args, i)
309  {
310  const Pair<word> dAk(dictAndKeyword(args[i].first()));
311  dictionary& subDict(dict.scopedDict(dAk.first()));
312  IStringStream entryStream
313  (
314  dAk.second() + ';'
315  );
316  subDict.set(entry::New(entryStream).ptr());
317  }
318 
319  forAll(namedArgs, i)
320  {
321  const Pair<word> dAk(dictAndKeyword(namedArgs[i].first()));
322  dictionary& subDict(dict.scopedDict(dAk.first()));
323  IStringStream entryStream
324  (
325  dAk.second() + ' ' + namedArgs[i].second() + ';'
326  );
327  subDict.set(entry::New(entryStream).ptr());
328  }
329 }
330 
331 
332 int main(int argc, char *argv[])
333 {
334  writeInfoHeader = false;
335 
336  argList::addNote("manipulates dictionaries");
337 
338  argList::validArgs.append("dictionary file");
339 
340  argList::addBoolOption("keywords", "list keywords");
341  argList::addOption("entry", "name", "report/select the named entry");
343  (
344  "value",
345  "Print entry value"
346  );
348  (
349  "rename",
350  "name",
351  "Rename entry or list of entries"
352  );
354  (
355  "set",
356  "value",
357  "Set entry value, add new entry or apply list of substitutions"
358  );
360  (
361  "add",
362  "value",
363  "Add a new entry"
364  );
366  (
367  "merge",
368  "value",
369  "Merge entry"
370  );
372  (
373  "dict",
374  "Set, add or merge entry from a dictionary."
375  );
377  (
378  "remove",
379  "Remove the entry."
380  );
382  (
383  "diff",
384  "dict",
385  "Write differences with respect to the specified dictionary"
386  );
388  (
389  "includes",
390  "List the #include/#includeIfPresent files to standard output"
391  );
393  (
394  "expand",
395  "Read the specified dictionary file and expand the macros etc."
396  );
398  (
399  "writePrecision",
400  "label",
401  "Write with the specified precision"
402  );
404  (
405  "create",
406  "Create a new dictionary if the input dictionary does not exist."
407  );
409  (
410  "output",
411  "path name",
412  "Path name of the output dictionary"
413  );
415  (
416  "quiet",
417  "Operate without outputting to the terminal or raising errors"
418  );
419 
420  argList args(argc, argv);
421 
422  const bool listIncludes = args.optionFound("includes");
423 
424  if (listIncludes)
425  {
427  }
428 
429  // Do not expand functionEntries except during dictionary expansion
430  // with the -expand option
431  if (!args.optionFound("expand"))
432  {
434  }
435 
436  // Do not write info if the quiet option is set
437  const bool quiet = args.optionFound("quiet");
438  if (quiet) messageStream::level = 0;
439 
440  // Set write precision
441  if (args.optionFound("writePrecision"))
442  {
443  const label writePrecision = args.optionRead<label>("writePrecision");
444  IOstream::defaultPrecision(writePrecision);
445  Sout.precision(writePrecision);
447  }
448 
449  const fileName dictPath(args[1]);
450 
451  Time* runTimePtr = nullptr;
452  localIOdictionary* localDictPtr = nullptr;
453 
454  dictionary* dictPtr = nullptr;
456 
457  // When running in parallel read the dictionary as a case localIOdictionary
458  // supporting file handlers
459  if (Pstream::parRun())
460  {
461  if (!args.checkRootCase())
462  {
463  FatalError.exit();
464  }
465 
467 
468  const wordList dictPathComponents(dictPath.components());
469 
470  if (dictPathComponents.size() == 1)
471  {
473  << "File name " << dictPath
474  << " does not contain an instance path needed in parallel"
475  << exit(FatalError, 1);
476  }
477 
478  const word instance = dictPathComponents[0];
479  const fileName dictFileName
480  (
481  SubList<word>(dictPathComponents, dictPathComponents.size() - 1, 1)
482  );
483 
484  scalar time;
485  if (readScalar(instance.c_str(), time))
486  {
487  runTimePtr->setTime(time, 0);
488  }
489 
490  localDictPtr = new localIOdictionary
491  (
492  IOobject
493  (
494  dictFileName,
495  instance,
496  *runTimePtr,
499  false
500  )
501  );
502  }
503  else
504  {
505  dictPtr = new dictionary(dictPath);
506  dictFormat =
507  readDict
508  (
509  *dictPtr,
510  dictPath.isAbsolute()
511  ? dictPath
512  : args.path()/dictPath,
513  args.optionFound("create")
514  );
515  }
516 
517  dictionary& dict = localDictPtr ? *localDictPtr : *dictPtr;
518 
519  bool changed = false;
520 
521  if (listIncludes)
522  {
523  return 0;
524  }
525  else if (args.optionFound("expand") && !args.optionFound("entry"))
526  {
527  if (!args.optionFound("output"))
528  {
530  <<"//\n// " << dictPath << "\n//\n";
531 
532  // Change the format to ASCII
534  {
536  (
537  "format",
539  true
540  );
541  }
542 
543  dict.dictionary::write(Info, false);
545 
546  return 0;
547  }
548  else
549  {
550  changed = true;
551  }
552  }
553 
554  word entryName;
555  fileName diffFileName;
556  if (args.optionReadIfPresent("entry", entryName))
557  {
558  const word scopedName(entryName);
559 
560  string newValue;
561 
562  if (args.optionReadIfPresent("rename", newValue))
563  {
564  // Extract dictionary name and keyword
565  const Pair<word> dAk(dictAndKeyword(scopedName));
566 
567  dictionary& subDict(dict.scopedDict(dAk.first()));
568 
569  subDict.changeKeyword(dAk.second(), word(newValue));
570 
571  changed = true;
572  }
573  else if
574  (
575  args.optionReadIfPresent("set", newValue)
576  || args.optionReadIfPresent("add", newValue)
577  || args.optionReadIfPresent("merge", newValue)
578  )
579  {
580  const bool overwrite = args.optionFound("set");
581  const bool merge = args.optionFound("merge");
582 
583  // Extract dictionary name and keyword
584  const Pair<word> dAk(dictAndKeyword(scopedName));
585 
586  dictionary& subDict(dict.scopedDict(dAk.first()));
587 
588  entry* ePtr = nullptr;
589 
590  if (args.optionFound("dict"))
591  {
592  const fileName fromDictFileName(newValue);
593  dictionary fromDict;
594  readDict(fromDict, fromDictFileName);
595 
596  const entry* fePtr
597  (
598  fromDict.lookupScopedEntryPtr
599  (
600  scopedName,
601  false,
602  true // Support wildcards
603  )
604  );
605 
606  if (!fePtr)
607  {
609  << "Cannot find entry " << entryName
610  << " in file " << fromDictFileName
611  << exit(FatalError, 1);
612  }
613 
614  ePtr = fePtr->clone().ptr();
615  }
616  else
617  {
618  IStringStream str(string(dAk.second()) + ' ' + newValue + ';');
619  ePtr = entry::New(str).ptr();
620  }
621 
622  if (overwrite)
623  {
624  Info << "New entry " << *ePtr << endl;
625  subDict.set(ePtr);
626  }
627  else
628  {
629  subDict.add(ePtr, merge);
630  }
631  changed = true;
632  }
633  else if (args.optionFound("remove"))
634  {
635  // Extract dictionary name and keyword
636  const Pair<word> dAk(dictAndKeyword(scopedName));
637 
638  dictionary& subDict(dict.scopedDict(dAk.first()));
639  subDict.remove(dAk.second());
640  changed = true;
641  }
642  else
643  {
644  if (args.optionReadIfPresent("diff", diffFileName))
645  {
646  dictionary diffDict;
647  readDict(diffDict, diffFileName);
648 
649  const Pair<word> dAk(dictAndKeyword(scopedName));
650 
651  dictionary& subDict(dict.scopedDict(dAk.first()));
652  const dictionary& subDict2(diffDict.scopedDict(dAk.first()));
653 
654  entry* ePtr =
655  subDict.lookupEntryPtr(dAk.second(), false, true);
656  const entry* e2Ptr =
657  subDict2.lookupEntryPtr(dAk.second(), false, true);
658 
659  if (ePtr && e2Ptr)
660  {
661  if (*ePtr == *e2Ptr)
662  {
663  subDict.remove(dAk.second());
664  }
665  else if (ePtr->isDict() && e2Ptr->isDict())
666  {
667  remove(ePtr->dict(), e2Ptr->dict());
668  }
669  }
670  }
671 
672  const entry* entPtr = dict.lookupScopedEntryPtr
673  (
674  scopedName,
675  false,
676  true // Support wildcards
677  );
678 
679  if (entPtr)
680  {
681  if (args.optionFound("keywords"))
682  {
683  const dictionary& dict = entPtr->dict();
685  {
686  Info<< iter().keyword() << endl;
687  }
688  }
689  else
690  {
691  if (args.optionFound("value"))
692  {
693  if (entPtr->isStream())
694  {
695  const tokenList& tokens = entPtr->stream();
696  forAll(tokens, i)
697  {
698  Info<< tokens[i];
699  if (i < tokens.size() - 1)
700  {
701  Info<< token::SPACE;
702  }
703  }
704  Info<< endl;
705  }
706  else if (entPtr->isDict())
707  {
708  Info<< entPtr->dict();
709  }
710  }
711  else
712  {
713  Info<< *entPtr;
714  }
715  }
716  }
717  else
718  {
720  << "Cannot find entry " << entryName
721  << exit(FatalIOError, 2);
722  }
723  }
724  }
725  else if (args.optionFound("rename"))
726  {
727  const string newNames(args.optionRead<string>("rename"));
728  rename(dict, newNames);
729  changed = true;
730  }
731  else if (args.optionFound("set"))
732  {
733  const string substitutions(args.optionRead<string>("set"));
734  substitute(dict, substitutions);
735  changed = true;
736  }
737  else if (args.optionFound("merge"))
738  {
739  dictionary fromDict;
740  if (args.optionFound("dict"))
741  {
742  const fileName fromDictFileName(args.optionRead<fileName>("merge"));
743  readDict(fromDict, fromDictFileName);
744  }
745  else
746  {
747  const string substitutions(args.optionRead<string>("merge"));
748  substitute(fromDict, substitutions);
749  }
750  mergeDictionaries(dict, fromDict, false);
751  changed = true;
752  }
753  else if (args.optionFound("keywords"))
754  {
756  {
757  Info<< iter().keyword() << endl;
758  }
759  }
760  else if (args.optionReadIfPresent("diff", diffFileName))
761  {
762  dictionary diffDict;
763  readDict(diffDict, diffFileName);
764 
765  remove(dict, diffDict);
766  dict.dictionary::write(Info, false);
767  }
768  else if (!args.optionFound("output"))
769  {
770  dict.dictionary::write(Info, false);
771  }
772 
773  if (changed || args.optionFound("output"))
774  {
775  if (localDictPtr)
776  {
777  localDictPtr->regIOobject::write();
778  }
779  else if (dictPtr)
780  {
781  // Set output dict name, defaults to the name of the input dict
782  const fileName outputDictPath
783  (
784  args.optionLookupOrDefault<fileName>("output", dictPath)
785  );
786 
787  OFstream os
788  (
789  outputDictPath.isAbsolute()
790  ? outputDictPath
791  : args.path()/outputDictPath,
792  dictFormat
793  );
794 
795  if (dictPtr->found(IOobject::foamFile))
796  {
798  dictPtr->remove(IOobject::foamFile);
799  }
800  else
801  {
802  IOobject::writeBanner(os) << nl;
803  }
804 
805  dictPtr->write(os, false);
806 
808  }
809  }
810 
811  delete dictPtr;
812  delete localDictPtr;
813  delete runTimePtr;
814 
815  return 0;
816 }
817 
818 
819 // ************************************************************************* //
#define forAll(list, i)
Loop across all elements in list.
Definition: UList.H:449
#define forAllConstIter(Container, container, iter)
Iterate across all elements in the container object of type.
Definition: UList.H:492
Input from file stream.
Definition: IFstream.H:85
IOobject defines the attributes of an object for which implicit objectRegistry management is supporte...
Definition: IOobject.H:99
static Stream & writeBanner(Stream &os, bool noHint=false)
Write the standard OpenFOAM file/dictionary banner.
Definition: IOobjectI.H:45
static Stream & writeEndDivider(Stream &os)
Write the standard end file divider.
Definition: IOobjectI.H:103
static constexpr const char * foamFile
Keyword for the FoamFile header sub-dictionary.
Definition: IOobject.H:104
static bool writeHeader(Ostream &os, const IOstream::versionNumber version, const IOstream::streamFormat format, const word &type, const string &note, const fileName &location, const word &name)
Write header.
streamFormat
Enumeration for the format of data in the stream.
Definition: IOstream.H:87
static unsigned int defaultPrecision()
Return the default precision.
Definition: IOstream.H:473
static streamFormat formatEnum(const word &)
Return stream format of given format name.
Definition: IOstream.C:39
Input from memory buffer stream.
Definition: IStringStream.H:52
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
Definition: List.H:91
Output to file stream.
Definition: OFstream.H:87
virtual int precision() const
Get precision of output field.
Definition: OSstream.C:270
A List obtained as a section of another List.
Definition: SubList.H:56
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
Definition: Time.H:76
virtual void setTime(const Time &)
Reset the time and time-index to those of the given time.
Definition: Time.C:993
static word controlDictName
The default control dictionary name (normally "controlDict")
Definition: Time.H:208
static bool & parRun()
Is this a parallel run?
Definition: UPstream.H:399
Extract command arguments and options from the supplied argc and argv parameters.
Definition: argList.H:103
static void addOption(const word &opt, const string &param="", const string &usage="")
Add to an option to validOptions with usage information.
Definition: argList.C:121
static void addNote(const string &)
Add extra notes for the usage information.
Definition: argList.C:152
T optionRead(const word &opt) const
Read a value from the named option.
Definition: argListI.H:244
static void addBoolOption(const word &opt, const string &usage="")
Add to a bool option to validOptions with usage information.
Definition: argList.C:111
bool optionFound(const word &opt) const
Return true if the named option is found.
Definition: argListI.H:114
bool optionReadIfPresent(const word &opt, T &) const
Read a value from the named option if present.
Definition: argListI.H:255
bool checkRootCase() const
Check root path and case path.
Definition: argList.C:1440
fileName path() const
Return the path to the caseName.
Definition: argListI.H:66
static SLList< string > validArgs
A list of valid (mandatory) arguments.
Definition: argList.H:153
T optionLookupOrDefault(const word &opt, const T &deflt) const
Read a value from the named option if present.
Definition: argListI.H:294
An auto-pointer similar to the STL auto_ptr but with automatic casting to a reference to the type and...
Definition: autoPtr.H:51
A list of keywords followed by any number of values (e.g. words and numbers) or sub-dictionaries.
Definition: dictionary.H:162
bool read(Istream &, const bool keepHeader=false)
Read dictionary from Istream, optionally keeping the header.
Definition: dictionaryIO.C:105
const entry * lookupEntryPtr(const word &, bool recursive, bool patternMatch) const
Find and return an entry data stream pointer if present.
Definition: dictionary.C:507
void write(Ostream &, const bool subDict=true) const
Write dictionary, normally with sub-dictionary formatting.
Definition: dictionaryIO.C:214
const entry * lookupScopedEntryPtr(const word &, bool recursive, bool patternMatch) const
Find and return an entry data stream pointer if present,.
Definition: dictionary.C:696
bool remove(const word &)
Remove an entry specified by keyword.
Definition: dictionary.C:1182
const dictionary & subDict(const word &) const
Find and return a sub-dictionary.
Definition: dictionary.C:778
bool add(entry *, bool mergeEntry=false)
Add a new entry.
Definition: dictionary.C:1019
bool found(const word &, bool recursive=false, bool patternMatch=true) const
Search dictionary for given keyword.
Definition: dictionary.C:468
const dictionary & scopedDict(const word &) const
Find and return a sub-dictionary by scoped lookup.
Definition: dictionary.C:943
A keyword and a list of tokens is an 'entry'.
Definition: entry.H:68
virtual bool isDict() const
Return true if this entry is a dictionary.
Definition: entry.H:178
virtual ITstream & stream() const =0
Return token stream if this entry is a primitive entry.
static bool New(dictionary &parentDict, Istream &)
Construct from Istream and insert into dictionary.
Definition: entryIO.C:105
virtual const dictionary & dict() const =0
Return dictionary if this entry is a dictionary.
virtual autoPtr< entry > clone(const dictionary &parentDict) const =0
Construct on freestore as copy with reference to the.
virtual bool isStream() const
Return true if this entry is a stream.
Definition: entry.H:169
static int disableFunctionEntries
Definition: entry.H:102
void exit(const int errNo=1)
Exit : can be called for any error to exit program.
Definition: error.C:125
A class for handling file names.
Definition: fileName.H:82
static bool log
Report which file is included to stdout.
Definition: includeEntry.H:156
localIOdictionary derived from IOdictionary with global set false to disable parallel master reading.
A token holds items read from Istream.
Definition: token.H:74
bool isWord() const
Definition: tokenI.H:342
const word & wordToken() const
Definition: tokenI.H:347
A class for handling words, derived from string.
Definition: word.H:63
#define FatalIOErrorInFunction(ios)
Report an error message using Foam::FatalIOError.
Definition: error.H:346
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:334
int main(int argc, char *argv[])
Definition: financialFoam.C:44
static Time * runTimePtr
Definition: globalFoam.H:51
Function with which to merge one dictionary into another. Intended for user-facing dictionary merging...
const dimensionSet time
Namespace for OpenFOAM.
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition: errorManip.H:124
void dictArgList(const Tuple2< string, label > &argString, word &configName, List< Tuple2< wordRe, label >> &args, List< Tuple3< word, string, label >> &namedArgs)
Parse dictionary substitution argument list.
Definition: dictionary.C:1494
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
Definition: label.H:59
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:288
bool writeInfoHeader
messageStream Info
labelList second(const UList< labelPair > &p)
Definition: patchToPatch.C:49
labelList first(const UList< labelPair > &p)
Definition: patchToPatch.C:39
Pair< word > dictAndKeyword(const word &scopedName)
Extracts dict name and keyword.
Definition: dictionary.C:1683
bool readScalar(const char *buf, doubleScalar &s)
Read whole of buf as a scalar. Return true if successful.
Definition: doubleScalar.H:75
IOerror FatalIOError
prefixOSstream Pout(cout, "Pout")
Definition: IOstreams.H:53
error FatalError
bool mergeDictionaries(dictionary &tgtDict, const dictionary &srcDict, const bool wildcards=true, const HashTable< wordList, word > &shortcuts=HashTable< wordList, word >(0))
prefixOSstream Sout(cout, "Sout")
Definition: IOstreams.H:51
static const char nl
Definition: Ostream.H:297
dictionary dict
const bool overwrite
Definition: setNoOverwrite.H:1
Foam::argList args(argc, argv)