dictionary.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-2021 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 "primitiveEntry.H"
28 #include "dictionaryEntry.H"
29 #include "regExp.H"
30 #include "OSHA1stream.H"
31 #include "DynamicList.H"
32 #include "inputSyntaxEntry.H"
33 #include "fileOperation.H"
34 #include "stringOps.H"
35 
36 /* * * * * * * * * * * * * * * Static Member Data * * * * * * * * * * * * * */
37 
38 namespace Foam
39 {
40  defineTypeNameAndDebug(dictionary, 0);
41 }
42 
44 
46 (
47  Foam::debug::infoSwitch("writeOptionalEntries", 0)
48 );
49 
50 
51 // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
52 
53 const Foam::entry* Foam::dictionary::lookupDotScopedSubEntryPtr
54 (
55  const word& keyword,
56  bool recursive,
57  bool patternMatch
58 ) const
59 {
60  string::size_type dotPos = keyword.find('.');
61 
62  if (dotPos == string::npos)
63  {
64  // Non-scoped lookup
65  return lookupEntryPtr(keyword, recursive, patternMatch);
66  }
67  else
68  {
69  if (dotPos == 0)
70  {
71  // Starting with a '.'. Go up for every 2nd '.' found
72 
73  const dictionary* dictPtr = this;
74 
75  string::size_type begVar = dotPos + 1;
76  string::const_iterator iter = keyword.begin() + begVar;
77  string::size_type endVar = begVar;
78  while (iter != keyword.end() && *iter == '.')
79  {
80  ++iter;
81  ++endVar;
82 
83  // Go to parent
84  if (&dictPtr->parent_ == &dictionary::null)
85  {
87  << "No parent of current dictionary"
88  << " when searching for "
89  << keyword.substr(begVar, keyword.size() - begVar)
90  << exit(FatalIOError);
91  }
92  dictPtr = &dictPtr->parent_;
93  }
94 
95  return dictPtr->lookupScopedSubEntryPtr
96  (
97  keyword.substr(endVar),
98  false,
99  patternMatch
100  );
101  }
102  else
103  {
104  // Extract the first word
105  word firstWord = keyword.substr(0, dotPos);
106 
107  const entry* entPtr = lookupDotScopedSubEntryPtr
108  (
109  firstWord,
110  false, // recursive
111  patternMatch
112  );
113 
114  if (!entPtr)
115  {
116  // Fall back to finding key with '.' so e.g. if keyword is
117  // a.b.c.d it would try
118  // a.b, a.b.c, a.b.c.d
119 
120  string::size_type nextDotPos = keyword.find
121  (
122  '.',
123  dotPos + 1
124  );
125 
126  while (true)
127  {
128  const entry* subEntPtr = lookupEntryPtr
129  (
130  keyword.substr(0, nextDotPos),
131  false, // recursive,
132  patternMatch
133  );
134  if (nextDotPos == string::npos)
135  {
136  // Parsed the whole word. Return entry or null.
137  return subEntPtr;
138  }
139 
140  if (subEntPtr && subEntPtr->isDict())
141  {
142  return subEntPtr->dict().lookupDotScopedSubEntryPtr
143  (
144  keyword.substr
145  (
146  nextDotPos,
147  keyword.size() - nextDotPos
148  ),
149  false,
150  patternMatch
151  );
152  }
153 
154  nextDotPos = keyword.find('.', nextDotPos + 1);
155  }
156  }
157 
158  if (entPtr->isDict())
159  {
160  return entPtr->dict().lookupDotScopedSubEntryPtr
161  (
162  keyword.substr(dotPos, keyword.size() - dotPos),
163  false,
164  patternMatch
165  );
166  }
167  else
168  {
169  return nullptr;
170  }
171  }
172  }
173 }
174 
175 
176 const Foam::entry* Foam::dictionary::lookupSlashScopedSubEntryPtr
177 (
178  const word& keyword,
179  bool recursive,
180  bool patternMatch
181 ) const
182 {
183  string::size_type slashPos = keyword.find('/');
184 
185  if (slashPos == string::npos)
186  {
187  // Non-scoped lookup
188  return lookupEntryPtr(keyword, recursive, patternMatch);
189  }
190  else
191  {
192  // Extract the first word
193  word firstWord = keyword.substr(0, slashPos);
194  slashPos++;
195 
196  if (firstWord == ".")
197  {
198  return lookupScopedSubEntryPtr
199  (
200  keyword.substr(slashPos),
201  false,
202  patternMatch
203  );
204  }
205  else if (firstWord == "..")
206  {
207  // Go to parent
208  if (&parent_ == &dictionary::null)
209  {
211  << "No parent of current dictionary"
212  << " when searching for "
213  << keyword.substr(slashPos, keyword.size() - slashPos)
214  << exit(FatalIOError);
215  }
216 
217  return parent_.lookupScopedSubEntryPtr
218  (
219  keyword.substr(slashPos),
220  false,
221  patternMatch
222  );
223  }
224  else
225  {
226  const entry* entPtr = lookupScopedSubEntryPtr
227  (
228  firstWord,
229  false, // recursive
230  patternMatch
231  );
232 
233  if (!entPtr)
234  {
235  // Fall back to finding key with '/' so e.g. if keyword is
236  // a/b/c/d it would try
237  // a/b, a/b/c, a/b/c/d
238 
239  string::size_type nextSlashPos = keyword.find
240  (
241  '/',
242  slashPos
243  );
244 
245  while (true)
246  {
247  const entry* subEntPtr = lookupEntryPtr
248  (
249  keyword.substr(0, nextSlashPos),
250  false, // recursive,
251  patternMatch
252  );
253 
254  if (nextSlashPos == string::npos)
255  {
256  // Parsed the whole word. Return entry or null.
257  return subEntPtr;
258  }
259 
260  nextSlashPos++;
261 
262  if (subEntPtr && subEntPtr->isDict())
263  {
264  return subEntPtr->dict().lookupScopedSubEntryPtr
265  (
266  keyword.substr
267  (
268  nextSlashPos,
269  keyword.size() - nextSlashPos
270  ),
271  false,
272  patternMatch
273  );
274  }
275 
276  nextSlashPos = keyword.find('/', nextSlashPos);
277  }
278  }
279 
280  if (entPtr->isDict())
281  {
282  return entPtr->dict().lookupScopedSubEntryPtr
283  (
284  keyword.substr(slashPos, keyword.size() - slashPos),
285  false,
286  patternMatch
287  );
288  }
289  else
290  {
291  return nullptr;
292  }
293  }
294  }
295 }
296 
297 
298 const Foam::entry* Foam::dictionary::lookupScopedSubEntryPtr
299 (
300  const word& keyword,
301  bool recursive,
302  bool patternMatch
303 ) const
304 {
306  {
307  return lookupDotScopedSubEntryPtr(keyword, recursive, patternMatch);
308  }
309  else
310  {
311  // Check for the dictionary boundary marker
312  const string::size_type emarkPos = keyword.find('!');
313 
314  if (emarkPos == string::npos || emarkPos == 0)
315  {
316  // Lookup in this dictionary
317 
318  return lookupSlashScopedSubEntryPtr
319  (
320  keyword,
321  recursive,
322  patternMatch
323  );
324  }
325  else
326  {
327  // Lookup in the dictionary specified by file name
328  // created from the part of the keyword before the '!'
329 
330  fileName fName = keyword.substr(0, emarkPos);
331 
332  if (!fName.isAbsolute())
333  {
334  fName = topDict().name().path()/fName;
335  }
336 
337  if (fName == topDict().name())
338  {
340  << "Attempt to re-read current dictionary " << fName
341  << " for keyword "
342  << keyword
343  << exit(FatalIOError);
344  }
345 
346  const word localKeyword = keyword.substr
347  (
348  emarkPos + 1,
349  keyword.size() - emarkPos - 1
350  );
351 
352  includedDictionary dict(fName, *this);
353 
354  const Foam::entry* entryPtr = dict.lookupScopedEntryPtr
355  (
356  localKeyword,
357  recursive,
358  patternMatch
359  );
360 
361  if (!entryPtr)
362  {
364  << "keyword " << localKeyword
365  << " is undefined in dictionary "
366  << dict.name()
367  << exit(FatalIOError);
368  }
369 
370  return entryPtr->clone(*this).ptr();
371  }
372  }
373 }
374 
375 
376 bool Foam::dictionary::findInPatterns
377 (
378  const bool patternMatch,
379  const word& Keyword,
381  DLList<autoPtr<regExp>>::const_iterator& reLink
382 ) const
383 {
384  if (patternEntries_.size())
385  {
386  while (wcLink != patternEntries_.end())
387  {
388  if
389  (
390  patternMatch
391  ? reLink()->match(Keyword)
392  : wcLink()->keyword() == Keyword
393  )
394  {
395  return true;
396  }
397 
398  ++reLink;
399  ++wcLink;
400  }
401  }
402 
403  return false;
404 }
405 
406 
407 bool Foam::dictionary::findInPatterns
408 (
409  const bool patternMatch,
410  const word& Keyword,
411  DLList<entry*>::iterator& wcLink,
412  DLList<autoPtr<regExp>>::iterator& reLink
413 )
414 {
415  if (patternEntries_.size())
416  {
417  while (wcLink != patternEntries_.end())
418  {
419  if
420  (
421  patternMatch
422  ? reLink()->match(Keyword)
423  : wcLink()->keyword() == Keyword
424  )
425  {
426  return true;
427  }
428 
429  ++reLink;
430  ++wcLink;
431  }
432  }
433 
434  return false;
435 }
436 
437 
438 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
439 
441 :
442  parent_(dictionary::null)
443 {}
444 
445 
447 :
448  dictionaryName(name),
449  parent_(dictionary::null)
450 {}
451 
452 
454 (
455  const dictionary& parentDict,
456  const dictionary& dict
457 )
458 :
459  dictionaryName(dict.name()),
460  IDLList<entry>(dict, *this),
461  parent_(parentDict)
462 {
463  forAllIter(IDLList<entry>, *this, iter)
464  {
465  hashedEntries_.insert(iter().keyword(), &iter());
466 
467  if (iter().keyword().isPattern())
468  {
469  patternEntries_.insert(&iter());
470  patternRegexps_.insert
471  (
472  autoPtr<regExp>(new regExp(iter().keyword()))
473  );
474  }
475  }
476 }
477 
478 
480 (
481  const dictionary& dict
482 )
483 :
484  dictionaryName(dict.name()),
485  IDLList<entry>(dict, *this),
486  parent_(dictionary::null)
487 {
488  forAllIter(IDLList<entry>, *this, iter)
489  {
490  hashedEntries_.insert(iter().keyword(), &iter());
491 
492  if (iter().keyword().isPattern())
493  {
494  patternEntries_.insert(&iter());
495  patternRegexps_.insert
496  (
497  autoPtr<regExp>(new regExp(iter().keyword()))
498  );
499  }
500  }
501 }
502 
503 
505 (
506  dictionary&& dict
507 )
508 :
509  dictionaryName(move(dict.name())),
510  IDLList<entry>(move(dict)),
511  hashedEntries_(move(dict.hashedEntries_)),
512  parent_(dict.parent_),
513  patternEntries_(move(dict.patternEntries_)),
514  patternRegexps_(move(dict.patternRegexps_))
515 {}
516 
517 
519 (
520  const dictionary* dictPtr
521 )
522 :
523  parent_(dictionary::null)
524 {
525  if (dictPtr)
526  {
527  operator=(*dictPtr);
528  }
529 }
530 
531 
533 (
534  const dictionary& parentDict,
535  dictionary&& dict
536 )
537 :
538  dictionaryName(move(dict.name())),
539  IDLList<entry>(move(dict)),
540  hashedEntries_(move(dict.hashedEntries_)),
541  parent_(parentDict),
542  patternEntries_(move(dict.patternEntries_)),
543  patternRegexps_(move(dict.patternRegexps_))
544 {
545  if (parentDict.name() != fileName::null)
546  {
547  name() = parentDict.name()/name();
548  }
549 }
550 
551 
553 {
554  return autoPtr<dictionary>(new dictionary(*this));
555 }
556 
557 
558 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
559 
561 {
562  // cerr<< "~dictionary() " << name() << " " << long(this) << std::endl;
563 }
564 
565 
566 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
567 
569 {
570  const dictionary& p = parent();
571 
572  if (&p != this && !p.name().empty())
573  {
574  return p.topDict();
575  }
576  else
577  {
578  return *this;
579  }
580 }
581 
582 
584 {
585  const dictionary& p = parent();
586 
587  if (&p != this && !p.name().empty())
588  {
589  const word pKeyword = p.topDictKeyword();
590  const char pSeparator = functionEntries::inputSyntaxEntry::scopeChar();
591  return
592  pKeyword == word::null
593  ? dictName()
594  : word(pKeyword + pSeparator + dictName());
595  }
596  else
597  {
598  return word::null;
599  }
600 }
601 
602 
604 {
605  if (size())
606  {
607  return first()->startLineNumber();
608  }
609  else
610  {
611  return -1;
612  }
613 }
614 
615 
617 {
618  if (size())
619  {
620  return last()->endLineNumber();
621  }
622  else
623  {
624  return -1;
625  }
626 }
627 
628 
630 {
631  OSHA1stream os;
632 
633  // Process entries
634  forAllConstIter(IDLList<entry>, *this, iter)
635  {
636  os << *iter;
637  }
638 
639  return os.digest();
640 }
641 
642 
644 {
645  // Serialise dictionary into a string
646  OStringStream os;
647  write(os, false);
648  IStringStream is(os.str());
649 
650  // Parse string as tokens
652  token t;
653  while (is.read(t))
654  {
655  tokens.append(t);
656  }
657 
658  return tokenList(move(tokens));
659 }
660 
661 
663 (
664  const word& keyword,
665  bool recursive,
666  bool patternMatch
667 ) const
668 {
669  if (hashedEntries_.found(keyword))
670  {
671  return true;
672  }
673  else
674  {
675  if (patternMatch && patternEntries_.size())
676  {
678  patternEntries_.begin();
680  patternRegexps_.begin();
681 
682  // Find in patterns using regular expressions only
683  if (findInPatterns(patternMatch, keyword, wcLink, reLink))
684  {
685  return true;
686  }
687  }
688 
689  if (recursive && &parent_ != &dictionary::null)
690  {
691  return parent_.found(keyword, recursive, patternMatch);
692  }
693  else
694  {
695  return false;
696  }
697  }
698 }
699 
700 
702 (
703  const word& keyword,
704  bool recursive,
705  bool patternMatch
706 ) const
707 {
708  HashTable<entry*>::const_iterator iter = hashedEntries_.find(keyword);
709 
710  if (iter == hashedEntries_.end())
711  {
712  if (patternMatch && patternEntries_.size())
713  {
715  patternEntries_.begin();
717  patternRegexps_.begin();
718 
719  // Find in patterns using regular expressions only
720  if (findInPatterns(patternMatch, keyword, wcLink, reLink))
721  {
722  return wcLink();
723  }
724  }
725 
726  if (recursive && &parent_ != &dictionary::null)
727  {
728  return parent_.lookupEntryPtr(keyword, recursive, patternMatch);
729  }
730  else
731  {
732  return nullptr;
733  }
734  }
735 
736  return iter();
737 }
738 
739 
741 (
742  const word& keyword,
743  bool recursive,
744  bool patternMatch
745 )
746 {
747  HashTable<entry*>::iterator iter = hashedEntries_.find(keyword);
748 
749  if (iter == hashedEntries_.end())
750  {
751  if (patternMatch && patternEntries_.size())
752  {
753  DLList<entry*>::iterator wcLink =
754  patternEntries_.begin();
756  patternRegexps_.begin();
757 
758  // Find in patterns using regular expressions only
759  if (findInPatterns(patternMatch, keyword, wcLink, reLink))
760  {
761  return wcLink();
762  }
763  }
764 
765  if (recursive && &parent_ != &dictionary::null)
766  {
767  return const_cast<dictionary&>(parent_).lookupEntryPtr
768  (
769  keyword,
770  recursive,
771  patternMatch
772  );
773  }
774  else
775  {
776  return nullptr;
777  }
778  }
779 
780  return iter();
781 }
782 
783 
785 (
786  const wordList& keywords,
787  bool recursive,
788  bool patternMatch
789 ) const
790 {
791  const entry* result = nullptr;
792 
793  forAll(keywords, keywordi)
794  {
795  const entry* entryPtr =
796  lookupEntryPtr(keywords[keywordi], recursive, patternMatch);
797 
798  if (entryPtr)
799  {
800  if (result)
801  {
802  IOWarningInFunction((*this))
803  << "Duplicate backwards compatible keywords \""
804  << result->keyword() << "\" and \"" << entryPtr->keyword()
805  << "\" are defined in dictionary " << name() << endl
806  << "The preferred keyword for this entry is \""
807  << keywords[0] << "\"" << endl;
808  }
809  else
810  {
811  result = entryPtr;
812  }
813  }
814  }
815 
816  return result;
817 }
818 
819 
821 (
822  const word& keyword,
823  bool recursive,
824  bool patternMatch
825 ) const
826 {
827  const entry* entryPtr = lookupEntryPtr(keyword, recursive, patternMatch);
828 
829  if (entryPtr == nullptr)
830  {
832  << "keyword " << keyword << " is undefined in dictionary "
833  << name()
834  << exit(FatalIOError);
835  }
836 
837  return *entryPtr;
838 }
839 
840 
842 (
843  const wordList& keywords,
844  bool recursive,
845  bool patternMatch
846 ) const
847 {
848  const entry* entryPtr =
849  lookupEntryPtrBackwardsCompatible(keywords, recursive, patternMatch);
850 
851  if (entryPtr == nullptr)
852  {
853  // Generate error message using the first keyword
854  return lookupEntry(keywords[0], recursive, patternMatch);
855  }
856  else
857  {
858  return *entryPtr;
859  }
860 }
861 
862 
864 (
865  const word& keyword,
866  bool recursive,
867  bool patternMatch
868 ) const
869 {
870  return lookupEntry(keyword, recursive, patternMatch).stream();
871 }
872 
873 
875 (
876  const wordList& keywords,
877  bool recursive,
878  bool patternMatch
879 ) const
880 {
882  (
883  keywords,
884  recursive,
885  patternMatch
886  ).stream();
887 }
888 
889 
891 (
892  const word& keyword,
893  bool recursive,
894  bool patternMatch
895 ) const
896 {
897  // '!' indicates the top-level directory in the "slash" syntax
898  // ':' indicates the top-level directory in the "dot" syntax
899  if
900  (
901  (functionEntries::inputSyntaxEntry::slash() && keyword[0] == '!')
902  || (functionEntries::inputSyntaxEntry::dot() && keyword[0] == ':')
903  )
904  {
905  // Go up to top level
906  const dictionary* dictPtr = this;
907  while (&dictPtr->parent_ != &dictionary::null)
908  {
909  dictPtr = &dictPtr->parent_;
910  }
911 
912  // At top. Recurse to find entries
913  return dictPtr->lookupScopedSubEntryPtr
914  (
915  keyword.substr(1, keyword.size() - 1),
916  false,
917  patternMatch
918  );
919  }
920  else
921  {
922  return lookupScopedSubEntryPtr
923  (
924  keyword,
925  recursive,
926  patternMatch
927  );
928  }
929 }
930 
931 
933 {
934  word varName = keyword(1, keyword.size() - 1);
935 
936  // Lookup the variable name in the given dictionary
937  const entry* ePtr = lookupScopedEntryPtr(varName, true, true);
938 
939  // If defined insert its entries into this dictionary
940  if (ePtr != nullptr)
941  {
942  const dictionary& addDict = ePtr->dict();
943 
944  forAllConstIter(IDLList<entry>, addDict, iter)
945  {
946  add(iter());
947  }
948 
949  return true;
950  }
951 
952  return false;
953 }
954 
955 
956 bool Foam::dictionary::isDict(const word& keyword) const
957 {
958  // Find non-recursive with patterns
959  const entry* entryPtr = lookupEntryPtr(keyword, false, true);
960 
961  if (entryPtr)
962  {
963  return entryPtr->isDict();
964  }
965  else
966  {
967  return false;
968  }
969 }
970 
971 
973 {
974  const entry* entryPtr = lookupEntryPtr(keyword, false, true);
975 
976  if (entryPtr)
977  {
978  return &entryPtr->dict();
979  }
980  else
981  {
982  return nullptr;
983  }
984 }
985 
986 
988 {
989  entry* entryPtr = lookupEntryPtr(keyword, false, true);
990 
991  if (entryPtr)
992  {
993  return &entryPtr->dict();
994  }
995  else
996  {
997  return nullptr;
998  }
999 }
1000 
1001 
1003 {
1004  const entry* entryPtr = lookupEntryPtr(keyword, false, true);
1005 
1006  if (entryPtr == nullptr)
1007  {
1008  FatalIOErrorInFunction(*this)
1009  << "keyword " << keyword << " is undefined in dictionary "
1010  << name()
1011  << exit(FatalIOError);
1012  }
1013  return entryPtr->dict();
1014 }
1015 
1016 
1018 {
1019  entry* entryPtr = lookupEntryPtr(keyword, false, true);
1020 
1021  if (entryPtr == nullptr)
1022  {
1023  FatalIOErrorInFunction(*this)
1024  << "keyword " << keyword << " is undefined in dictionary "
1025  << name()
1026  << exit(FatalIOError);
1027  }
1028  return entryPtr->dict();
1029 }
1030 
1031 
1034  const word& keyword,
1035  const bool mustRead
1036 ) const
1037 {
1038  const entry* entryPtr = lookupEntryPtr(keyword, false, true);
1039 
1040  if (entryPtr == nullptr)
1041  {
1042  if (mustRead)
1043  {
1044  FatalIOErrorInFunction(*this)
1045  << "keyword " << keyword << " is undefined in dictionary "
1046  << name()
1047  << exit(FatalIOError);
1048  }
1049 
1050  return dictionary(*this, dictionary(name() + '/' + keyword));
1051  }
1052  else
1053  {
1054  return entryPtr->dict();
1055  }
1056 }
1057 
1058 
1061  const word& keyword
1062 ) const
1063 {
1064  const entry* entryPtr = lookupEntryPtr(keyword, false, true);
1065 
1066  if (entryPtr)
1067  {
1068  return entryPtr->dict();
1069  }
1070  else
1071  {
1072  return *this;
1073  }
1074 }
1075 
1076 
1078 {
1079  if (keyword == "")
1080  {
1081  return *this;
1082  }
1083  else
1084  {
1085  const entry* entPtr = lookupScopedEntryPtr
1086  (
1087  keyword,
1088  false,
1089  false
1090  );
1091  if (!entPtr || !entPtr->isDict())
1092  {
1093  FatalIOErrorInFunction(*this)
1094  << "keyword " << keyword
1095  << " is undefined in dictionary "
1096  << name() << " or is not a dictionary"
1097  << endl
1098  << "Valid keywords are " << keys()
1099  << exit(FatalIOError);
1100  }
1101  return entPtr->dict();
1102  }
1103 }
1104 
1105 
1107 {
1108  return const_cast<dictionary&>
1109  (
1110  const_cast<const dictionary*>(this)->scopedDict(keyword)
1111  );
1112 }
1113 
1114 
1116 {
1117  wordList keys(size());
1118 
1119  label nKeys = 0;
1120  forAllConstIter(IDLList<entry>, *this, iter)
1121  {
1122  keys[nKeys++] = iter().keyword();
1123  }
1124 
1125  return keys;
1126 }
1127 
1128 
1130 {
1131  return hashedEntries_.sortedToc();
1132 }
1133 
1134 
1136 {
1137  List<keyType> keys(size());
1138 
1139  label nKeys = 0;
1140  forAllConstIter(IDLList<entry>, *this, iter)
1141  {
1142  if (iter().keyword().isPattern() ? patterns : !patterns)
1143  {
1144  keys[nKeys++] = iter().keyword();
1145  }
1146  }
1147  keys.setSize(nKeys);
1148 
1149  return keys;
1150 }
1151 
1152 
1153 bool Foam::dictionary::add(entry* entryPtr, bool mergeEntry)
1154 {
1155  HashTable<entry*>::iterator iter = hashedEntries_.find
1156  (
1157  entryPtr->keyword()
1158  );
1159 
1160  if (mergeEntry && iter != hashedEntries_.end())
1161  {
1162  // Merge dictionary with dictionary
1163  if (iter()->isDict() && entryPtr->isDict())
1164  {
1165  iter()->dict().merge(entryPtr->dict());
1166  delete entryPtr;
1167 
1168  return true;
1169  }
1170  else
1171  {
1172  // Replace existing dictionary with entry or vice versa
1173  IDLList<entry>::replace(iter(), entryPtr);
1174  delete iter();
1175  hashedEntries_.erase(iter);
1176 
1177  if (hashedEntries_.insert(entryPtr->keyword(), entryPtr))
1178  {
1179  entryPtr->name() = name() + '/' + entryPtr->keyword();
1180 
1181  if (entryPtr->keyword().isPattern())
1182  {
1183  patternEntries_.insert(entryPtr);
1184  patternRegexps_.insert
1185  (
1186  autoPtr<regExp>(new regExp(entryPtr->keyword()))
1187  );
1188  }
1189 
1190  return true;
1191  }
1192  else
1193  {
1194  IOWarningInFunction((*this))
1195  << "problem replacing entry "<< entryPtr->keyword()
1196  << " in dictionary " << name() << endl;
1197 
1198  IDLList<entry>::remove(entryPtr);
1199  delete entryPtr;
1200  return false;
1201  }
1202  }
1203  }
1204 
1205  if (hashedEntries_.insert(entryPtr->keyword(), entryPtr))
1206  {
1207  entryPtr->name() = name() + '/' + entryPtr->keyword();
1208  IDLList<entry>::append(entryPtr);
1209 
1210  if (entryPtr->keyword().isPattern())
1211  {
1212  patternEntries_.insert(entryPtr);
1213  patternRegexps_.insert
1214  (
1215  autoPtr<regExp>(new regExp(entryPtr->keyword()))
1216  );
1217  }
1218 
1219  return true;
1220  }
1221  else
1222  {
1223  // If function entries are disabled allow duplicate entries
1225  {
1226  entryPtr->name() = name() + '/' + entryPtr->keyword();
1227  IDLList<entry>::append(entryPtr);
1228 
1229  return true;
1230  }
1231  else
1232  {
1233  IOWarningInFunction((*this))
1234  << "attempt to add entry "<< entryPtr->keyword()
1235  << " which already exists in dictionary " << name()
1236  << endl;
1237 
1238  delete entryPtr;
1239  return false;
1240  }
1241  }
1242 }
1243 
1244 
1245 void Foam::dictionary::add(const entry& e, bool mergeEntry)
1246 {
1247  add(e.clone(*this).ptr(), mergeEntry);
1248 }
1249 
1250 
1251 void Foam::dictionary::add(const keyType& k, const word& w, bool overwrite)
1252 {
1253  add(new primitiveEntry(k, token(w)), overwrite);
1254 }
1255 
1256 
1259  const keyType& k,
1260  const Foam::string& s,
1261  bool overwrite
1262 )
1263 {
1264  add(new primitiveEntry(k, token(s)), overwrite);
1265 }
1266 
1267 
1268 void Foam::dictionary::add(const keyType& k, const label l, bool overwrite)
1269 {
1270  add(new primitiveEntry(k, token(l)), overwrite);
1271 }
1272 
1273 
1274 void Foam::dictionary::add(const keyType& k, const scalar s, bool overwrite)
1275 {
1276  add(new primitiveEntry(k, token(s)), overwrite);
1277 }
1278 
1279 
1282  const keyType& k,
1283  const dictionary& d,
1284  bool mergeEntry
1285 )
1286 {
1287  add(new dictionaryEntry(k, *this, d), mergeEntry);
1288 }
1289 
1290 
1292 {
1293  entry* existingPtr = lookupEntryPtr(entryPtr->keyword(), false, true);
1294 
1295  // Clear dictionary so merge acts like overwrite
1296  if (existingPtr && existingPtr->isDict())
1297  {
1298  existingPtr->dict().clear();
1299  }
1300  add(entryPtr, true);
1301 }
1302 
1303 
1305 {
1306  set(e.clone(*this).ptr());
1307 }
1308 
1309 
1310 void Foam::dictionary::set(const keyType& k, const dictionary& d)
1311 {
1312  set(new dictionaryEntry(k, *this, d));
1313 }
1314 
1315 
1316 bool Foam::dictionary::remove(const word& Keyword)
1317 {
1318  HashTable<entry*>::iterator iter = hashedEntries_.find(Keyword);
1319 
1320  if (iter != hashedEntries_.end())
1321  {
1322  // Delete from patterns first
1323  DLList<entry*>::iterator wcLink =
1324  patternEntries_.begin();
1326  patternRegexps_.begin();
1327 
1328  // Find in pattern using exact match only
1329  if (findInPatterns(false, Keyword, wcLink, reLink))
1330  {
1331  patternEntries_.remove(wcLink);
1332  patternRegexps_.remove(reLink);
1333  }
1334 
1335  IDLList<entry>::remove(iter());
1336  delete iter();
1337  hashedEntries_.erase(iter);
1338 
1339  return true;
1340  }
1341  else
1342  {
1343  return false;
1344  }
1345 }
1346 
1347 
1350  const keyType& oldKeyword,
1351  const keyType& newKeyword,
1352  bool forceOverwrite
1353 )
1354 {
1355  // No change
1356  if (oldKeyword == newKeyword)
1357  {
1358  return false;
1359  }
1360 
1361  HashTable<entry*>::iterator iter = hashedEntries_.find(oldKeyword);
1362 
1363  // oldKeyword not found - do nothing
1364  if (iter == hashedEntries_.end())
1365  {
1366  return false;
1367  }
1368 
1369  if (iter()->keyword().isPattern())
1370  {
1371  FatalIOErrorInFunction(*this)
1372  << "Old keyword "<< oldKeyword
1373  << " is a pattern."
1374  << "Pattern replacement not yet implemented."
1375  << exit(FatalIOError);
1376  }
1377 
1378 
1379  HashTable<entry*>::iterator iter2 = hashedEntries_.find(newKeyword);
1380 
1381  // newKeyword already exists
1382  if (iter2 != hashedEntries_.end())
1383  {
1384  if (forceOverwrite)
1385  {
1386  if (iter2()->keyword().isPattern())
1387  {
1388  // Delete from patterns first
1389  DLList<entry*>::iterator wcLink =
1390  patternEntries_.begin();
1392  patternRegexps_.begin();
1393 
1394  // Find in patterns using exact match only
1395  if (findInPatterns(false, iter2()->keyword(), wcLink, reLink))
1396  {
1397  patternEntries_.remove(wcLink);
1398  patternRegexps_.remove(reLink);
1399  }
1400  }
1401 
1402  IDLList<entry>::replace(iter2(), iter());
1403  delete iter2();
1404  hashedEntries_.erase(iter2);
1405 
1406  }
1407  else
1408  {
1410  (
1411  *this
1412  ) << "cannot rename keyword "<< oldKeyword
1413  << " to existing keyword " << newKeyword
1414  << " in dictionary " << name() << endl;
1415  return false;
1416  }
1417  }
1418 
1419  // Change name and HashTable, but leave DL-List untouched
1420  iter()->keyword() = newKeyword;
1421  iter()->name() = name() + '/' + newKeyword;
1422  hashedEntries_.erase(oldKeyword);
1423  hashedEntries_.insert(newKeyword, iter());
1424 
1425  if (newKeyword.isPattern())
1426  {
1427  patternEntries_.insert(iter());
1428  patternRegexps_.insert
1429  (
1430  autoPtr<regExp>(new regExp(newKeyword))
1431  );
1432  }
1433 
1434  return true;
1435 }
1436 
1437 
1439 {
1440  // Check for assignment to self
1441  if (this == &dict)
1442  {
1443  FatalIOErrorInFunction(*this)
1444  << "attempted merge to self for dictionary " << name()
1445  << abort(FatalIOError);
1446  }
1447 
1448  bool changed = false;
1449 
1450  forAllConstIter(IDLList<entry>, dict, iter)
1451  {
1452  HashTable<entry*>::iterator fnd = hashedEntries_.find(iter().keyword());
1453 
1454  if (fnd != hashedEntries_.end())
1455  {
1456  // Recursively merge sub-dictionaries
1457  // TODO: merge without copying
1458  if (fnd()->isDict() && iter().isDict())
1459  {
1460  if (fnd()->dict().merge(iter().dict()))
1461  {
1462  changed = true;
1463  }
1464  }
1465  else
1466  {
1467  add(iter().clone(*this).ptr(), true);
1468  changed = true;
1469  }
1470  }
1471  else
1472  {
1473  // Not found - just add
1474  add(iter().clone(*this).ptr());
1475  changed = true;
1476  }
1477  }
1478 
1479  return changed;
1480 }
1481 
1482 
1484 {
1486  hashedEntries_.clear();
1487  patternEntries_.clear();
1488  patternRegexps_.clear();
1489 }
1490 
1491 
1493 {
1494  // Changing parents probably doesn't make much sense,
1495  // but what about the names?
1496  name() = dict.name();
1497 
1499  hashedEntries_.transfer(dict.hashedEntries_);
1500  patternEntries_.transfer(dict.patternEntries_);
1501  patternRegexps_.transfer(dict.patternRegexps_);
1502 }
1503 
1504 
1505 // * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
1506 
1508 {
1509  return lookup(keyword);
1510 }
1511 
1512 
1514 {
1515  // Check for assignment to self
1516  if (this == &rhs)
1517  {
1518  FatalIOErrorInFunction(*this)
1519  << "attempted assignment to self for dictionary " << name()
1520  << abort(FatalIOError);
1521  }
1522 
1523  name() = rhs.name();
1524  clear();
1525 
1526  // Create clones of the entries in the given dictionary
1527  // resetting the parentDict to this dictionary
1528 
1529  forAllConstIter(IDLList<entry>, rhs, iter)
1530  {
1531  add(iter().clone(*this).ptr());
1532  }
1533 }
1534 
1535 
1537 {
1538  // Check for assignment to self
1539  if (this == &rhs)
1540  {
1541  FatalIOErrorInFunction(*this)
1542  << "attempted assignment to self for dictionary " << name()
1543  << abort(FatalIOError);
1544  }
1545 
1546  dictionaryName::operator=(move(rhs));
1547  IDLList<entry>::operator=(move(rhs));
1548  hashedEntries_ = move(rhs.hashedEntries_);
1549  patternEntries_ = move(rhs.patternEntries_);
1550  patternRegexps_ = move(rhs.patternRegexps_);
1551 }
1552 
1553 
1555 {
1556  // Check for assignment to self
1557  if (this == &rhs)
1558  {
1559  FatalIOErrorInFunction(*this)
1560  << "attempted addition assignment to self for dictionary " << name()
1561  << abort(FatalIOError);
1562  }
1563 
1564  forAllConstIter(IDLList<entry>, rhs, iter)
1565  {
1566  add(iter().clone(*this).ptr());
1567  }
1568 }
1569 
1570 
1572 {
1573  // Check for assignment to self
1574  if (this == &rhs)
1575  {
1576  FatalIOErrorInFunction(*this)
1577  << "attempted assignment to self for dictionary " << name()
1578  << abort(FatalIOError);
1579  }
1580 
1581  forAllConstIter(IDLList<entry>, rhs, iter)
1582  {
1583  if (!found(iter().keyword()))
1584  {
1585  add(iter().clone(*this).ptr());
1586  }
1587  }
1588 }
1589 
1590 
1592 {
1593  // Check for assignment to self
1594  if (this == &rhs)
1595  {
1596  FatalIOErrorInFunction(*this)
1597  << "attempted assignment to self for dictionary " << name()
1598  << abort(FatalIOError);
1599  }
1600 
1601  forAllConstIter(IDLList<entry>, rhs, iter)
1602  {
1603  set(iter().clone(*this).ptr());
1604  }
1605 }
1606 
1607 
1608 /* * * * * * * * * * * * * * * * Global operators * * * * * * * * * * * * * */
1609 
1610 Foam::dictionary Foam::operator+
1612  const dictionary& dict1,
1613  const dictionary& dict2
1614 )
1615 {
1616  dictionary sum(dict1);
1617  sum += dict2;
1618  return sum;
1619 }
1620 
1621 
1622 Foam::dictionary Foam::operator|
1624  const dictionary& dict1,
1625  const dictionary& dict2
1626 )
1627 {
1628  dictionary sum(dict1);
1629  sum |= dict2;
1630  return sum;
1631 }
1632 
1633 
1634 // * * * * * * * * * * * * * * * Global Functions * * * * * * * * * * * * * //
1635 
1636 void Foam::dictArgList
1638  const string& funcArgs,
1639  word& funcName,
1640  wordReList& args,
1641  List<Tuple2<word, string>>& namedArgs
1642 )
1643 {
1644  funcName = funcArgs;
1645 
1646  int argLevel = 0;
1647  bool namedArg = false;
1648  word argName;
1649 
1650  word::size_type start = 0;
1651  word::size_type i = 0;
1652 
1653  for
1654  (
1655  word::const_iterator iter = funcArgs.begin();
1656  iter != funcArgs.end();
1657  ++iter
1658  )
1659  {
1660  char c = *iter;
1661 
1662  if (c == '(')
1663  {
1664  if (argLevel == 0)
1665  {
1666  funcName = funcArgs(start, i - start);
1667  start = i+1;
1668  }
1669  ++argLevel;
1670  }
1671  else if (c == ',' || c == ')')
1672  {
1673  if (argLevel == 1)
1674  {
1675  if (namedArg)
1676  {
1677  namedArgs.append
1678  (
1680  (
1681  argName,
1682  funcArgs(start, i - start)
1683  )
1684  );
1685  namedArg = false;
1686  }
1687  else
1688  {
1689  args.append(wordRe(funcArgs(start, i - start)));
1690  }
1691  start = i+1;
1692  }
1693 
1694  if (c == ')')
1695  {
1696  if (argLevel == 1)
1697  {
1698  break;
1699  }
1700  --argLevel;
1701  }
1702  }
1703  else if (c == '=')
1704  {
1705  argName = funcArgs(start, i - start);
1706  string::stripInvalid<variable>(argName);
1707  start = i+1;
1708  namedArg = true;
1709  }
1710 
1711  ++i;
1712  }
1713 
1714  // Strip whitespace from the function name
1715  string::stripInvalid<word>(funcName);
1716 }
1717 
1718 
1719 void Foam::dictArgList
1721  const string& funcArgs,
1722  wordReList& args,
1723  List<Tuple2<word, string>>& namedArgs
1724 )
1725 {
1726  int argLevel = 0;
1727  bool namedArg = false;
1728  word argName;
1729 
1730  word::size_type start = 0;
1731  word::size_type i = 0;
1732 
1733  for
1734  (
1735  word::const_iterator iter = funcArgs.begin();
1736  iter != funcArgs.end();
1737  ++iter
1738  )
1739  {
1740  char c = *iter;
1741 
1742  if (c == '(')
1743  {
1744  ++argLevel;
1745  }
1746  else if (c == ',' || std::next(iter) == funcArgs.end())
1747  {
1748  if (std::next(iter) == funcArgs.end())
1749  {
1750  if (c == ')')
1751  {
1752  --argLevel;
1753  }
1754 
1755  ++i;
1756  }
1757 
1758  if (argLevel == 0)
1759  {
1760  if (namedArg)
1761  {
1762  namedArgs.append
1763  (
1765  (
1766  argName,
1767  funcArgs(start, i - start)
1768  )
1769  );
1770  namedArg = false;
1771  }
1772  else
1773  {
1774  args.append(wordRe(funcArgs(start, i - start)));
1775  }
1776  start = i+1;
1777  }
1778  }
1779  else if (c == '=')
1780  {
1781  argName = funcArgs(start, i - start);
1782  string::stripInvalid<variable>(argName);
1783  start = i+1;
1784  namedArg = true;
1785  }
1786  else if (c == ')')
1787  {
1788  --argLevel;
1789  }
1790 
1791  ++i;
1792  }
1793 }
1794 
1795 
1797 {
1798  string::size_type i = scopedName.find_last_of
1799  (
1801  );
1802 
1803  if (i != string::npos)
1804  {
1805  return Pair<word>
1806  (
1807  scopedName.substr(0, i),
1808  scopedName.substr(i+1, string::npos)
1809  );
1810  }
1811  else
1812  {
1813  return Pair<word>("", scopedName);
1814  }
1815 }
1816 
1817 
1818 // ************************************************************************* //
static bool slash()
Return true if the inputSyntax is slash.
Template class for intrusive linked lists.
Definition: ILList.H:50
void write(Ostream &, const bool subDict=true) const
Write dictionary, normally with sub-dictionary formatting.
Definition: dictionaryIO.C:207
A class for handling keywords in dictionaries.
Definition: keyType.H:66
virtual autoPtr< entry > clone(const dictionary &parentDict) const =0
Construct on freestore as copy with reference to the.
dictionary dict
bool found(const word &, bool recursive=false, bool patternMatch=true) const
Search dictionary for given keyword.
Definition: dictionary.C:663
#define forAll(list, i)
Loop across all elements in list.
Definition: UList.H:434
bool remove(const word &)
Remove an entry specified by keyword.
Definition: dictionary.C:1316
const entry & lookupEntryBackwardsCompatible(const wordList &, bool recursive, bool patternMatch) const
Find and return an entry data stream if present, trying a list.
Definition: dictionary.C:842
A class for handling file names.
Definition: fileName.H:79
label endLineNumber() const
Return line number of last token in dictionary.
Definition: dictionary.C:616
void operator=(const dictionary &)
Definition: dictionary.C:1513
tokenList tokens() const
Return the dictionary as a list of tokens.
Definition: dictionary.C:643
const entry * lookupEntryPtr(const word &, bool recursive, bool patternMatch) const
Find and return an entry data stream pointer if present.
Definition: dictionary.C:702
const keyType & keyword() const
Return keyword.
Definition: entry.H:123
An STL-conforming const_iterator.
Definition: HashTable.H:481
const dictionary & scopedDict(const word &) const
Find and return a sub-dictionary by scoped lookup.
Definition: dictionary.C:1077
Wrapper around POSIX extended regular expressions.
Definition: regExp.H:61
SHA1Digest digest() const
Return the SHA1 digest of the dictionary contents.
Definition: dictionary.C:629
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition: errorManip.H:124
void operator+=(const dictionary &)
Include entries from the given dictionary.
Definition: dictionary.C:1554
List< token > tokenList
List of tokens, used for a IOdictionary entry.
Definition: tokenList.H:42
A list of keyword definitions, which are a keyword followed by any number of values (e...
Definition: dictionary.H:156
#define forAllConstIter(Container, container, iter)
Iterate across all elements in the container object of type.
Definition: UList.H:477
A 2-tuple for storing two objects of different types.
Definition: HashTable.H:65
const entry * lookupEntryPtrBackwardsCompatible(const wordList &, bool recursive, bool patternMatch) const
Find and return an entry data stream if present, trying a list.
Definition: dictionary.C:785
void transfer(ILList< LListBase, T > &)
Transfer the contents of the argument into this List.
Definition: ILList.C:134
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
Definition: HashTable.H:59
Template class for non-intrusive linked lists.
Definition: LList.H:51
#define forAllIter(Container, container, iter)
Iterate across all elements in the container object of type.
Definition: UList.H:459
dictionaryName()
Construct dictionaryName null.
Definition: dictionary.H:90
An STL-conforming const_iterator.
Definition: LList.H:297
A token holds items read from Istream.
Definition: token.H:72
static const fileName null
An empty fileName.
Definition: fileName.H:97
static bool dot()
Return true if the inputSyntax is dot.
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:251
The SHA1 message digest.
Definition: SHA1Digest.H:62
An STL-conforming iterator.
Definition: LList.H:246
virtual const dictionary & dict() const =0
Return dictionary if this entry is a dictionary.
friend class iterator
Definition: LList.H:82
static bool writeOptionalEntries
If true write optional keywords and values.
Definition: dictionary.H:246
const entry & lookupEntry(const word &, bool recursive, bool patternMatch) const
Find and return an entry data stream if present otherwise error.
Definition: dictionary.C:821
A Foam::OSstream for calculating SHA-1 digests.
Definition: OSHA1stream.H:149
T * last()
Return the last entry.
Definition: UILList.H:121
A keyword and a list of tokens is a &#39;dictionaryEntry&#39;.
void transfer(dictionary &)
Transfer the contents of the argument and annul the argument.
Definition: dictionary.C:1492
const dimensionedScalar c
Speed of light in a vacuum.
autoPtr< dictionary > clone() const
Construct and return clone.
Definition: dictionary.C:552
An STL-conforming const_iterator.
Definition: UILList.H:234
const entry * lookupScopedEntryPtr(const word &, bool recursive, bool patternMatch) const
Find and return an entry data stream pointer if present.
Definition: dictionary.C:891
wordList toc() const
Return the table of contents.
Definition: dictionary.C:1115
int infoSwitch(const char *name, const int defaultValue=0)
Lookup info switch or add default value.
Definition: debug.C:233
bool isDict(const word &) const
Check if entry is a sub-dictionary.
Definition: dictionary.C:956
bool add(entry *, bool mergeEntry=false)
Add a new entry.
Definition: dictionary.C:1153
dimensioned< Type > sum(const DimensionedField< Type, GeoMesh > &df)
const word dictName() const
Return the local dictionary name (final part of scoped name)
Definition: dictionary.H:121
const dictionary & subDict(const word &) const
Find and return a sub-dictionary.
Definition: dictionary.C:1002
A keyword and a list of tokens is a &#39;primitiveEntry&#39;. An primitiveEntry can be read, written and printed, and the types and values of its tokens analysed.
dictionary()
Construct top-level dictionary null.
Definition: dictionary.C:440
An STL-conforming iterator.
Definition: HashTable.H:426
bool changeKeyword(const keyType &oldKeyword, const keyType &newKeyword, bool forceOverwrite=false)
Change the keyword for an entry,.
Definition: dictionary.C:1349
Pair< word > dictAndKeyword(const word &scopedName)
Extracts dict name and keyword.
Definition: dictionary.C:1796
void operator<<=(const dictionary &)
Unconditionally include entries from the given dictionary.
Definition: dictionary.C:1591
static int disableFunctionEntries
Definition: entry.H:86
An ordered pair of two objects of type <T> with first() and second() elements.
Definition: contiguous.H:49
const fileName & name() const
Return the dictionary name.
Definition: dictionary.H:109
A 1D vector of objects of type <T> that resizes itself as necessary to accept the new objects...
Definition: DynamicList.H:56
const dictionary & optionalSubDict(const word &) const
Find and return a sub-dictionary if found.
Definition: dictionary.C:1060
A class for handling words, derived from string.
Definition: word.H:59
const dictionary & parent() const
Return the parent dictionary.
Definition: dictionary.H:301
void clear()
Clear the contents of the list.
Definition: ILList.C:121
void append(const T &)
Append an element at the end of the list.
Definition: ListI.H:178
word topDictKeyword() const
Return the scoped keyword with which this dictionary can be.
Definition: dictionary.C:583
static const dictionary null
Null dictionary.
Definition: dictionary.H:242
An STL-conforming iterator.
Definition: UILList.H:185
const dictionary & topDict() const
Return the top of the tree.
Definition: dictionary.C:568
static const word null
An empty word.
Definition: word.H:77
T * remove(T *p)
Remove and return element.
Definition: UILList.H:142
graph_traits< Graph >::vertices_size_type size_type
Definition: SloanRenumber.C:73
errorManip< error > abort(error &err)
Definition: errorManip.H:131
A wordRe is a word, but can also have a regular expression for matching words.
Definition: wordRe.H:74
static char scopeChar()
Return true if the inputSyntax is slash.
const dictionary * subDictPtr(const word &) const
Find and return a sub-dictionary pointer if present.
Definition: dictionary.C:972
virtual bool isDict() const
Return true if this entry is a dictionary.
Definition: entry.H:156
defineTypeNameAndDebug(combustionModel, 0)
word name(const complex &)
Return a string representation of a complex.
Definition: complex.C:47
LList< DLListBase, T > DLList
Definition: DLList.H:43
List< keyType > keys(bool patterns=false) const
Return the list of available keys or patterns.
Definition: dictionary.C:1135
friend class const_iterator
Definition: LList.H:85
void setSize(const label)
Reset size of List.
Definition: List.C:281
void operator|=(const dictionary &)
Conditionally include entries from the given dictionary.
Definition: dictionary.C:1571
ITstream & operator[](const word &) const
Find and return entry.
Definition: dictionary.C:1507
void operator=(const dictionaryName &name)
Definition: dictionary.H:140
#define FatalIOErrorInFunction(ios)
Report an error message using Foam::FatalIOError.
Definition: error.H:318
Input from memory buffer stream.
Definition: IStringStream.H:49
string str() const
Return the string.
SHA1Digest digest()
Return the SHA-1 digest for the data processed until now.
Definition: OSHA1stream.H:194
virtual const fileName & name() const =0
Return the dictionary name.
virtual ~dictionary()
Destructor.
Definition: dictionary.C:560
void set(entry *)
Assign a new entry, overwrite any existing entry.
Definition: dictionary.C:1291
bool substituteScopedKeyword(const word &keyword)
Substitute the given scoped keyword prepended by &#39;$&#39; with the.
Definition: dictionary.C:932
bool merge(const dictionary &)
Merge entries from the given dictionary.
Definition: dictionary.C:1438
#define IOWarningInFunction(ios)
Report an IO warning using Foam::Warning.
An auto-pointer similar to the STL auto_ptr but with automatic casting to a reference to the type and...
Definition: PtrList.H:52
const doubleScalar e
Elementary charge.
Definition: doubleScalar.H:105
volScalarField & p
T * first()
Return the first entry.
Definition: UILList.H:109
void clear()
Clear the dictionary.
Definition: dictionary.C:1483
virtual ITstream & stream() const =0
Return token stream if this entry is a primitive entry.
void operator=(const ILList< LListBase, T > &)
Assignment operator.
Definition: ILList.C:144
A class for handling character strings derived from std::string.
Definition: string.H:76
Output to memory buffer stream.
Definition: OStringStream.H:49
label startLineNumber() const
Return line number of first token in dictionary.
Definition: dictionary.C:603
void dictArgList(const string &funcArgs, word &funcName, wordReList &args, List< Tuple2< word, string >> &namedArgs)
Parse dictionary substitution argument list.
Definition: dictionary.C:1637
wordList sortedToc() const
Return the sorted table of contents.
Definition: dictionary.C:1129
Input token stream.
Definition: ITstream.H:49
dictionary subOrEmptyDict(const word &, const bool mustRead=false) const
Find and return a sub-dictionary as a copy, or.
Definition: dictionary.C:1033
ITstream & lookupBackwardsCompatible(const wordList &, bool recursive=false, bool patternMatch=true) const
Find and return an entry data stream, trying a list of keywords.
Definition: dictionary.C:875
Namespace for OpenFOAM.
A keyword and a list of tokens is an &#39;entry&#39;.
Definition: entry.H:65
bool isPattern() const
Should be treated as a match rather than a literal string.
Definition: keyTypeI.H:97
ITstream & lookup(const word &, bool recursive=false, bool patternMatch=true) const
Find and return an entry data stream.
Definition: dictionary.C:864
IOerror FatalIOError