dictionary.H
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 Class
25  Foam::dictionary
26 
27 Description
28  A list of keyword definitions, which are a keyword followed by any number
29  of values (e.g. words and numbers). The keywords can represent patterns
30  which are matched using Posix regular expressions. The general order for
31  searching is as follows:
32  - exact match
33  - pattern match (in reverse order)
34  - optional recursion into the enclosing (parent) dictionaries
35 
36  The dictionary class is the base class for IOdictionary.
37  It also serves as a bootstrap dictionary for the objectRegistry data
38  dictionaries since, unlike the IOdictionary class, it does not use an
39  objectRegistry itself to work.
40 
41  To add - a merge() member function with a non-const dictionary parameter?
42  This would avoid unnecessary cloning in the add(entry*, bool) method.
43 
44 SourceFiles
45  dictionary.C
46  dictionaryIO.C
47 
48 \*---------------------------------------------------------------------------*/
49 
50 #ifndef dictionary_H
51 #define dictionary_H
52 
53 #include "entry.H"
54 #include "IDLList.H"
55 #include "DLList.H"
56 #include "HashSet.H"
57 #include "ITstream.H"
58 #include "wordReList.H"
59 #include "Pair.H"
60 #include "className.H"
61 
62 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
63 
64 namespace Foam
65 {
66 
67 // Forward declaration of friend functions and operators
68 class regExp;
69 class dictionary;
70 class SHA1Digest;
71 
72 Istream& operator>>(Istream&, dictionary&);
73 Ostream& operator<<(Ostream&, const dictionary&);
74 
75 /*---------------------------------------------------------------------------*\
76  Class dictionaryName Declaration
77 \*---------------------------------------------------------------------------*/
78 
79 class dictionaryName
80 {
81  // Private Data
82 
83  fileName name_;
84 
85 
86 public:
87 
88  // Constructors
89 
90  //- Construct dictionaryName null
92  {}
93 
94  //- Construct dictionaryName as copy of the given fileName
96  :
97  name_(name)
98  {}
99 
100  //- Move constructor
102  :
103  name_(move(name.name_))
104  {}
105 
106 
107  // Member Functions
108 
109  //- Return the dictionary name
110  const fileName& name() const
111  {
112  return name_;
113  }
114 
115  //- Return the dictionary name
116  fileName& name()
117  {
118  return name_;
119  }
120 
121  //- Return the local dictionary name (final part of scoped name)
122  const word dictName() const
123  {
124  const word scopedName = name_.name();
125 
126  string::size_type i = scopedName.rfind('/');
127 
128  if (i == scopedName.npos)
129  {
130  return scopedName;
131  }
132  else
133  {
134  return scopedName.substr(i + 1, scopedName.npos);
135  }
136  }
137 
138 
139  // Member Operators
140 
141  void operator=(const dictionaryName& name)
142  {
143  name_ = name.name_;
144  }
145 
147  {
148  name_ = move(name.name_);
149  }
150 };
151 
152 
153 /*---------------------------------------------------------------------------*\
154  Class dictionary Declaration
155 \*---------------------------------------------------------------------------*/
156 
157 class dictionary
158 :
159  public dictionaryName,
160  public IDLList<entry>
161 {
162  // Private Data
163 
164  //- HashTable of the entries held on the DL-list for quick lookup
165  HashTable<entry*> hashedEntries_;
166 
167  //- Parent dictionary
168  const dictionary& parent_;
169 
170  //- Entries of matching patterns
171  DLList<entry*> patternEntries_;
172 
173  //- Patterns as precompiled regular expressions
174  DLList<autoPtr<regExp>> patternRegexps_;
175 
176 
177  // Private Member Functions
178 
179  //- Find and return an entry data stream pointer if present
180  // otherwise return nullptr. Supports scoping using '.'
181  const entry* lookupDotScopedSubEntryPtr
182  (
183  const word&,
184  bool recursive,
185  bool patternMatch
186  ) const;
187 
188  //- Find and return an entry data stream pointer if present
189  // otherwise return nullptr. Supports scoping using '/'
190  const entry* lookupSlashScopedSubEntryPtr
191  (
192  const word&,
193  bool recursive,
194  bool patternMatch
195  ) const;
196 
197  //- Find and return an entry data stream pointer if present
198  // otherwise return nullptr. Supports scoping using '/' or '.'
199  const entry* lookupScopedSubEntryPtr
200  (
201  const word&,
202  bool recursive,
203  bool patternMatch
204  ) const;
205 
206  //- Search patterns table for exact match or regular expression match
207  bool findInPatterns
208  (
209  const bool patternMatch,
210  const word& Keyword,
213  ) const;
214 
215  //- Search patterns table for exact match or regular expression match
216  bool findInPatterns
217  (
218  const bool patternMatch,
219  const word& Keyword,
220  DLList<entry*>::iterator& wcLink,
222  );
223 
224 
225  // Private Classes
226 
227  class includedDictionary;
228 
229 
230 public:
231 
232  //- Declare friendship with the entry class for IO
233  friend class entry;
234 
235 
236  // Declare name of the class and its debug switch
237  ClassName("dictionary");
238 
239 
240  // Public static data
241 
242  //- Null dictionary
243  static const dictionary null;
244 
245  //- If true write optional keywords and values
246  // if not present in dictionary
247  static bool writeOptionalEntries;
248 
249 
250  // Constructors
251 
252  //- Construct top-level dictionary null
253  dictionary();
254 
255  //- Construct top-level empty dictionary with given name
256  dictionary(const fileName& name);
257 
258  //- Construct given the entry name, parent dictionary and Istream,
259  // reading entries until lastEntry or EOF
260  dictionary
261  (
262  const fileName& name,
263  const dictionary& parentDict,
264  Istream&
265  );
266 
267  //- Construct top-level dictionary from Istream,
268  // reading entries until EOF, optionally keeping the header
269  dictionary(Istream&, const bool keepHeader=false);
270 
271  //- Construct top-level dictionary with given T entries
272  template<class T, class ... KeysAndTs>
273  dictionary
274  (
275  const keyType& k,
276  const T& t,
277  const KeysAndTs& ... keysAndTs
278  );
279 
280  //- Construct top-level dictionary with given name and T entries
281  template<class T, class ... KeysAndTs>
282  dictionary
283  (
284  const fileName& name,
285  const keyType& k,
286  const T& t,
287  const KeysAndTs& ... keysAndTs
288  );
289 
290  //- Construct as copy given the parent dictionary
291  dictionary(const dictionary& parentDict, const dictionary&);
292 
293  //- Construct top-level dictionary as copy
294  dictionary(const dictionary&);
295 
296  //- Construct top-level dictionary as copy from pointer to dictionary.
297  // A null pointer is treated like an empty dictionary.
298  dictionary(const dictionary*);
299 
300  //- Move constructor transferring parameter contents
301  // given parent dictionary
302  dictionary(const dictionary& parentDict, dictionary&&);
303 
304  //- Move constructor
306 
307  //- Construct and return clone
308  autoPtr<dictionary> clone() const;
309 
310  //- Construct top-level dictionary on freestore from Istream
312 
313 
314  //- Destructor
315  virtual ~dictionary();
316 
317 
318  // Member Functions
319 
320  //- Return the parent dictionary
321  const dictionary& parent() const
322  {
323  return parent_;
324  }
325 
326  //- Return whether this dictionary is null
327  bool isNull() const
328  {
329  return this == &null;
330  }
331 
332  //- Return the top of the tree
333  const dictionary& topDict() const;
334 
335  //- Return the scoped keyword with which this dictionary can be
336  // accessed from the top dictionary in the tree
337  word topDictKeyword() const;
338 
339  //- Return line number of first token in dictionary
340  label startLineNumber() const;
341 
342  //- Return line number of last token in dictionary
343  label endLineNumber() const;
344 
345  //- Return the SHA1 digest of the dictionary contents
346  SHA1Digest digest() const;
347 
348  //- Return the dictionary as a list of tokens
349  tokenList tokens() const;
350 
351 
352  // Search and lookup
353 
354  //- Search dictionary for given keyword
355  // If recursive, search parent dictionaries
356  // If patternMatch, use regular expressions
357  bool found
358  (
359  const word&,
360  bool recursive=false,
361  bool patternMatch=true
362  ) const;
363 
364  //- Find and return an entry data stream pointer if present
365  // otherwise return nullptr.
366  // If recursive, search parent dictionaries.
367  // If patternMatch, use regular expressions
368  const entry* lookupEntryPtr
369  (
370  const word&,
371  bool recursive,
372  bool patternMatch
373  ) const;
374 
375  //- Find and return an entry data stream pointer for manipulation
376  // if present otherwise return nullptr.
377  // If recursive, search parent dictionaries.
378  // If patternMatch, use regular expressions.
380  (
381  const word&,
382  bool recursive,
383  bool patternMatch
384  );
385 
386  //- Find and return an entry data stream if present, trying a list
387  // of keywords in sequence, otherwise return nullptr.
388  // If recursive, search parent dictionaries.
389  // If patternMatch, use regular expressions
391  (
392  const wordList&,
393  bool recursive,
394  bool patternMatch
395  ) const;
396 
397  //- Find and return an entry data stream if present otherwise error.
398  // If recursive, search parent dictionaries.
399  // If patternMatch, use regular expressions.
400  const entry& lookupEntry
401  (
402  const word&,
403  bool recursive,
404  bool patternMatch
405  ) const;
406 
407  //- Find and return an entry data stream if present, trying a list
408  // of keywords in sequence, otherwise error.
409  // If recursive, search parent dictionaries.
410  // If patternMatch, use regular expressions
412  (
413  const wordList&,
414  bool recursive,
415  bool patternMatch
416  ) const;
417 
418  //- Find and return an entry data stream
419  // If recursive, search parent dictionaries.
420  // If patternMatch, use regular expressions.
422  (
423  const word&,
424  bool recursive=false,
425  bool patternMatch=true
426  ) const;
427 
428  //- Find and return an entry data stream, trying a list of keywords
429  // in sequence
430  // if not found throw a fatal error relating to the first keyword
431  // If recursive, search parent dictionaries.
432  // If patternMatch, use regular expressions.
434  (
435  const wordList&,
436  bool recursive=false,
437  bool patternMatch=true
438  ) const;
439 
440  //- Find and return a T,
441  // if not found throw a fatal error.
442  // If recursive, search parent dictionaries.
443  // If patternMatch, use regular expressions.
444  template<class T>
445  T lookup
446  (
447  const word&,
448  bool recursive=false,
449  bool patternMatch=true
450  ) const;
451 
452  //- Find and return a T, trying a list of keywords in sequence
453  // if not found throw a fatal error relating to the first keyword
454  // If recursive, search parent dictionaries.
455  // If patternMatch, use regular expressions.
456  template<class T>
458  (
459  const wordList&,
460  bool recursive=false,
461  bool patternMatch=true
462  ) const;
463 
464  //- Find and return a T,
465  // if not found return the given default value.
466  // If recursive, search parent dictionaries.
467  // If patternMatch, use regular expressions.
468  template<class T>
470  (
471  const word&,
472  const T&,
473  bool recursive=false,
474  bool patternMatch=true
475  ) const;
476 
477  //- Find and return a T, trying a list of keywords in sequence
478  // if not found throw a fatal error relating to the first keyword
479  // If recursive, search parent dictionaries.
480  // If patternMatch, use regular expressions.
481  template<class T>
483  (
484  const wordList&,
485  const T&,
486  bool recursive=false,
487  bool patternMatch=true
488  ) const;
489 
490  //- Find and return a T, if not found return the given
491  // default value, and add to dictionary.
492  // If recursive, search parent dictionaries.
493  // If patternMatch, use regular expressions.
494  template<class T>
496  (
497  const word&,
498  const T&,
499  bool recursive=false,
500  bool patternMatch=true
501  );
502 
503  //- Find an entry if present, and assign to T
504  // Returns true if the entry was found.
505  // If recursive, search parent dictionaries.
506  // If patternMatch, use regular expressions.
507  template<class T>
508  bool readIfPresent
509  (
510  const word&,
511  T&,
512  bool recursive=false,
513  bool patternMatch=true
514  ) const;
515 
516  //- Find and return an entry data stream pointer if present
517  // otherwise return nullptr. Allows scoping using '/' with
518  // special handling for '!' and '..'.
520  (
521  const word&,
522  bool recursive,
523  bool patternMatch
524  ) const;
525 
526  //- Check if entry is a sub-dictionary
527  bool isDict(const word&) const;
528 
529  //- Find and return a sub-dictionary pointer if present
530  // otherwise return nullptr.
531  const dictionary* subDictPtr(const word&) const;
532 
533  //- Find and return a sub-dictionary pointer if present
534  // otherwise return nullptr.
535  dictionary* subDictPtr(const word&);
536 
537  //- Find and return a sub-dictionary
538  const dictionary& subDict(const word&) const;
539 
540  //- Find and return a sub-dictionary for manipulation
541  dictionary& subDict(const word&);
542 
543  //- Find and return a sub-dictionary, trying a list of keywords in
544  // sequence, otherwise error.
545  const dictionary& subDictBackwardsCompatible(const wordList&) const;
546 
547  //- Find and return a sub-dictionary as a copy, or
548  // return an empty dictionary if the sub-dictionary does not exist
550  (
551  const word&,
552  const bool mustRead = false
553  ) const;
554 
555  //- Find and return a sub-dictionary if found
556  // otherwise return this dictionary
557  const dictionary& optionalSubDict(const word&) const;
558 
559  //- Find and return a sub-dictionary by scoped lookup
560  // i.e. the keyword may contain scope characters.
561  // If the keyword is null this dictionary is returned
562  const dictionary& scopedDict(const word&) const;
563 
564  //- Find and return a sub-dictionary by scoped lookup
565  // i.e. the keyword may contain scope characters.
566  // If the keyword is null this dictionary is returned
567  dictionary& scopedDict(const word&);
568 
569  //- Return the table of contents
570  wordList toc() const;
571 
572  //- Return the sorted table of contents
573  wordList sortedToc() const;
574 
575  //- Return the list of available keys or patterns
576  List<keyType> keys(bool patterns=false) const;
577 
578 
579  // Editing
580 
581  //- Substitute the given keyword prepended by '$' with the
582  // corresponding sub-dictionary entries
583  bool substituteKeyword(const word& keyword);
584 
585  //- Substitute the given scoped keyword prepended by '$' with the
586  // corresponding sub-dictionary entries
587  bool substituteScopedKeyword(const word& keyword);
588 
589  //- Add a new entry
590  // With the merge option, dictionaries are interwoven and
591  // primitive entries are overwritten
592  bool add(entry*, bool mergeEntry=false);
593 
594  //- Add an entry
595  // With the merge option, dictionaries are interwoven and
596  // primitive entries are overwritten
597  void add(const entry&, bool mergeEntry=false);
598 
599  //- Add a word entry
600  // optionally overwrite an existing entry
601  void add(const keyType&, const word&, bool overwrite=false);
602 
603  //- Add a string entry
604  // optionally overwrite an existing entry
605  void add(const keyType&, const string&, bool overwrite=false);
606 
607  //- Add a label entry
608  // optionally overwrite an existing entry
609  void add(const keyType&, const label, bool overwrite=false);
610 
611  //- Add a scalar entry
612  // optionally overwrite an existing entry
613  void add(const keyType&, const scalar, bool overwrite=false);
614 
615  //- Add a dictionary entry
616  // optionally merge with an existing sub-dictionary
617  void add
618  (
619  const keyType&,
620  const dictionary&,
621  bool mergeEntry=false
622  );
623 
624  //- Add a T entry
625  // optionally overwrite an existing entry
626  template<class T>
627  void add(const keyType&, const T&, bool overwrite=false);
628 
629  //- Assign a new entry, overwrite any existing entry
630  void set(entry*);
631 
632  //- Assign a new entry, overwrite any existing entry
633  void set(const entry&);
634 
635  //- Assign a dictionary entry, overwrite any existing entry
636  void set(const keyType&, const dictionary&);
637 
638  //- Assign a T entry, overwrite any existing entry
639  template<class T>
640  void set(const keyType&, const T&);
641 
642  //- Assign multiple T entries, overwriting any existing entries
643  template<class T, class ... KeysAndTs>
644  void set(const keyType&, const T&, const KeysAndTs& ...);
645 
646  //- Remove an entry specified by keyword
647  bool remove(const word&);
648 
649  //- Change the keyword for an entry,
650  // optionally forcing overwrite of an existing entry
651  bool changeKeyword
652  (
653  const keyType& oldKeyword,
654  const keyType& newKeyword,
655  bool forceOverwrite=false
656  );
657 
658  //- Merge entries from the given dictionary.
659  // Also merge sub-dictionaries as required.
660  bool merge(const dictionary&);
661 
662  //- Clear the dictionary
663  void clear();
664 
665  //- Transfer the contents of the argument and annul the argument.
666  void transfer(dictionary&);
667 
668 
669  // Read
670 
671  //- Read dictionary from Istream, optionally keeping the header
672  bool read(Istream&, const bool keepHeader=false);
673 
674  //- Return true if the dictionary global,
675  // i.e. the same on all processors.
676  // Defaults to false, must be overridden by global IO dictionaries
677  virtual bool global() const;
678 
679 
680  // Write
681 
682  //- Write dictionary, normally with sub-dictionary formatting
683  void write(Ostream&, const bool subDict=true) const;
684 
685 
686  // Member Operators
687 
688  //- Find and return entry
689  ITstream& operator[](const word&) const;
690 
691  void operator=(const dictionary&);
692 
693  void operator=(dictionary&&);
694 
695  //- Include entries from the given dictionary.
696  // Warn, but do not overwrite existing entries.
697  void operator+=(const dictionary&);
698 
699  //- Conditionally include entries from the given dictionary.
700  // Do not overwrite existing entries.
701  void operator|=(const dictionary&);
702 
703  //- Unconditionally include entries from the given dictionary.
704  // Overwrite existing entries.
705  void operator<<=(const dictionary&);
706 
707 
708  // IOstream Operators
709 
710  //- Read dictionary from Istream
711  friend Istream& operator>>(Istream&, dictionary&);
712 
713  //- Write dictionary to Ostream
714  friend Ostream& operator<<(Ostream&, const dictionary&);
715 };
716 
717 
718 // Private Classes
719 
721 :
722  public dictionary
723 {
724  // Private Data
725 
726  //- Global IO status inherited from the parent dictionary
727  bool global_;
728 
729 
730 public:
731 
732  // Constructors
733 
734  //- Construct an included dictionary for the given parent
735  // setting the "global" status dictionary without setting the parent
737  (
738  const fileName& fName,
739  const dictionary& parentDict
740  );
741 
742 
743  //- Destructor
744  virtual ~includedDictionary()
745  {}
746 
747 
748  // Member Functions
749 
750  //- Return true if the dictionary global,
751  // i.e. the same on all processors.
752  // Inherited from the parent dictionary into which this is included
753  virtual bool global() const
754  {
755  return global_;
756  }
757 };
758 
759 
760 // Global Operators
761 
762 //- Combine dictionaries.
763 // Starting from the entries in dict1 and then including those from dict2.
764 // Warn, but do not overwrite the entries from dict1.
765 dictionary operator+(const dictionary& dict1, const dictionary& dict2);
766 
767 //- Combine dictionaries.
768 // Starting from the entries in dict1 and then including those from dict2.
769 // Do not overwrite the entries from dict1.
770 dictionary operator|(const dictionary& dict1, const dictionary& dict2);
771 
772 
773 // Global Functions
774 
775 //- Parse dictionary substitution argument list
776 void dictArgList
777 (
778  const string& argString,
779  word& configName,
780  wordReList& args,
781  List<Tuple2<word, string>>& namedArgs
782 );
783 
784 //- Parse dictionary substitution argument list
785 void dictArgList
786 (
787  const string& argString,
788  wordReList& args,
789  List<Tuple2<word, string>>& namedArgs
790 );
791 
792 //- Extracts dict name and keyword
793 Pair<word> dictAndKeyword(const word& scopedName);
794 
795 //- Return the list of configuration files in
796 // user/group/shipped directories.
797 // The search scheme allows for version-specific and
798 // version-independent files using the following hierarchy:
799 // - \b user settings:
800 // - ~/.OpenFOAM/<VERSION>/caseDicts/postProcessing
801 // - ~/.OpenFOAM/caseDicts/postProcessing
802 // - \b group (site) settings (when $WM_PROJECT_SITE is set):
803 // - $WM_PROJECT_SITE/<VERSION>/etc/caseDicts/postProcessing
804 // - $WM_PROJECT_SITE/etc/caseDicts/postProcessing
805 // - \b group (site) settings (when $WM_PROJECT_SITE is not set):
806 // - $WM_PROJECT_INST_DIR/site/<VERSION>/etc/
807 // caseDicts/postProcessing
808 // - $WM_PROJECT_INST_DIR/site/etc/caseDicts/postProcessing
809 // - \b other (shipped) settings:
810 // - $WM_PROJECT_DIR/etc/caseDicts/postProcessing
812 (
813  const fileName& configFilesPath
814 );
815 
816 //- Search for configuration file for given region
817 // and if not present also search the case directory as well as the
818 // user/group/shipped directories.
819 // The search scheme allows for version-specific and
820 // version-independent files using the following hierarchy:
821 // - \b user settings:
822 // - ~/.OpenFOAM/<VERSION>/caseDicts/postProcessing
823 // - ~/.OpenFOAM/caseDicts/postProcessing
824 // - \b group (site) settings (when $WM_PROJECT_SITE is set):
825 // - $WM_PROJECT_SITE/<VERSION>/etc/caseDicts/postProcessing
826 // - $WM_PROJECT_SITE/etc/caseDicts/postProcessing
827 // - \b group (site) settings (when $WM_PROJECT_SITE is not set):
828 // - $WM_PROJECT_INST_DIR/site/<VERSION>/etc/
829 // caseDicts/postProcessing
830 // - $WM_PROJECT_INST_DIR/site/etc/caseDicts/postProcessing
831 // - \b other (shipped) settings:
832 // - $WM_PROJECT_DIR/etc/caseDicts/postProcessing
833 //
834 // \return The path of the configuration file if found
835 // otherwise null
837 (
838  const word& configName,
839  const fileName& configFilesPath,
840  const word& region = word::null
841 );
842 
843 //- Read the specified configuration file
844 // parsing the optional arguments included in the string
845 // 'argString', inserting 'field' or 'fields' entries as required
846 // and merging the resulting configuration dictionary into
847 // 'parentDict'.
848 //
849 // Parses the optional arguments:
850 // 'Q(U)' -> configFileName = Q; args = (U)
851 // -> field U;
852 //
853 // Supports named arguments:
854 // 'patchAverage(patch=inlet, p,U)'
855 // or
856 // 'patchAverage(patch=inlet, field=(p U))'
857 // -> configFileName = patchAverage;
858 // args = (patch=inlet, p,U)
859 // -> patch inlet;
860 // fields (p U);
861 bool readConfigFile
862 (
863  const word& configType,
864  const string& argString,
865  dictionary& parentDict,
866  const fileName& configFilesPath,
867  const Pair<string>& contextTypeAndValue,
868  const word& region = word::null
869 );
870 
871 //- Write a dictionary entry
872 void writeEntry(Ostream& os, const dictionary& dict);
873 
874 //- Helper function to write the keyword and entry
875 template<class EntryType>
876 void writeEntry(Ostream& os, const word& entryName, const EntryType& value);
877 
878 //- Helper function to write the keyword and entry only if the
879 // values are not equal. The value is then output as value2
880 template<class EntryType>
882 (
883  Ostream& os,
884  const word& entryName,
885  const EntryType& value1,
886  const EntryType& value2
887 );
888 
889 
890 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
891 
892 } // End namespace Foam
893 
894 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
895 
896 #ifdef NoRepository
897  #include "dictionaryTemplates.C"
898 #endif
899 
900 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
901 
902 #endif
903 
904 // ************************************************************************* //
Non-intrusive doubly-linked list.
Intrusive doubly-linked list.
label k
graph_traits< Graph >::vertices_size_type size_type
Definition: SloanRenumber.C:73
An STL-conforming hash table.
Definition: HashTable.H:127
Template class for intrusive linked lists.
Definition: ILList.H:67
Input token stream.
Definition: ITstream.H:53
An Istream is an abstract base class for all input systems (streams, files, token lists etc)....
Definition: Istream.H:60
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
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
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:57
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
An auto-pointer similar to the STL auto_ptr but with automatic casting to a reference to the type and...
Definition: autoPtr.H:51
const word dictName() const
Return the local dictionary name (final part of scoped name)
Definition: dictionary.H:121
void operator=(const dictionaryName &name)
Definition: dictionary.H:140
dictionaryName()
Construct dictionaryName null.
Definition: dictionary.H:90
const fileName & name() const
Return the dictionary name.
Definition: dictionary.H:109
includedDictionary(const fileName &fName, const dictionary &parentDict)
Construct an included dictionary for the given parent.
Definition: dictionaryIO.C:72
virtual ~includedDictionary()
Destructor.
Definition: dictionary.H:743
virtual bool global() const
Return true if the dictionary global,.
Definition: dictionary.H:752
A list of keyword definitions, which are a keyword followed by any number of values (e....
Definition: dictionary.H:160
T lookupOrDefaultBackwardsCompatible(const wordList &, const T &, bool recursive=false, bool patternMatch=true) const
Find and return a T, trying a list of keywords in sequence.
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
ClassName("dictionary")
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
virtual bool global() const
Return true if the dictionary global,.
Definition: dictionaryIO.C:153
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
bool read(Istream &, const bool keepHeader=false)
Read dictionary from Istream, optionally keeping the header.
Definition: dictionaryIO.C:108
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
T lookupOrDefault(const word &, const T &, bool recursive=false, bool patternMatch=true) const
Find and return a T,.
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
bool substituteKeyword(const word &keyword)
Substitute the given keyword prepended by '$' with the.
Definition: dictionaryIO.C:159
void set(entry *)
Assign a new entry, overwrite any existing entry.
Definition: dictionary.C:1307
void write(Ostream &, const bool subDict=true) const
Write dictionary, normally with sub-dictionary formatting.
Definition: dictionaryIO.C:204
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
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 & parent() const
Return the parent dictionary.
Definition: dictionary.H:320
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
T lookupOrAddDefault(const word &, const T &, bool recursive=false, bool patternMatch=true)
Find and return a T, if not found return the given.
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
friend Istream & operator>>(Istream &, dictionary &)
Read dictionary from Istream.
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
bool isNull() const
Return whether this dictionary is null.
Definition: dictionary.H:326
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
bool readIfPresent(const word &, T &, bool recursive=false, bool patternMatch=true) const
Find an entry if present, and assign to T.
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
friend Ostream & operator<<(Ostream &, const dictionary &)
Write dictionary to Ostream.
static autoPtr< dictionary > New(Istream &)
Construct top-level dictionary on freestore from Istream.
Definition: dictionaryIO.C:100
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
A class for handling file names.
Definition: fileName.H:82
word name() const
Return file name (part beyond last /)
Definition: fileName.C:195
A class for handling keywords in dictionaries.
Definition: keyType.H:69
A class for handling words, derived from string.
Definition: word.H:62
static const word null
An empty word.
Definition: word.H:77
Macro definitions for declaring ClassName(), NamespaceName(), etc.
Namespace for OpenFOAM.
void writeEntryIfDifferent(Ostream &os, const word &entryName, const EntryType &value1, const EntryType &value2)
Helper function to write the keyword and entry only if the.
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
void dictArgList(const string &argString, word &configName, wordReList &args, List< Tuple2< word, string >> &namedArgs)
Parse dictionary substitution argument list.
Definition: dictionary.C:1653
wordList listAllConfigFiles(const fileName &configFilesPath)
Return the list of configuration files in.
Definition: dictionaryIO.C:406
bool readConfigFile(const word &configType, const string &argString, dictionary &parentDict, const fileName &configFilesPath, const Pair< string > &contextTypeAndValue, const word &region=word::null)
Read the specified configuration file.
Definition: dictionaryIO.C:424
Pair< word > dictAndKeyword(const word &scopedName)
Extracts dict name and keyword.
Definition: dictionary.C:1812
void writeEntry(Ostream &os, const HashTable< T, Key, Hash > &ht)
Definition: HashTableIO.C:96
fileName findConfigFile(const word &configName, const fileName &configFilesPath, const word &region=word::null)
Search for configuration file for given region.
Definition: dictionaryIO.C:351
Istream & operator>>(Istream &, directionInfo &)
tmp< fvMatrix< Type > > operator+(const fvMatrix< Type > &, const fvMatrix< Type > &)
Ostream & operator<<(Ostream &, const ensightPart &)
void T(FieldField< Field, Type > &f1, const FieldField< Field, Type > &f2)
HashSet< Key, Hash > operator|(const HashSet< Key, Hash > &hash1, const HashSet< Key, Hash > &hash2)
Combine entries from HashSets.
dictionary dict
Foam::argList args(argc, argv)