dictionaryIO.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) 2011-2026 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 \*---------------------------------------------------------------------------*/
25 
26 #include "dictionary.H"
27 #include "IOobject.H"
28 #include "HashSet.H"
29 #include "inputModeEntry.H"
30 #include "codeIncludeEntry.H"
31 #include "stringOps.H"
32 #include "etcFiles.H"
33 #include "wordAndDictionary.H"
34 #include "ITstream.H"
35 #include "OTstream.H"
36 #include "OSspecific.H"
37 
38 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
39 
41 (
42  const fileName& name,
43  const dictionary& parentDict,
44  Istream& is
45 )
46 :
47  dictionaryName(pathName(parentDict, name)),
48  parent_(parentDict),
49  filePtr_(nullptr)
50 {
51  read(is);
52 }
53 
54 
55 Foam::dictionary::dictionary(Istream& is, const bool keepHeader)
56 :
57  dictionaryName(is.name()),
58  parent_(dictionary::null),
59  filePtr_(nullptr)
60 {
61  // Reset input mode as this is a "top-level" dictionary
63 
64  read(is, keepHeader);
65 }
66 
67 
69 (
70  const fileName& fName,
71  const dictionary& parentDict
72 )
73 :
74  dictionary(fName),
75  global_(parentDict.topDict().global())
76 {
77  autoPtr<ISstream> ifsPtr
78  (
79  fileHandler().NewIFstream(fName)
80  );
81  ISstream& ifs = ifsPtr();
82 
83  if (!ifs || !ifs.good())
84  {
85  FatalIOErrorInFunction(parentDict)
86  << "Included dictionary file " << fName
87  << " cannot be found for dictionary " << parentDict.name()
88  << exit(FatalIOError);
89  }
90 
91  read(ifs);
92 }
93 
94 
95 // * * * * * * * * * * * * * * * * Selectors * * * * * * * * * * * * * * * * //
96 
98 {
99  return autoPtr<dictionary>(new dictionary(is));
100 }
101 
102 
103 // * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
104 
105 bool Foam::dictionary::read(Istream& is, const bool keepHeader)
106 {
107  // Check for empty dictionary
108  if (is.eof())
109  {
110  return true;
111  }
112 
113  if (!is.good())
114  {
116  << "Istream not OK for reading dictionary "
117  << exit(FatalIOError);
118 
119  return false;
120  }
121 
122  // Cache the file/stream pointer
123  const Istream* filePtr0 = filePtr_;
124 
125  // Set the file/stream pointer to the given stream
126  filePtr_ = &is;
127 
128  token currToken(is);
129  if (currToken != token::BEGIN_BLOCK)
130  {
131  is.putBack(currToken);
132  }
133 
134  while (!is.eof() && entry::New(*this, is))
135  {}
136 
137  // normally remove the FoamFile header entry if it exists
138  if (!keepHeader)
139  {
141  }
142 
143  if (is.bad())
144  {
146  << "Istream not OK after reading dictionary " << name()
147  << endl;
148 
149  return false;
150  }
151 
152  // Reset the file/stream pointer to the original
153  filePtr_ = filePtr0;
154 
155  return true;
156 }
157 
158 
160 {
161  if (&parent_ != &dictionary::null)
162  {
163  return parent_.global();
164  }
165  else
166  {
167  return false;
168  }
169 }
170 
171 
173 {
174  word varName = keyword(1, keyword.size()-1);
175 
176  // lookup the variable name in the given dictionary
177  const entry* ePtr = lookupEntryPtr(varName, true, true);
178 
179  // if defined insert its entries into this dictionary
180  if (ePtr != nullptr)
181  {
182  const dictionary& addDict = ePtr->dict();
183 
184  forAllConstIter(IDLList<entry>, addDict, iter)
185  {
186  add(iter());
187  }
188 
189  return true;
190  }
191 
192  return false;
193 }
194 
195 
196 
197 // * * * * * * * * * * * * * * Istream Operator * * * * * * * * * * * * * * //
198 
200 {
201  // Reset input mode assuming this is a "top-level" dictionary
203 
204  dict.clear();
205  dict.name() = is.name();
206  dict.read(is);
207 
208  return is;
209 }
210 
211 
212 // * * * * * * * * * * * * * * Ostream Operator * * * * * * * * * * * * * * //
213 
215 {
216  if (subDict)
217  {
218  os << nl << indent << token::BEGIN_BLOCK << incrIndent << nl;
219  }
220 
221  forAllConstIter(IDLList<entry>, *this, iter)
222  {
223  const entry& e = *iter;
224 
225  // Write entry
226  os << e;
227 
228  // Add extra new line between entries for "top-level" dictionaries
229  if (!subDict && parent() == dictionary::null && (&e != last()))
230  {
231  os << nl;
232  }
233 
234  // Check stream before going to next entry.
235  if (!os.good())
236  {
238  << "Can't write entry " << iter().keyword()
239  << " for dictionary " << name()
240  << endl;
241  }
242  }
243 
244  if (subDict)
245  {
246  os << decrIndent << indent << token::END_BLOCK << endl;
247  }
248 }
249 
250 
252 {
253  dict.write(os, true);
254  return os;
255 }
256 
257 
258 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
259 
260 namespace Foam
261 {
262 
263 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
264 
267 {
268  const wordRe unsetPattern("<.*>");
269  unsetPattern.compile();
270 
271  List<Tuple2<word, string>> unsetArgs;
272 
274  {
275  if (iter().isStream())
276  {
277  ITstream& its = iter().stream();
278  OStringStream oss;
279  bool isUnset = false;
280 
281  forAll(its, i)
282  {
283  oss << its[i];
284  if (its[i].isWord() && unsetPattern.match(its[i].wordToken()))
285  {
286  isUnset = true;
287  }
288  }
289 
290  if (isUnset)
291  {
292  unsetArgs.append
293  (
295  (
296  iter().keyword(),
297  oss.str()
298  )
299  );
300  }
301  }
302  else
303  {
304  List<Tuple2<word, string>> subUnsetArgs =
305  unsetConfigEntries(iter().dict());
306 
307  forAll(subUnsetArgs, i)
308  {
309  unsetArgs.append
310  (
312  (
313  iter().keyword() + '/' + subUnsetArgs[i].first(),
314  subUnsetArgs[i].second()
315  )
316  );
317  }
318  }
319  }
320 
321  return unsetArgs;
322 }
323 
324 
326 (
327  const fileName& dir,
328  HashSet<word>& foMap
329 )
330 {
331  // Search specified directory for configuration files
332  {
333  fileNameList foFiles(fileHandler().readDir(dir));
334  forAll(foFiles, f)
335  {
336  if (foFiles[f].ext().empty())
337  {
338  foMap.insert(foFiles[f]);
339  }
340  }
341  }
342 
343  // Recurse into sub-directories
344  {
346  forAll(foDirs, fd)
347  {
348  listConfigFiles(dir/foDirs[fd], foMap);
349  }
350  }
351 }
352 
353 
354 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
355 
356 } // End namespace Foam
357 
358 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
359 
361 (
362  const word& configName,
363  const fileName& configFilesPath,
364  const word& configFilesDir,
365  const word& region
366 )
367 {
368  // First check if there is a configuration file in the
369  // region configFilesDir directory
370  {
371  const fileName dictFile
372  (
373  stringOps::expandEnvVar("$FOAM_CASE")
374  /configFilesDir/region/configName
375  );
376 
377  if (isFile(dictFile))
378  {
379  return dictFile;
380  }
381  }
382 
383  // Next, if the region is specified, check if there is a configuration file
384  // in the global configFilesDir directory
385  if (region != word::null)
386  {
387  const fileName dictFile
388  (
389  stringOps::expandEnvVar("$FOAM_CASE")/configFilesDir/configName
390  );
391 
392  if (isFile(dictFile))
393  {
394  return dictFile;
395  }
396  }
397 
398  // Finally, check etc directories
399  {
400  const fileNameList etcDirs(findEtcDirs(configFilesPath));
401 
402  forAll(etcDirs, i)
403  {
404  const fileName dictFile(search(configName, etcDirs[i]));
405 
406  if (!dictFile.empty())
407  {
408  return dictFile;
409  }
410  }
411  }
412 
413  return fileName::null;
414 }
415 
416 
418 (
419  const fileName& configFilesPath
420 )
421 {
422  HashSet<word> foMap;
423 
424  fileNameList etcDirs(findEtcDirs(configFilesPath));
425 
426  forAll(etcDirs, ed)
427  {
428  listConfigFiles(etcDirs[ed], foMap);
429  }
430 
431  return foMap.sortedToc();
432 }
433 
434 
436 (
437  const string& arg,
438  dictionary& dict,
439  const label lineNumber
440 )
441 {
442  // Add a temporary dummy_ entry to set the arg lineNumber in dict
443  dict.set(primitiveEntry("dummy_", token(word("<dummy>"), lineNumber)));
444 
445  string expandedArg(arg);
446  stringOps::inplaceExpandEntry(expandedArg, dict, true, false);
447 
448  // Remove temporary dummy_ entry
449  dict.remove("dummy_");
450 
451  return expandedArg;
452 }
453 
454 
456 (
457  dictionary& dict,
458  const word& keyword,
459  const string& value,
460  const label lineNumber
461 )
462 {
463  IStringStream entryStream(dict.name(), keyword + ' ' + value + ';');
464  entryStream.lineNumber() = lineNumber;
465  autoPtr<entry> argEntry(entry::New(entryStream));
466  if (argEntry.valid())
467  {
468  dict.set(argEntry.ptr());
469  }
470  else
471  {
473  << "Cannot construct argument entry from string "
474  << entryStream.str() << nl
475  << " on line " << lineNumber << " of dictionary " << dict.name()
476  << exit(FatalIOError);
477  }
478 }
479 
480 
482 (
483  const word& configType,
484  const Tuple2<string, label>& argStringLine,
485  dictionary& parentDict,
486  const fileName& configFilesPath,
487  const word& configFilesDir,
488  const word& region,
489  const string& command
490 )
491 {
492  word funcType;
495 
496  dictArgList(argStringLine, funcType, args, namedArgs);
497 
498  // Search for the configuration file
499  fileName path = findConfigFile
500  (
501  funcType,
502  configFilesPath,
503  configFilesDir,
504  region
505  );
506 
507  if (path == fileName::null)
508  {
509  if (funcType == word::null)
510  {
511  FatalIOErrorInFunction(parentDict)
512  << "configuration file name not specified"
513  << nl << nl
514  << "Available configured objects:"
515  << listAllConfigFiles(configFilesPath)
516  << exit(FatalIOError);
517  }
518  else
519  {
520  FatalIOErrorInFunction(parentDict)
521  << "Cannot find configuration file "
522  << funcType << nl << nl
523  << "Available configured objects:"
524  << listAllConfigFiles(configFilesPath)
525  << exit(FatalIOError);
526  }
527 
528  return false;
529  }
530 
531  // Read the configuration file
532  autoPtr<ISstream> fileStreamPtr(fileHandler().NewIFstream(path));
533  ISstream& fileStream = fileStreamPtr();
534 
535  // Delay processing the functionEntries
536  // until after the argument entries have been added
538  dictionary funcDict(fileName(funcType), parentDict, fileStream);
540 
541  // Store the funcDict as read for error reporting context
542  const dictionary funcDict0(funcDict);
543 
544  // Insert the 'field' and/or 'fields' and 'objects' entries corresponding
545  // to both the arguments and the named arguments
547  bool print = false;
548  forAll(args, i)
549  {
550  if (const_cast<const wordRe&>(args[i].first()).strip(" \n") == "print")
551  {
552  print = true;
553  }
554  else
555  {
556  fieldArgs.append
557  (
559  (
560  expandArg(args[i].first(), funcDict, args[i].second()),
562  )
563  );
564  }
565  }
566  forAll(namedArgs, i)
567  {
568  if (namedArgs[i].first() == "field")
569  {
570  IStringStream iss(namedArgs[i].second());
571  fieldArgs.append(wordAndDictionary(iss));
572  }
573  if
574  (
575  namedArgs[i].first() == "fields"
576  || namedArgs[i].first() == "objects"
577  )
578  {
579  IStringStream iss(namedArgs[i].second());
580  fieldArgs.append(List<wordAndDictionary>(iss));
581  }
582  }
583  if (fieldArgs.size() == 1)
584  {
585  funcDict.set("field", fieldArgs[0].first());
586  funcDict.merge(fieldArgs[0].second());
587  }
588  if (fieldArgs.size() >= 1)
589  {
590  funcDict.set("fields", fieldArgs);
591  funcDict.set("objects", fieldArgs);
592  }
593 
594  // Insert non-field arguments
595  forAll(namedArgs, i)
596  {
597  if
598  (
599  namedArgs[i].first() != "field"
600  && namedArgs[i].first() != "fields"
601  && namedArgs[i].first() != "objects"
602  && namedArgs[i].first() != "funcName"
603  && namedArgs[i].first() != "name"
604  )
605  {
606  const Pair<word> dAk(dictAndKeyword(namedArgs[i].first()));
607  dictionary& subDict(funcDict.scopedDict(dAk.first()));
609  (
610  subDict,
611  dAk.second(),
612  expandArg
613  (
614  namedArgs[i].second(),
615  funcDict,
616  namedArgs[i].third()
617  ),
618  namedArgs[i].third()
619  );
620  }
621  }
622 
623  // Insert the region name if specified
624  if (region != word::null)
625  {
626  funcDict.set("region", region);
627  }
628 
629  // Set the name of the entry to that specified by the optional
630  // name argument otherwise automatically generate a unique name
631  // from the type and arguments
632  word entryName(funcType);
633  if (args.size() || namedArgs.size())
634  {
635  bool named = false;
636  forAll(namedArgs, i)
637  {
638  if
639  (
640  namedArgs[i].first() == "funcName"
641  || namedArgs[i].first() == "name"
642  )
643  {
644  entryName = expandArg
645  (
646  namedArgs[i].second(),
647  funcDict,
648  namedArgs[i].third()
649  );
650  entryName.strip(" \n");
651  named = true;
652  }
653  }
654 
655  if (!named)
656  {
657  entryName += '(';
658  forAll(args, i)
659  {
660  if (i > 0)
661  {
662  entryName += ',';
663  }
664  entryName += args[i].first();
665  }
666  forAll(namedArgs, i)
667  {
668  if (args.size() || i > 0)
669  {
670  entryName += ',';
671  }
672  entryName += namedArgs[i].first();
673  entryName += '=';
674  entryName += expandArg
675  (
676  namedArgs[i].second(),
677  funcDict,
678  namedArgs[i].third()
679  );
680  }
681  entryName += ')';
682  string::stripInvalid<word>(entryName);
683  }
684  }
685 
686  // Check for anything in the configuration that has not been set
687  List<Tuple2<word, string>> unsetArgs = unsetConfigEntries(funcDict);
688  bool hasUnsetError = false;
689  forAll(unsetArgs, i)
690  {
691  if
692  (
693  unsetArgs[i].first() != "fields"
694  && unsetArgs[i].first() != "objects"
695  )
696  {
697  hasUnsetError = true;
698  }
699  }
700  if (!hasUnsetError)
701  {
702  forAll(unsetArgs, i)
703  {
704  funcDict.set(unsetArgs[i].first(), wordList());
705  }
706  }
707  else
708  {
709  FatalIOErrorInFunction(funcDict0)
710  << nl;
711 
712  forAll(unsetArgs, i)
713  {
714  FatalIOErrorInFunction(funcDict0)
715  << "Essential value for keyword '" << unsetArgs[i].first()
716  << "' not set" << nl;
717  }
718 
719  FatalIOErrorInFunction(funcDict0)
720  << nl << "In " << configType << " entry:" << nl
721  << " " << argStringLine.first().c_str() << nl;
722 
723  if (command != string::null)
724  {
725  FatalIOErrorInFunction(funcDict0)
726  << nl << "In command:" << nl
727  << " " << command.c_str() << endl;
728  }
729 
730  if (argStringLine.second() >= 0)
731  {
732  FatalIOErrorInFunction(funcDict0)
733  << nl << "In dictionary:" << nl
734  << " " << parentDict.name().c_str()
735  << " starting at line " << argStringLine.second() << nl;
736  }
737 
738  FatalIOErrorInFunction(funcDict0)
739  << nl << "Including file:" << nl
740  << " " << path.c_str() << nl;
741 
742  word funcType;
745  dictArgList(argStringLine, funcType, args, namedArgs);
746 
747  string argList;
748  forAll(args, i)
749  {
750  args[i].first().strip(" \n");
751  argList += (argList.size() ? ", " : "") + args[i].first();
752  }
753  forAll(namedArgs, i)
754  {
755  namedArgs[i].second().strip(" \n");
756  argList +=
757  (argList.size() ? ", " : "")
758  + namedArgs[i].first() + " = " + namedArgs[i].second();
759  }
760  forAll(unsetArgs, i)
761  {
762  unsetArgs[i].second().strip(" \n");
763  argList +=
764  (argList.size() ? ", " : "")
765  + unsetArgs[i].first() + " = " + unsetArgs[i].second();
766  }
767 
768  FatalIOErrorInFunction(funcDict0)
769  << nl << "The " << configType << " entry should be:" << nl
770  << " " << funcType << '(' << argList.c_str() << ')'
771  << exit(FatalIOError);
772  }
773 
774  // Expand the funcDict executing the functionEntries
775  // now that the argument entries have been added
776  dictionary funcArgsDict;
777  funcArgsDict.add(entryName, funcDict);
778 
779  {
780  OTstream os(fileStream.name());
781  funcArgsDict.write(os);
782  funcArgsDict = dictionary
783  (
784  funcType,
785  funcDict,
786  ITstream(os.name(), os)()
787  );
788  }
789 
790  // Merge this configuration dictionary into parentDict
791  parentDict.merge(funcArgsDict);
792  parentDict.subDict(entryName).name() = funcDict.name();
793 
794  if (print)
795  {
796  printDictionary::set(parentDict.subDict(entryName));
797  }
798 
799  return true;
800 }
801 
802 
803 // * * * * * * * * * * * * * * * IOstream Functions * * * * * * * * * * * * //
804 
805 void Foam::writeEntry(Ostream& os, const dictionary& value)
806 {
807  os << value;
808 }
809 
810 
811 // ************************************************************************* //
Functions used by OpenFOAM that are specific to POSIX compliant operating systems and need to be repl...
#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
A 1D vector of objects of type <T> that resizes itself as necessary to accept the new objects.
Definition: DynamicList.H:78
DynamicList< T, SizeInc, SizeMult, SizeDiv > & append(const T &)
Append an element at the end of the list.
Definition: DynamicListI.H:296
A HashTable with keys but without contents.
Definition: HashSet.H:62
bool insert(const Key &key)
Insert a new entry.
Definition: HashSet.H:109
List< Key > sortedToc() const
Return the table of contents as a sorted list.
Definition: HashTable.C:242
Template class for intrusive linked lists.
Definition: ILList.H:67
static constexpr const char * foamFile
Keyword for the FoamFile header sub-dictionary.
Definition: IOobject.H:104
label lineNumber() const
Return current stream line number.
Definition: IOstream.H:450
virtual const fileName & name() const
Return the name of the stream.
Definition: IOstream.H:297
bool bad() const
Return true if stream is corrupted.
Definition: IOstream.H:351
bool good() const
Return true if next operation might succeed.
Definition: IOstream.H:333
Generic input stream.
Definition: ISstream.H:55
virtual const fileName & name() const
Return the name of the stream.
Definition: ISstream.H:121
Input from memory buffer stream.
Definition: IStringStream.H:52
string str() const
Return the string.
Input token stream.
Definition: ITstream.H:56
An Istream is an abstract base class for all input systems (streams, files, token lists etc)....
Definition: Istream.H:60
bool good() const
Return true if next operation might succeed.
Definition: Istream.H:101
void putBack(const token &)
Put back token.
Definition: Istream.C:30
bool eof() const
Return true if end of input seen.
Definition: Istream.H:107
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
void append(const T &)
Append an element at the end of the list.
Definition: ListI.H:178
void size(const label)
Override size to be inconsistent with allocated storage.
Definition: ListI.H:164
Output to memory buffer stream.
Definition: OStringStream.H:52
string str() const
Return the string.
Output token stream.
Definition: OTstream.H:56
virtual const fileName & name() const
Return the name of the stream.
Definition: OTstream.H:86
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:57
const Type & second() const
Return second.
Definition: PairI.H:121
const Type & first() const
Return first.
Definition: PairI.H:107
A 2-tuple for storing two objects of different types.
Definition: Tuple2.H:66
const Type2 & second() const
Return second.
Definition: Tuple2.H:131
const Type1 & first() const
Return first.
Definition: Tuple2.H:119
T * last()
Return the last entry.
Definition: UILList.H:121
T * first()
Return the first entry.
Definition: UILList.H:109
T & first()
Return the first element of the list.
Definition: UListI.H:114
Extract command arguments and options from the supplied argc and argv parameters.
Definition: argList.H:103
label size() const
Return the number of arguments.
Definition: argListI.H:90
An auto-pointer similar to the STL auto_ptr but with automatic casting to a reference to the type and...
Definition: autoPtr.H:51
bool valid() const
Return true if the autoPtr valid (ie, the pointer is set)
Definition: autoPtrI.H:83
T * ptr()
Return object pointer for reuse.
Definition: autoPtrI.H:90
const fileName & name() const
Return the dictionary name.
Definition: dictionary.H:111
includedDictionary(const fileName &fName, const dictionary &parentDict)
Construct an included dictionary for the given parent.
Definition: dictionaryIO.C:69
A list of keywords followed by any number of values (e.g. words and numbers) or sub-dictionaries.
Definition: dictionary.H:162
dictionary()
Construct top-level dictionary null.
Definition: dictionary.C:255
virtual bool global() const
Return true if the dictionary global,.
Definition: dictionaryIO.C:159
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
bool substituteKeyword(const word &keyword)
Substitute the given keyword prepended by '$' with the.
Definition: dictionaryIO.C:172
void write(Ostream &, const bool subDict=true) const
Write dictionary, normally with sub-dictionary formatting.
Definition: dictionaryIO.C:214
bool remove(const word &)
Remove an entry specified by keyword.
Definition: dictionary.C:1182
const dictionary & parent() const
Return the parent dictionary.
Definition: dictionary.H:348
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
const dictionary & scopedDict(const word &) const
Find and return a sub-dictionary by scoped lookup.
Definition: dictionary.C:943
static const dictionary null
Null dictionary.
Definition: dictionary.H:261
static autoPtr< dictionary > New(Istream &)
Construct top-level dictionary on freestore from Istream.
Definition: dictionaryIO.C:97
bool merge(const dictionary &)
Merge entries from the given dictionary.
Definition: dictionary.C:1313
A keyword and a list of tokens is an 'entry'.
Definition: entry.H:68
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.
static int disableFunctionEntries
Definition: entry.H:102
A class for handling file names.
Definition: fileName.H:82
static const fileName null
An empty fileName.
Definition: fileName.H:97
static void clear()
Reset the inputMode to default (ie, merge)
A keyword and a list of tokens is a 'primitiveEntry'. An primitiveEntry can be read,...
static void set(const dictionary &dict)
Set the dictionary to be printed.
A class for handling character strings derived from std::string.
Definition: string.H:79
static const string null
An empty string.
Definition: string.H:88
void strip(const string &)
Strip characters from the start and end of the string.
Definition: string.C:265
A token holds items read from Istream.
Definition: token.H:74
@ BEGIN_BLOCK
Definition: token.H:114
@ END_BLOCK
Definition: token.H:115
Tuple of a word and dictionary, used to read in per-field options for function objects in the followi...
A wordRe is a word, but can also have a regular expression for matching words.
Definition: wordRe.H:77
bool compile() const
Compile the regular expression.
Definition: wordReI.H:161
bool match(const std::string &, bool literalMatch=false) const
Smart match as regular expression or as a string.
Definition: wordReI.H:202
A class for handling words, derived from string.
Definition: word.H:63
static const word null
An empty word.
Definition: word.H:78
#define FatalIOErrorInFunction(ios)
Report an error message using Foam::FatalIOError.
Definition: error.H:346
Functions to search 'etc' directories for configuration files etc.
#define WarningInFunction
Report a warning using Foam::Warning.
#define InfoInFunction
Report an information message using Foam::Info.
dictionary & configDict()
The central control dictionary.
Definition: debug.C:117
string expandEnvVar(const string &, const bool allowEmpty=false)
Expand all occurrences of environment variables and paths.
Definition: stringOps.C:241
string & inplaceExpandEntry(string &s, const dictionary &dict, const bool allowEnvVars, const bool allowEmpty, const char sigil='$')
Inplace expand occurrences of variables according to the dictionary.
Definition: stringOps.C:760
Namespace for OpenFOAM.
bool isFile(const fileName &, const bool checkVariants=true, const bool followLink=true)
Does the name exist as a file in the file system?
Definition: POSIX.C:555
const fileOperation & fileHandler()
Get current file handler.
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition: errorManip.H:124
List< word > wordList
A List of words.
Definition: fileName.H:54
const doubleScalar e
Definition: doubleScalar.H:106
fileName findConfigFile(const word &configName, const fileName &configFilesPath, const word &configFilesDir, const word &region=word::null)
Search for configuration file for given region.
Definition: dictionaryIO.C:361
Istream & operator>>(Istream &, pointEdgeDist &)
Definition: pointEdgeDist.C:41
Ostream & decrIndent(Ostream &os)
Decrement the indent level.
Definition: Ostream.H:272
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
void listConfigFiles(const fileName &dir, HashSet< word > &foMap)
Definition: dictionaryIO.C:326
wordList listAllConfigFiles(const fileName &configFilesPath)
Return the list of configuration files in.
Definition: dictionaryIO.C:418
const fvMesh & region(const dictionary &dict)
Cast the give dictionary to the corresponding region fvMesh.
Definition: fvMesh.C:1831
labelList second(const UList< labelPair > &p)
Definition: patchToPatch.C:49
Ostream & incrIndent(Ostream &os)
Increment the indent level.
Definition: Ostream.H:265
Pair< word > dictAndKeyword(const word &scopedName)
Extracts dict name and keyword.
Definition: dictionary.C:1683
void addArgEntry(dictionary &dict, const word &keyword, const string &value, const label lineNumber)
Add the keyword value pair to dict.
Definition: dictionaryIO.C:456
Foam::List< Foam::Tuple2< Foam::word, Foam::string > > unsetConfigEntries(const dictionary &configDict)
Definition: dictionaryIO.C:266
IOerror FatalIOError
fileNameList findEtcDirs(const fileName &local=fileName::null)
Search for directories from user/group/shipped directories.
Definition: etcFiles.C:32
word name(const LagrangianState state)
Return a string representation of a Lagrangian state enumeration.
Ostream & operator<<(Ostream &os, const fvConstraints &constraints)
Ostream & indent(Ostream &os)
Indent stream.
Definition: Ostream.H:243
void writeEntry(Ostream &os, const word &key, const DimensionedFieldFunction< DimensionedFieldType > &f)
static const char nl
Definition: Ostream.H:297
fileNameList readDir(const fileName &, const fileType=fileType::file, const bool filterVariants=true, const bool followLink=true)
Read a directory and return the entries as a string list.
Definition: POSIX.C:662
string expandArg(const string &arg, dictionary &dict, const label lineNumber)
Expand arg within the dict context and return.
Definition: dictionaryIO.C:436
fileName search(const word &file, const fileName &directory)
Recursively search the given directory for the file.
bool readConfigFile(const word &configType, const Tuple2< string, label > &argString, dictionary &parentDict, const fileName &configFilesPath, const word &configFilesDir, const word &region=word::null, const string &command=string::null)
Read the specified configuration file.
Definition: dictionaryIO.C:482
labelList f(nPoints)
dictionary dict
Foam::argList args(argc, argv)