Loading...
Searching...
No Matches
dictionary.C
Go to the documentation of this file.
1/*---------------------------------------------------------------------------*\
2 ========= |
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4 \\ / O peration |
5 \\ / A nd | www.openfoam.com
6 \\/ M anipulation |
7-------------------------------------------------------------------------------
8 Copyright (C) 2011-2017 OpenFOAM Foundation
9 Copyright (C) 2015-2025 OpenCFD Ltd.
10-------------------------------------------------------------------------------
11License
12 This file is part of OpenFOAM.
13
14 OpenFOAM is free software: you can redistribute it and/or modify it
15 under the terms of the GNU General Public License as published by
16 the Free Software Foundation, either version 3 of the License, or
17 (at your option) any later version.
18
19 OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
20 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
21 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
22 for more details.
23
24 You should have received a copy of the GNU General Public License
25 along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
26
27\*---------------------------------------------------------------------------*/
28
29#include "dictionary.H"
30#include "error.H"
31#include "JobInfo.H"
32#include "primitiveEntry.H"
33#include "dictionaryEntry.H"
34#include "regExp.H"
35#include "OSHA1stream.H"
36#include "OSstream.H"
37#include "argList.H"
38#include "registerSwitch.H"
39
40/* * * * * * * * * * * * * * * Static Member Data * * * * * * * * * * * * * */
41
42namespace Foam
43{
45}
46
48
52(
53 Foam::debug::infoSwitch("writeOptionalEntries", 0)
54);
55
56
58(
59 "writeOptionalEntries",
60 int,
62);
63
64
65// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
66
67Foam::word Foam::dictionary::executableName()
70}
71
72
73// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
74
76:
77 name_(),
78 parent_(dictionary::null)
79{}
80
81
83:
84 name_(name),
85 parent_(dictionary::null)
86{}
87
88
90(
91 const dictionary& parentDict,
92 const dictionary& dict
93)
94:
95 parent_type(dict, *this),
96 name_(dict.name()),
97 parent_(parentDict)
98{
99 for (entry& e : *this)
100 {
101 hashedEntries_.insert(e.keyword(), &e);
102
103 if (e.keyword().isPattern())
104 {
105 patterns_.push_front(&e);
106 regexps_.push_front(autoPtr<regExp>::New(e.keyword()));
107 }
108 }
109}
110
111
113(
114 const dictionary& dict
115)
116:
117 parent_type(dict, *this),
118 name_(dict.name()),
119 parent_(dictionary::null)
120{
121 for (entry& e : *this)
122 {
123 hashedEntries_.insert(e.keyword(), &e);
124
125 if (e.keyword().isPattern())
126 {
127 patterns_.push_front(&e);
128 regexps_.push_front(autoPtr<regExp>::New(e.keyword()));
129 }
130 }
131}
132
133
135:
136 name_(),
137 parent_(dictionary::null)
138{
139 if (dict)
140 {
141 operator=(*dict);
142 }
143}
144
145
147(
148 const dictionary& parentDict,
150)
151:
152 name_(),
153 parent_(parentDict)
154{
155 transfer(dict);
156 name() = fileName::concat(parentDict.name(), name(), '/');
157}
158
159
161(
163)
164:
165 name_(),
166 parent_(dictionary::null)
167{
168 transfer(dict);
169}
170
171
174 return autoPtr<dictionary>::New(*this);
175}
176
177
178// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
183
184// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
186Foam::fileName Foam::dictionary::relativeName(const bool caseTag) const
187{
188 return argList::envRelativePath(name(), caseTag);
189}
190
191
193{
194 const dictionary& p = parent();
195
196 if (&p != this && !p.name().empty())
197 {
198 return p.topDict();
199 }
200
201 return *this;
202}
203
204
205Foam::label Foam::dictionary::startLineNumber() const
206{
207 return
208 (
210 ? -1
212 );
213}
214
215
216Foam::label Foam::dictionary::endLineNumber() const
217{
218 return
219 (
221 ? -1
223 );
224}
225
226
228{
230
231 // Process entries
232 for (const entry& e : *this)
233 {
234 os << e;
235 }
236
237 return os.digest();
238}
239
240
242{
243 // Serialize dictionary entries into a string
244 OCharStream os;
245
246 // Process entries
247 for (const entry& e : *this)
248 {
249 os << e;
251
252 // String re-parsed as a list of tokens
253 return ITstream::parse(os.view());
254}
255
256
258(
259 const ITstream& is,
260 const word& keyword
261) const
262{
263 const label remaining = (is.size() ? is.nRemainingTokens() : -100);
264
265 if (!remaining)
266 {
267 return;
268 }
269
270 // Similar to SafeFatalIOError
272 {
273 OSstream& err =
275 (
276 "", // functionName
277 "", // sourceFileName
278 0, // sourceFileLineNumber
279 relativeName(), // ioFileName == dictionary name
280 is.lineNumber() // ioStartLineNumber
281 );
282
283 if (remaining > 0)
284 {
285 err
286 << "Entry '" << keyword << "' has "
287 << remaining << " excess tokens in stream" << nl << nl
288 << " ";
289 is.writeList(err, 0); // <- flatOutput
290 }
291 else
292 {
293 err << "Entry '" << keyword
294 << "' had no tokens in stream" << nl << nl;
295 }
296
297 err << exit(FatalIOError);
298 }
299 else
300 {
301 // Not yet constructed
302
303 std::cerr
304 << nl
305 << "--> FOAM FATAL IO ERROR:" << nl;
306
307 if (remaining > 0)
308 {
309 std::cerr
310 << "Entry '" << keyword << "' has "
311 << remaining << " excess tokens in stream" << nl << nl;
312 }
313 else
314 {
315 std::cerr
316 << "Entry '" << keyword
317 << "' had no tokens in stream" << nl << nl;
318 }
319
320 std::cerr
321 // ioFileName == dictionary name
322 << "file: " << relativeName()
323 << " at line " << is.lineNumber() << '.' << nl
324 << std::endl;
325
326 std::exit(1);
327 }
328}
329
330
331void Foam::dictionary::raiseBadInput
332(
333 const ITstream& is,
334 const word& keyword
335) const
336{
337 // Can use FatalIOError instead of SafeFatalIOError
338 // since predicate checks are not used at the earliest stages
340 (
341 "", // functionName
342 "", // sourceFileName
343 0, // sourceFileLineNumber
344 relativeName(), // ioFileName == dictionary name
345 is.lineNumber(), // ioStartLineNumber
346 -1 // ioEndLineNumber
347 )
348 << "Entry '" << keyword << "' with invalid input" << nl
349 << exit(FatalIOError);
350}
351
352
354(
355 const word& keyword,
356 enum keyType::option matchOpt
357) const
358{
359 const entry* eptr = findEntry(keyword, matchOpt);
360
361 if (!eptr)
362 {
364 << "Entry '" << keyword << "' not found in dictionary "
365 << relativeName() << nl
367 }
368
369 return *eptr;
370}
371
372
374(
375 const word& keyword,
376 enum keyType::option matchOpt
377) const
378{
379 return lookupEntry(keyword, matchOpt).stream();
380}
381
382
384(
385 const word& keyword,
386 bool mergeEntry
387)
388{
389 if (keyword.size() < 2)
390 {
391 return false;
392 }
393
394 // Drop leading '$' to get the var-name, already validated as word.
395 const word varName(keyword.substr(1), false);
396
397 // Lookup the variable name in the given dictionary
398 const const_searcher finder(csearch(varName, keyType::REGEX_RECURSIVE));
399
400 // If defined insert its entries into this dictionary
401 if (finder.good())
402 {
403 for (const entry& e : finder.dict())
404 {
405 add(e, mergeEntry);
406 }
407
408 return true;
409 }
410
411 return false;
412}
413
414
416(
417 const word& keyword,
418 bool mergeEntry
419)
420{
421 if (keyword.size() < 2)
422 {
423 return false;
424 }
425
426 // Drop leading '$' to get the var-name, already validated as word.
427 const word varName(keyword.substr(1), false);
428
429 // Lookup the variable name in the given dictionary
430 const auto finder(csearchScoped(varName, keyType::REGEX_RECURSIVE));
431
432 // If defined insert its entries into this dictionary
433 if (finder.good())
434 {
435 for (const entry& e : finder.dict())
436 {
437 add(e, mergeEntry);
438 }
439
440 return true;
441 }
442
443 return false;
444}
445
446
448(
449 const word& keyword,
450 enum keyType::option matchOpt
451) const
452{
453 const const_searcher finder(csearch(keyword, matchOpt));
454
455 if (!finder.good())
456 {
458 << "Entry '" << keyword << "' not found in dictionary "
459 << relativeName() << nl
461 }
462
463 return finder.dict();
464}
465
466
468(
469 const word& keyword,
470 enum keyType::option matchOpt
471)
472{
473 searcher finder(search(keyword, matchOpt));
474
475 if (!finder.good())
476 {
478 << "Entry '" << keyword << "' not found in dictionary "
479 << relativeName() << nl
481 }
482
483 return finder.dict();
484}
485
486
488(
489 const word& keyword,
490 enum keyType::option matchOpt
491)
492{
493 searcher finder(search(keyword, matchOpt));
494
495 dictionary* dictPtr = finder.dictPtr();
496
497 if (dictPtr)
498 {
499 // Found and a sub-dictionary
500 return *dictPtr;
501 }
502
503 if (finder.good())
504 {
506 << "Entry '" << keyword
507 << "' is not a sub-dictionary in dictionary "
508 << relativeName() << nl
509 << exit(FatalIOError);
510 }
511
512 dictPtr = this->set(keyword, dictionary())->dictPtr();
513
514 if (!dictPtr)
515 {
517 << "Failed to insert sub-dictionary '" << keyword
518 << "' in dictionary "
519 << relativeName() << nl
521 }
522
523 return *dictPtr;
524}
525
526
528(
529 const word& keyword,
530 enum keyType::option matchOpt,
531 const bool mandatory
532) const
533{
534 const const_searcher finder(csearch(keyword, matchOpt));
535
536 const dictionary* dictPtr = finder.dictPtr();
537
538 if (dictPtr)
539 {
540 // Found and a sub-dictionary
541 return *dictPtr;
542 }
543
544 if (mandatory)
545 {
547 << "Entry '" << keyword
548 << "' is not a sub-dictionary in dictionary "
549 << relativeName() << nl
550 << exit(FatalIOError);
551 }
552
553 if (finder.good())
554 {
556 << "Entry '" << keyword
557 << "' found but not a sub-dictionary in dictionary "
558 << relativeName() << endl;
560
561 // The move constructor properly qualifies the dictionary name
562 return dictionary(*this, dictionary(fileName(keyword)));
563}
564
565
567(
568 const word& keyword,
569 enum keyType::option matchOpt
570) const
571{
572 const const_searcher finder(csearch(keyword, matchOpt));
573
574 const dictionary* dictPtr = finder.dictPtr();
575
576 if (dictPtr)
577 {
578 // Found and a sub-dictionary
579 return *dictPtr;
580 }
581
582 if (finder.good())
583 {
585 << "Entry '" << keyword
586 << "' found but not a sub-dictionary in dictionary "
588 }
589
590 return *this;
591}
592
593
595{
596 wordList list(size());
597
598 label n = 0;
599 for (const entry& e : *this)
600 {
601 list[n++] = e.keyword();
602 }
603
604 return list;
605}
606
609{
610 return hashedEntries_.sortedToc();
611}
612
613
615{
616 List<keyType> list(size());
617
618 label n = 0;
619 for (const entry& e : *this)
620 {
621 if (e.keyword().isPattern() ? patterns : !patterns)
622 {
623 list[n++] = e.keyword();
624 }
626 list.resize(n);
627
628 return list;
629}
630
631
632Foam::entry* Foam::dictionary::add(entry* entryPtr, bool mergeEntry)
633{
634 if (!entryPtr)
635 {
636 return nullptr;
637 }
638
639 auto iter = hashedEntries_.find(entryPtr->keyword());
640
641 if (mergeEntry && iter.good())
642 {
643 // Merge dictionary with dictionary
644 if (iter()->isDict() && entryPtr->isDict())
645 {
646 iter()->dict().merge(entryPtr->dict());
647
648 delete entryPtr;
649 return iter(); // pointer to existing dictionary
650 }
651
652
653 // Replace existing dictionary with entry or vice versa
654 parent_type::replace(iter(), entryPtr);
655 delete iter();
656 hashedEntries_.erase(iter);
657
658 if (hashedEntries_.insert(entryPtr->keyword(), entryPtr))
659 {
660 entryPtr->name() =
661 fileName::concat(name(), entryPtr->keyword(), '/');
662
663 if (entryPtr->keyword().isPattern())
664 {
665 patterns_.push_front(entryPtr);
666 regexps_.push_front(autoPtr<regExp>::New(entryPtr->keyword()));
667 }
668
669 return entryPtr; // now an entry in the dictionary
670 }
671
672
674 << "Problem replacing entry "<< entryPtr->keyword()
675 << " in dictionary " << relativeName() << endl;
676
677 parent_type::remove(entryPtr);
678
679 delete entryPtr;
680 return nullptr;
681 }
682
683
684 if (hashedEntries_.insert(entryPtr->keyword(), entryPtr))
685 {
686 entryPtr->name() =
687 fileName::concat(name(), entryPtr->keyword(), '/');
688
689 parent_type::push_back(entryPtr);
690
691 if (entryPtr->keyword().isPattern())
692 {
693 patterns_.push_front(entryPtr);
694 regexps_.push_front(autoPtr<regExp>::New(entryPtr->keyword()));
695 }
696
697 return entryPtr; // now an entry in the dictionary
698 }
699
700
702 << "Attempt to add entry " << entryPtr->keyword()
703 << " which already exists in dictionary "
705
706 delete entryPtr;
707 return nullptr;
708}
709
711Foam::entry* Foam::dictionary::add(const entry& e, bool mergeEntry)
712{
713 return add(e.clone(*this).ptr(), mergeEntry);
714}
715
716
718(
719 const keyType& k,
720 const word& v,
721 bool overwrite
722)
723{
724 return add(new primitiveEntry(k, token(v)), overwrite);
725}
726
727
729(
730 const keyType& k,
731 const Foam::string& v,
732 bool overwrite
733)
734{
735 return add(new primitiveEntry(k, token(v)), overwrite);
736}
737
738
740(
741 const keyType& k,
742 const label v,
743 bool overwrite
744)
745{
746 return add(new primitiveEntry(k, token(v)), overwrite);
747}
748
749
751(
752 const keyType& k,
753 const scalar v,
754 bool overwrite
755)
756{
757 return add(new primitiveEntry(k, token(v)), overwrite);
758}
759
760
762(
763 const keyType& k,
764 const dictionary& v,
765 bool mergeEntry
766)
767{
768 return add(new dictionaryEntry(k, *this, v), mergeEntry);
769}
770
771
773{
774 if (!entryPtr)
775 {
776 return nullptr;
777 }
778
779 // Find non-recursive with patterns
780 searcher finder(search(entryPtr->keyword(), keyType::REGEX));
781
782 dictionary* dictPtr = finder.dictPtr();
783
784 // Clear dictionary so merge acts like overwrite
785 if (dictPtr)
786 {
787 dictPtr->clear();
788 }
789
790 return add(entryPtr, true);
791}
792
795{
796 return set(e.clone(*this).ptr());
797}
798
801{
802 return set(new dictionaryEntry(k, *this, v));
803}
804
806Foam::entry* Foam::dictionary::set(const keyType& k, std::nullptr_t)
807{
808 return set(new primitiveEntry(k));
809}
810
815}
816
819{
820 return set(new primitiveEntry(k, std::move(tokens)));
821}
822
823
825{
826 if (this == &dict)
827 {
829 << "Attempted merge to self, for dictionary "
830 << relativeName() << nl
832 }
833
834 bool changed = false;
835
836 for (const entry& e : dict)
837 {
838 auto fnd = hashedEntries_.find(e.keyword());
839
840 if (fnd.good())
841 {
842 // Recursively merge sub-dictionaries
843 // TODO: merge without copying
844 if (fnd()->isDict() && e.isDict())
845 {
846 if (fnd()->dict().merge(e.dict()))
847 {
848 changed = true;
849 }
850 }
851 else
852 {
853 add(e.clone(*this).ptr(), true);
854 changed = true;
855 }
856 }
857 else
858 {
859 // Not found - just add
860 add(e.clone(*this).ptr());
861 changed = true;
863 }
864
865 return changed;
866}
867
868
870{
872 hashedEntries_.clear();
873 patterns_.clear();
874 regexps_.clear();
875}
876
877
879{
880 // Changing parents probably doesn't make much sense,
881 // but what about the names?
882 name() = dict.name();
883
884 parent_type::transfer(dict);
885 hashedEntries_.transfer(dict.hashedEntries_);
886 patterns_.transfer(dict.patterns_);
887 regexps_.transfer(dict.regexps_);
888}
889
890
891// * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
892
894{
895 if (this == &rhs)
896 {
897 return; // Self-assignment is a no-op
898 }
899
900 name() = rhs.name();
901 clear();
902
903 // Create clones of the entries in the given dictionary
904 // resetting the parentDict to this dictionary
905
906 for (const entry& e : rhs)
907 {
908 add(e.clone(*this).ptr());
909 }
910}
911
912
914{
915 if (this == &rhs)
916 {
918 << "Attempted addition to self, for dictionary "
919 << relativeName() << nl
921 }
922
923 for (const entry& e : rhs)
924 {
925 add(e.clone(*this).ptr());
926 }
927}
928
929
931{
932 if (this == &rhs)
933 {
935 << "Attempted |= merging to self, for dictionary "
936 << relativeName() << nl
938 }
939
940 for (const entry& e : rhs)
941 {
942 if (!found(e.keyword()))
944 add(e.clone(*this).ptr());
945 }
946 }
947}
948
949
951{
952 if (this == &rhs)
953 {
955 << "Attempted addition to self, for dictionary "
956 << relativeName() << nl
958 }
959
960 for (const entry& e : rhs)
961 {
962 set(e.clone(*this).ptr());
963 }
964}
965
966
967/* * * * * * * * * * * * * * * * Global operators * * * * * * * * * * * * * */
968
969Foam::dictionary Foam::operator+
970(
971 const dictionary& dict1,
972 const dictionary& dict2
973)
975 dictionary result(dict1);
976 result += dict2;
977 return result;
978}
979
980
981Foam::dictionary Foam::operator|
982(
983 const dictionary& dict1,
984 const dictionary& dict2
985)
986{
987 dictionary result(dict1);
988 result |= dict2;
989 return result;
990}
991
992
993// ************************************************************************* //
label k
bool found
label n
bool empty() const noexcept
True if the list is empty.
Definition DLListBase.H:189
void push_back(link *item)
Add at back of list.
Definition DLListBase.C:52
link * replace(link *oldLink, link *newLink)
Replace oldLink with newLink and return element.
Definition DLListBase.C:214
label size() const noexcept
The number of elements in list.
Definition DLListBase.H:194
tmp< GeometricField< Type, PatchField, GeoMesh > > clone() const
Clone.
void transfer(ILList< DLListBase, T > &lst)
label lineNumber() const noexcept
Const access to the current stream line number.
Definition IOstream.H:409
An input stream of tokens.
Definition ITstream.H:56
static tokenList parse(const UList< char > &input, IOstreamOption streamOpt=IOstreamOption())
Create token list by parsing the input character sequence until no good tokens remain.
Definition ITstream.H:268
label nRemainingTokens() const noexcept
Number of tokens remaining.
Definition ITstream.H:432
static bool constructed
Global value for constructed job info.
Definition JobInfo.H:115
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
Definition List.H:72
void resize(const label len)
Adjust allocated size of list.
Definition ListI.H:153
An OSstream with internal List storage.
The output stream for calculating SHA1 digests.
Generic output stream using a standard (STL) stream.
Definition OSstream.H:53
The SHA1 message digest.
Definition SHA1Digest.H:58
A 1D vector of objects of type <T>, where the size of the vector is known and can be used for subscri...
Definition UList.H:89
void size(const label n)
Older name for setAddressableSize.
Definition UList.H:118
Ostream & writeList(Ostream &os, const label shortLen=0) const
Write List, with line-breaks in ASCII when length exceeds shortLen.
Definition UListIO.C:90
static fileName envRelativePath(const fileName &input, const bool caseTag=false)
Return the input relative to the globalPath by stripping off a leading value of the envGlobalPath.
Definition argList.C:675
static word envExecutable()
Name of the executable from environment variable.
Definition argList.C:662
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
Definition autoPtr.H:65
static autoPtr< T > New(Args &&... args)
Construct autoPtr with forwarding arguments.
Definition autoPtr.H:178
A keyword and a list of tokens is a 'dictionaryEntry'.
bool good() const noexcept
True if entry was found.
Definition dictionary.H:234
dict_reference dict() const
Return the found entry as a dictionary. Error if not found, or not a dictionary.
Definition dictionary.H:294
dict_pointer dictPtr() const noexcept
Pointer to the found entry as a dictionary, nullptr otherwise.
Definition dictionary.H:277
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition dictionary.H:133
dictionary subOrEmptyDict(const word &keyword, enum keyType::option matchOpt=keyType::REGEX, const bool mandatory=false) const
Find and return a sub-dictionary as a copy, otherwise return an empty dictionary.
Definition dictionary.C:521
void transfer(dictionary &dict)
Transfer the contents of the argument and annul the argument.
Definition dictionary.C:871
const dictionary & optionalSubDict(const word &keyword, enum keyType::option matchOpt=keyType::REGEX) const
Find and return a sub-dictionary, otherwise return this dictionary.
Definition dictionary.C:560
const fileName & name() const noexcept
The dictionary name.
Definition dictionaryI.H:41
dictionary & subDictOrAdd(const word &keyword, enum keyType::option matchOpt=keyType::REGEX)
Find and return a sub-dictionary for manipulation.
Definition dictionary.C:481
void checkITstream(const ITstream &is, const word &keyword) const
Check after reading if the input token stream has unconsumed tokens remaining or if there were no tok...
Definition dictionary.C:251
const dictionary & subDict(const word &keyword, enum keyType::option matchOpt=keyType::REGEX) const
Find and return a sub-dictionary.
Definition dictionary.C:441
const dictionary & topDict() const
Return the top of the tree.
Definition dictionary.C:185
void operator<<=(const dictionary &rhs)
Unconditionally include entries from the given dictionary.
Definition dictionary.C:943
static refPtr< OSstream > reportingOutput
Output location when reporting default values.
Definition dictionary.H:492
bool substituteKeyword(const word &keyword, bool mergeEntry=false)
Substitute the given keyword (which is prefixed by '$').
Definition dictionary.C:377
dictionary()
Default construct, a top-level empty dictionary.
Definition dictionary.C:68
autoPtr< dictionary > clone() const
Construct and return clone.
Definition dictionary.C:165
static int writeOptionalEntries
Report optional keywords and values if not present in dictionary.
Definition dictionary.H:482
fileName relativeName(const bool caseTag=false) const
The dictionary name relative to the case.
Definition dictionary.C:179
bool merge(const dictionary &dict)
Merge entries from the given dictionary.
Definition dictionary.C:817
const entry * findEntry(const word &keyword, enum keyType::option matchOpt=keyType::REGEX) const
Find an entry (const access) with the given keyword.
Definition dictionaryI.H:84
const_searcher csearchScoped(const word &keyword, enum keyType::option matchOpt) const
Search using scoping.
tokenList tokens() const
Return the dictionary as a list of tokens.
Definition dictionary.C:234
void operator|=(const dictionary &rhs)
Conditionally include entries from the given dictionary.
Definition dictionary.C:923
List< keyType > keys(bool patterns=false) const
Return the list of available keys or patterns.
Definition dictionary.C:607
friend class entry
Declare friendship with the entry class for IO.
Definition dictionary.H:338
ITstream & lookup(const word &keyword, enum keyType::option matchOpt=keyType::REGEX) const
Find and return an entry data stream. FatalIOError if not found, or not a stream.
Definition dictionary.C:367
label endLineNumber() const
Return line number of last token in dictionary.
Definition dictionary.C:209
bool substituteScopedKeyword(const word &keyword, bool mergeEntry=false)
Substitute the given scoped keyword (which is prefixed by '$').
Definition dictionary.C:409
wordList sortedToc() const
Return the sorted table of contents.
Definition dictionary.C:601
const dictionary & parent() const noexcept
Return the parent dictionary.
Definition dictionaryI.H:77
const entry & lookupEntry(const word &keyword, enum keyType::option matchOpt) const
Search for an entry (const access) with the given keyword.
Definition dictionary.C:347
const_searcher csearch(const word &keyword, enum keyType::option matchOpt=keyType::REGEX) const
Search dictionary for given keyword.
Searcher< false > searcher
Searcher with non-const access.
Definition dictionary.H:330
Searcher< true > const_searcher
Searcher with const access.
Definition dictionary.H:325
void clear()
Clear the dictionary.
Definition dictionary.C:862
virtual ~dictionary()
Destructor.
Definition dictionary.C:173
bool isDict(const word &keyword, enum keyType::option matchOpt=keyType::REGEX) const
Check for existence of a sub-dictionary. Generally prefer findDict() for more flexibility.
entry * add(entry *entryPtr, bool mergeEntry=false)
Add a new entry.
Definition dictionary.C:625
wordList toc() const
Return the table of contents.
Definition dictionary.C:587
entry * set(entry *entryPtr)
Assign a new entry, overwriting any existing entry.
Definition dictionary.C:765
label startLineNumber() const
Return line number of first token in dictionary.
Definition dictionary.C:198
static const dictionary null
An empty dictionary, which is also the parent for all dictionaries.
Definition dictionary.H:487
void operator=(const dictionary &rhs)
Copy assignment.
Definition dictionary.C:886
SHA1Digest digest() const
Return the SHA1 digest of the dictionary contents.
Definition dictionary.C:220
void operator+=(const dictionary &rhs)
Include entries from the given dictionary.
Definition dictionary.C:906
A keyword and a list of tokens is an 'entry'.
Definition entry.H:66
virtual bool isDict() const noexcept
True if this entry is a dictionary.
Definition entry.H:284
virtual const fileName & name() const =0
Return the entry name.
const keyType & keyword() const noexcept
Return keyword.
Definition entry.H:231
virtual const dictionary & dict() const =0
Return dictionary, if entry is a dictionary, otherwise Fatal.
A class for handling file names.
Definition fileName.H:75
static fileName concat(const std::string &s1, const std::string &s2, const char delim='/')
Join two strings with a path separator ('/' by default).
Definition fileName.C:211
A class for handling keywords in dictionaries.
Definition keyType.H:69
option
Enumeration for the data type and search/match modes (bitmask).
Definition keyType.H:80
@ REGEX_RECURSIVE
Definition keyType.H:88
@ REGEX
Regular expression.
Definition keyType.H:83
bool isPattern() const noexcept
The keyType is treated as a pattern, not as literal string.
Definition keyTypeI.H:97
A keyword and a list of tokens comprise a primitiveEntry. A primitiveEntry can be read,...
A class for managing references or pointers (no reference counting).
Definition refPtr.H:54
A class for handling character strings derived from std::string.
Definition string.H:76
A token holds an item read from Istream.
Definition token.H:70
A class for handling words, derived from Foam::string.
Definition word.H:66
#define defineTypeNameAndDebug(Type, DebugSwitch)
Define the typeName and debug information.
Definition className.H:142
volScalarField & p
#define FatalIOErrorInFunction(ios)
Report an error message using Foam::FatalIOError.
Definition error.H:629
OBJstream os(runTime.globalPath()/outputName)
auto & name
surface1 clear()
#define IOWarningInFunction(ios)
Report an IO warning using Foam::Warning.
void set(List< bool > &bools, const labelUList &locations)
Set the listed locations (assign 'true').
Definition BitOps.C:35
int infoSwitch(const char *name, const int deflt=0)
Lookup info switch or add default value.
Definition debug.C:228
Namespace for OpenFOAM.
List< word > wordList
List of word.
Definition fileName.H:60
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition Ostream.H:519
void add(DimensionedField< scalar, GeoMesh > &result, const dimensioned< scalar > &dt1, const DimensionedField< scalar, GeoMesh > &f2)
errorManip< error > abort(error &err)
Definition errorManip.H:139
IOerror FatalIOError
Error stream (stdout output on all processes), with additional 'FOAM FATAL IO ERROR' header text and ...
void rhs(fvMatrix< typename Expr::value_type > &m, const Expr &expression)
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for expressions::valueTypeCode::INVALID.
Definition exprTraits.C:127
List< token > tokenList
List of token, used for dictionary primitive entry (for example).
Definition tokenList.H:32
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition errorManip.H:125
fileName search(const word &file, const fileName &directory)
Recursively search the given directory for the file.
Definition fileName.C:642
constexpr char nl
The newline '\n' character (0x0a).
Definition Ostream.H:50
#define registerInfoSwitch(Name, Type, SwitchVar)
dictionary dict
volScalarField & e