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.
518  // If recursive, search parent dictionaries.
519  // If patternMatch, use regular expressions.
520  // Allows scoping using '/' with special handling for '!' and '..'.
522  (
523  const word&,
524  bool recursive,
525  bool patternMatch
526  ) const;
527 
528  //- Find and return a T,
529  // if not found throw a fatal error.
530  // If recursive, search parent dictionaries.
531  // If patternMatch, use regular expressions.
532  // Allows scoping using '/' with special handling for '!' and '..'.
533  template<class T>
535  (
536  const word&,
537  bool recursive=false,
538  bool patternMatch=true
539  ) const;
540 
541  //- Check if entry is a sub-dictionary
542  bool isDict(const word&) const;
543 
544  //- Find and return a sub-dictionary pointer if present
545  // otherwise return nullptr.
546  const dictionary* subDictPtr(const word&) const;
547 
548  //- Find and return a sub-dictionary pointer if present
549  // otherwise return nullptr.
550  dictionary* subDictPtr(const word&);
551 
552  //- Find and return a sub-dictionary
553  const dictionary& subDict(const word&) const;
554 
555  //- Find and return a sub-dictionary for manipulation
556  dictionary& subDict(const word&);
557 
558  //- Find and return a sub-dictionary, trying a list of keywords in
559  // sequence, otherwise error.
560  const dictionary& subDictBackwardsCompatible(const wordList&) const;
561 
562  //- Find and return a sub-dictionary as a copy, or
563  // return an empty dictionary if the sub-dictionary does not exist
565  (
566  const word&,
567  const bool mustRead = false
568  ) const;
569 
570  //- Find and return a sub-dictionary if found
571  // otherwise return this dictionary
572  const dictionary& optionalSubDict(const word&) const;
573 
574  //- Find and return a sub-dictionary by scoped lookup
575  // i.e. the keyword may contain scope characters.
576  // If the keyword is null this dictionary is returned
577  const dictionary& scopedDict(const word&) const;
578 
579  //- Find and return a sub-dictionary by scoped lookup
580  // i.e. the keyword may contain scope characters.
581  // If the keyword is null this dictionary is returned
582  dictionary& scopedDict(const word&);
583 
584  //- Return the table of contents
585  wordList toc() const;
586 
587  //- Return the sorted table of contents
588  wordList sortedToc() const;
589 
590  //- Return the list of available keys or patterns
591  List<keyType> keys(bool patterns=false) const;
592 
593 
594  // Editing
595 
596  //- Substitute the given keyword prepended by '$' with the
597  // corresponding sub-dictionary entries
598  bool substituteKeyword(const word& keyword);
599 
600  //- Substitute the given scoped keyword prepended by '$' with the
601  // corresponding sub-dictionary entries
602  bool substituteScopedKeyword(const word& keyword);
603 
604  //- Add a new entry
605  // With the merge option, dictionaries are interwoven and
606  // primitive entries are overwritten
607  bool add(entry*, bool mergeEntry=false);
608 
609  //- Add an entry
610  // With the merge option, dictionaries are interwoven and
611  // primitive entries are overwritten
612  void add(const entry&, bool mergeEntry=false);
613 
614  //- Add a word entry
615  // optionally overwrite an existing entry
616  void add(const keyType&, const word&, bool overwrite=false);
617 
618  //- Add a string entry
619  // optionally overwrite an existing entry
620  void add(const keyType&, const string&, bool overwrite=false);
621 
622  //- Add a label entry
623  // optionally overwrite an existing entry
624  void add(const keyType&, const label, bool overwrite=false);
625 
626  //- Add a scalar entry
627  // optionally overwrite an existing entry
628  void add(const keyType&, const scalar, bool overwrite=false);
629 
630  //- Add a dictionary entry
631  // optionally merge with an existing sub-dictionary
632  void add
633  (
634  const keyType&,
635  const dictionary&,
636  bool mergeEntry=false
637  );
638 
639  //- Add a T entry
640  // optionally overwrite an existing entry
641  template<class T>
642  void add(const keyType&, const T&, bool overwrite=false);
643 
644  //- Assign a new entry, overwrite any existing entry
645  void set(entry*);
646 
647  //- Assign a new entry, overwrite any existing entry
648  void set(const entry&);
649 
650  //- Assign a dictionary entry, overwrite any existing entry
651  void set(const keyType&, const dictionary&);
652 
653  //- Assign a T entry, overwrite any existing entry
654  template<class T>
655  void set(const keyType&, const T&);
656 
657  //- Assign multiple T entries, overwriting any existing entries
658  template<class T, class ... KeysAndTs>
659  void set(const keyType&, const T&, const KeysAndTs& ...);
660 
661  //- Remove an entry specified by keyword
662  bool remove(const word&);
663 
664  //- Change the keyword for an entry,
665  // optionally forcing overwrite of an existing entry
666  bool changeKeyword
667  (
668  const keyType& oldKeyword,
669  const keyType& newKeyword,
670  bool forceOverwrite=false
671  );
672 
673  //- Merge entries from the given dictionary.
674  // Also merge sub-dictionaries as required.
675  bool merge(const dictionary&);
676 
677  //- Clear the dictionary
678  void clear();
679 
680  //- Transfer the contents of the argument and annul the argument.
681  void transfer(dictionary&);
682 
683 
684  // Read
685 
686  //- Read dictionary from Istream, optionally keeping the header
687  bool read(Istream&, const bool keepHeader=false);
688 
689  //- Return true if the dictionary global,
690  // i.e. the same on all processors.
691  // Defaults to false, must be overridden by global IO dictionaries
692  virtual bool global() const;
693 
694 
695  // Write
696 
697  //- Write dictionary, normally with sub-dictionary formatting
698  void write(Ostream&, const bool subDict=true) const;
699 
700 
701  // Member Operators
702 
703  //- Find and return entry
704  ITstream& operator[](const word&) const;
705 
706  void operator=(const dictionary&);
707 
708  void operator=(dictionary&&);
709 
710  //- Include entries from the given dictionary.
711  // Warn, but do not overwrite existing entries.
712  void operator+=(const dictionary&);
713 
714  //- Conditionally include entries from the given dictionary.
715  // Do not overwrite existing entries.
716  void operator|=(const dictionary&);
717 
718  //- Unconditionally include entries from the given dictionary.
719  // Overwrite existing entries.
720  void operator<<=(const dictionary&);
721 
722 
723  // IOstream Operators
724 
725  //- Read dictionary from Istream
726  friend Istream& operator>>(Istream&, dictionary&);
727 
728  //- Write dictionary to Ostream
729  friend Ostream& operator<<(Ostream&, const dictionary&);
730 };
731 
732 
733 // Private Classes
734 
736 :
737  public dictionary
738 {
739  // Private Data
740 
741  //- Global IO status inherited from the parent dictionary
742  bool global_;
743 
744 
745 public:
746 
747  // Constructors
748 
749  //- Construct an included dictionary for the given parent
750  // setting the "global" status dictionary without setting the parent
752  (
753  const fileName& fName,
754  const dictionary& parentDict
755  );
756 
757 
758  //- Destructor
759  virtual ~includedDictionary()
760  {}
761 
762 
763  // Member Functions
764 
765  //- Return true if the dictionary global,
766  // i.e. the same on all processors.
767  // Inherited from the parent dictionary into which this is included
768  virtual bool global() const
769  {
770  return global_;
771  }
772 };
773 
774 
775 // Global Operators
776 
777 //- Combine dictionaries.
778 // Starting from the entries in dict1 and then including those from dict2.
779 // Warn, but do not overwrite the entries from dict1.
780 dictionary operator+(const dictionary& dict1, const dictionary& dict2);
781 
782 //- Combine dictionaries.
783 // Starting from the entries in dict1 and then including those from dict2.
784 // Do not overwrite the entries from dict1.
785 dictionary operator|(const dictionary& dict1, const dictionary& dict2);
786 
787 
788 // Global Functions
789 
790 //- Parse dictionary substitution argument list
791 void dictArgList
792 (
793  const string& argString,
794  word& configName,
795  wordReList& args,
796  List<Tuple2<word, string>>& namedArgs
797 );
798 
799 //- Parse dictionary substitution argument list
800 void dictArgList
801 (
802  const string& argString,
803  wordReList& args,
804  List<Tuple2<word, string>>& namedArgs
805 );
806 
807 //- Extracts dict name and keyword
808 Pair<word> dictAndKeyword(const word& scopedName);
809 
810 //- Return the list of configuration files in
811 // user/group/shipped directories.
812 // The search scheme allows for version-specific and
813 // version-independent files using the following hierarchy:
814 // - \b user settings:
815 // - ~/.OpenFOAM/<VERSION>/caseDicts/postProcessing
816 // - ~/.OpenFOAM/caseDicts/postProcessing
817 // - \b group (site) settings (when $WM_PROJECT_SITE is set):
818 // - $WM_PROJECT_SITE/<VERSION>/etc/caseDicts/postProcessing
819 // - $WM_PROJECT_SITE/etc/caseDicts/postProcessing
820 // - \b group (site) settings (when $WM_PROJECT_SITE is not set):
821 // - $WM_PROJECT_INST_DIR/site/<VERSION>/etc/
822 // caseDicts/postProcessing
823 // - $WM_PROJECT_INST_DIR/site/etc/caseDicts/postProcessing
824 // - \b other (shipped) settings:
825 // - $WM_PROJECT_DIR/etc/caseDicts/postProcessing
827 (
828  const fileName& configFilesPath
829 );
830 
831 //- Search for configuration file for given region
832 // and if not present also search the case directory as well as the
833 // user/group/shipped directories.
834 // The search scheme allows for version-specific and
835 // version-independent files using the following hierarchy:
836 // - \b user settings:
837 // - ~/.OpenFOAM/<VERSION>/caseDicts/postProcessing
838 // - ~/.OpenFOAM/caseDicts/postProcessing
839 // - \b group (site) settings (when $WM_PROJECT_SITE is set):
840 // - $WM_PROJECT_SITE/<VERSION>/etc/caseDicts/postProcessing
841 // - $WM_PROJECT_SITE/etc/caseDicts/postProcessing
842 // - \b group (site) settings (when $WM_PROJECT_SITE is not set):
843 // - $WM_PROJECT_INST_DIR/site/<VERSION>/etc/
844 // caseDicts/postProcessing
845 // - $WM_PROJECT_INST_DIR/site/etc/caseDicts/postProcessing
846 // - \b other (shipped) settings:
847 // - $WM_PROJECT_DIR/etc/caseDicts/postProcessing
848 //
849 // \return The path of the configuration file if found
850 // otherwise null
852 (
853  const word& configName,
854  const fileName& configFilesPath,
855  const word& region = word::null
856 );
857 
858 //- Read the specified configuration file
859 // parsing the optional arguments included in the string
860 // 'argString', inserting 'field' or 'fields' entries as required
861 // and merging the resulting configuration dictionary into
862 // 'parentDict'.
863 //
864 // Parses the optional arguments:
865 // 'Q(U)' -> configFileName = Q; args = (U)
866 // -> field U;
867 //
868 // Supports named arguments:
869 // 'patchAverage(patch=inlet, p,U)'
870 // or
871 // 'patchAverage(patch=inlet, field=(p U))'
872 // -> configFileName = patchAverage;
873 // args = (patch=inlet, p,U)
874 // -> patch inlet;
875 // fields (p U);
876 bool readConfigFile
877 (
878  const word& configType,
879  const string& argString,
880  dictionary& parentDict,
881  const fileName& configFilesPath,
882  const Pair<string>& contextTypeAndValue,
883  const word& region = word::null
884 );
885 
886 //- Write a dictionary entry
887 void writeEntry(Ostream& os, const dictionary& dict);
888 
889 //- Helper function to write the keyword and entry
890 template<class EntryType>
891 void writeEntry(Ostream& os, const word& entryName, const EntryType& value);
892 
893 //- Helper function to write the keyword and entry only if the
894 // values are not equal. The value is then output as value2
895 template<class EntryType>
897 (
898  Ostream& os,
899  const word& entryName,
900  const EntryType& value1,
901  const EntryType& value2
902 );
903 
904 
905 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
906 
907 } // End namespace Foam
908 
909 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
910 
911 #ifdef NoRepository
912  #include "dictionaryTemplates.C"
913 #endif
914 
915 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
916 
917 #endif
918 
919 // ************************************************************************* //
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:76
virtual ~includedDictionary()
Destructor.
Definition: dictionary.H:758
virtual bool global() const
Return true if the dictionary global,.
Definition: dictionary.H:767
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:157
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:112
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:163
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:211
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:104
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
T lookupScoped(const word &, bool recursive=false, bool patternMatch=true) const
Find and return a T,.
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:413
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:431
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:358
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)