Loading...
Searching...
No Matches
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-2024 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/>.
26\*---------------------------------------------------------------------------*/
27
28#include "dictionary.H"
29
30// * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * //
37
38inline int Foam::dictionary::reportOptional(const int level) noexcept
39{
40 int old(writeOptionalEntries);
42 return old;
43}
44
45
46// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
49{
50 return name_;
51}
52
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
78inline bool Foam::dictionary::isNullDict() const noexcept
79{
80 return (this == &dictionary::null);
81}
82
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
110inline 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
151(
152 const word& keyword,
153 enum keyType::option matchOpt
154) const
155{
156 return csearch(keyword, matchOpt).streamPtr();
157}
158
159
160// ************************************************************************* //
An input stream of tokens.
Definition ITstream.H:56
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition dictionary.H:133
bool isNullDict() const noexcept
The dictionary is actually dictionary::null (root dictionary).
Definition dictionaryI.H:71
static int reportOptional() noexcept
Return the state of reporting optional (default) entries.
Definition dictionaryI.H:25
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.
const dictionary * findDict(const word &keyword, enum keyType::option matchOpt=keyType::REGEX) const
Find and return a sub-dictionary pointer if present (and it is a dictionary) otherwise return nullptr...
dictionary()
Default construct, a top-level empty dictionary.
Definition dictionary.C:68
static int writeOptionalEntries
Report optional keywords and values if not present in dictionary.
Definition dictionary.H:482
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.
friend class entry
Declare friendship with the entry class for IO.
Definition dictionary.H:338
bool found(const word &keyword, enum keyType::option matchOpt=keyType::REGEX) const
Find an entry (const access) with the given keyword.
const dictionary & parent() const noexcept
Return the parent dictionary.
Definition dictionaryI.H:77
const_searcher csearch(const word &keyword, enum keyType::option matchOpt=keyType::REGEX) const
Search dictionary for given keyword.
ITstream * findStream(const word &keyword, enum keyType::option matchOpt=keyType::REGEX) const
Find and return an entry stream if present (and it is a stream) otherwise return nullptr.
static const dictionary null
An empty dictionary, which is also the parent for all dictionaries.
Definition dictionary.H:487
word dictName() const
The local dictionary name (final part of scoped name).
Definition dictionaryI.H:53
A keyword and a list of tokens is an 'entry'.
Definition entry.H:66
A class for handling file names.
Definition fileName.H:75
option
Enumeration for the data type and search/match modes (bitmask).
Definition keyType.H:80
A class for handling words, derived from Foam::string.
Definition word.H:66
const direction noexcept
Definition scalarImpl.H:265