dictionaryI.H
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) 2021 OpenCFD Ltd.
9-------------------------------------------------------------------------------
10License
11 This file is part of OpenFOAM.
12
13 OpenFOAM is free software: you can redistribute it and/or modify it
14 under the terms of the GNU General Public License as published by
15 the Free Software Foundation, either version 3 of the License, or
16 (at your option) any later version.
17
18 OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
19 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
20 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21 for more details.
22
23 You should have received a copy of the GNU General Public License
24 along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
25
26\*---------------------------------------------------------------------------*/
27
28#include "dictionary.H"
29
30// * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * //
31
33{
35}
36
37
38inline int Foam::dictionary::reportOptional(const int level) noexcept
39{
40 int old(writeOptionalEntries);
41 writeOptionalEntries = level;
42 return old;
43}
44
45
46// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
47
49{
50 return name_;
51}
52
53
55{
56 return name_;
57}
58
59
61{
62 word scopedName(name_.name());
63
64 const auto i = scopedName.rfind('.');
65 if (i == std::string::npos)
66 {
67 return scopedName;
68 }
69
70 return scopedName.substr(i+1);
71}
72
73
75{
76 return (this == &dictionary::null);
77}
78
79
81{
82 return parent_;
83}
84
85
87(
88 const word& keyword,
89 enum keyType::option matchOpt
90) const
91{
92 return csearch(keyword, matchOpt).good();
93}
94
95
97(
98 const word& keyword,
99 enum keyType::option matchOpt
100)
101{
102 return search(keyword, matchOpt).ptr();
103}
104
105
107(
108 const word& keyword,
109 enum keyType::option matchOpt
110) const
111{
112 return csearch(keyword, matchOpt).ptr();
113}
114
115
117(
118 const word& keyword,
119 enum keyType::option matchOpt
120) const
121{
122 return csearchScoped(keyword, matchOpt).ptr();
123}
124
125
127(
128 const word& keyword,
129 enum keyType::option matchOpt
130)
131{
132 return search(keyword, matchOpt).dictPtr();
133}
134
135
137(
138 const word& keyword,
139 enum keyType::option matchOpt
140) const
141{
142 return csearch(keyword, matchOpt).dictPtr();
143}
144
145
147(
148 const word& keyword,
149 enum keyType::option matchOpt
150) const
151{
152 return csearch(keyword, matchOpt).isDict();
153}
154
155
156// ************************************************************************* //
bool found
bool isDict() const noexcept
True if found entry is a dictionary.
Definition: dictionary.H:231
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:126
bool isNullDict() const noexcept
The dictionary is actually dictionary::null (root dictionary)
Definition: dictionaryI.H:74
dictionary * findDict(const word &keyword, enum keyType::option matchOpt=keyType::REGEX)
Find and return a sub-dictionary pointer if present.
Definition: dictionaryI.H:127
static int reportOptional() noexcept
Return the state of reporting optional (default) entries.
Definition: dictionaryI.H:32
const fileName & name() const noexcept
The dictionary name.
Definition: dictionaryI.H:48
const entry * findScoped(const word &keyword, enum keyType::option matchOpt=keyType::REGEX) const
Search for a scoped entry (const access) with the given keyword.
Definition: dictionaryI.H:117
static int writeOptionalEntries
Report optional keywords and values if not present in dictionary.
Definition: dictionary.H:391
entry * findEntry(const word &keyword, enum keyType::option matchOpt=keyType::REGEX)
Find for an entry (non-const access) with the given keyword.
Definition: dictionaryI.H:97
const dictionary & parent() const noexcept
Return the parent dictionary.
Definition: dictionaryI.H:80
word dictName() const
The local dictionary name (final part of scoped name)
Definition: dictionaryI.H:60
A keyword and a list of tokens is an 'entry'.
Definition: entry.H:70
A class for handling file names.
Definition: fileName.H:76
option
Enumeration for the data type and search/match modes (bitmask)
Definition: keyType.H:79
A class for handling words, derived from Foam::string.
Definition: word.H:68
const direction noexcept
Definition: Scalar.H:223
fileName search(const word &file, const fileName &directory)
Recursively search the given directory for the file.
Definition: fileName.C:624