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