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-2023 OpenCFD Ltd.
9 -------------------------------------------------------------------------------
10 License
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 {
34  return writeOptionalEntries;
35 }
36 
37 
38 inline 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  // With other (non-slash) separator. Eg, with '.'
63  // word scopedName(name_.name());
64  //
65  // const auto i = scopedName.rfind('.');
66  // if (i == std::string::npos)
67  // {
68  // return scopedName;
69  // }
70  //
71  // return scopedName.substr(i+1);
72 
73  // With '/' separator, this is just fileName::name()
74  return name_.name();
75 }
76 
77 
78 inline bool Foam::dictionary::isNullDict() const noexcept
79 {
80  return (this == &dictionary::null);
81 }
82 
83 
85 {
86  return parent_;
87 }
88 
89 
91 (
92  const word& keyword,
93  enum keyType::option matchOpt
94 ) const
95 {
96  return csearch(keyword, matchOpt).ptr();
97 }
98 
99 
101 (
102  const word& keyword,
103  enum keyType::option matchOpt
104 )
105 {
106  return const_cast<entry*>(csearch(keyword, matchOpt).ptr());
107 }
108 
109 
110 inline bool Foam::dictionary::found
111 (
112  const word& keyword,
113  enum keyType::option matchOpt
114 ) const
115 {
116  return static_cast<bool>(findEntry(keyword, matchOpt));
117 }
118 
119 
121 (
122  const word& keyword,
123  enum keyType::option matchOpt
124 ) const
125 {
126  return csearchScoped(keyword, matchOpt).ptr();
127 }
128 
129 
131 (
132  const word& keyword,
133  enum keyType::option matchOpt
134 ) const
135 {
136  return csearch(keyword, matchOpt).dictPtr();
137 }
138 
139 
141 (
142  const word& keyword,
143  enum keyType::option matchOpt
144 )
145 {
146  return const_cast<dictionary*>(csearch(keyword, matchOpt).dictPtr());
147 }
148 
149 
150 inline bool Foam::dictionary::isDict
151 (
152  const word& keyword,
153  enum keyType::option matchOpt
154 ) const
155 {
156  return static_cast<bool>(findDict(keyword, matchOpt));
157 }
158 
159 
160 // ************************************************************************* //
word dictName() const
The local dictionary name (final part of scoped name)
Definition: dictionaryI.H:53
static int reportOptional() noexcept
Return the state of reporting optional (default) entries.
Definition: dictionaryI.H:25
A class for handling file names.
Definition: fileName.H:72
A list of keyword definitions, which are a keyword followed by a number of values (eg...
Definition: dictionary.H:129
const entry * findEntry(const dictionary &dict, const label val)
Linear search for labelled entry, nullptr if not found.
const fileName & name() const noexcept
The dictionary name.
Definition: dictionaryI.H:41
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:114
bool found(const word &keyword, enum keyType::option matchOpt=keyType::REGEX) const
Find an entry (const access) with the given keyword.
Definition: dictionaryI.H:104
const dictionary & parent() const noexcept
Return the parent dictionary.
Definition: dictionaryI.H:77
A class for handling words, derived from Foam::string.
Definition: word.H:63
static const dictionary null
An empty dictionary, which is also the parent for all dictionaries.
Definition: dictionary.H:474
const direction noexcept
Definition: Scalar.H:258
static int writeOptionalEntries
Report optional keywords and values if not present in dictionary.
Definition: dictionary.H:469
bool isDict(const word &keyword, enum keyType::option matchOpt=keyType::REGEX) const
Find a sub-dictionary.
Definition: dictionaryI.H:144
option
Enumeration for the data type and search/match modes (bitmask)
Definition: keyType.H:79
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
bool isNullDict() const noexcept
The dictionary is actually dictionary::null (root dictionary)
Definition: dictionaryI.H:71
A keyword and a list of tokens is an &#39;entry&#39;.
Definition: entry.H:63
const dictionary * findDict(const word &keyword, enum keyType::option matchOpt=keyType::REGEX) const
Find and return a sub-dictionary pointer if present (and a sub-dictionary) otherwise return nullptr...
Definition: dictionaryI.H:124