Loading...
Searching...
No Matches
namedDictionary.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) 2020 OpenFOAM Foundation
9 Copyright (C) 2021-2023 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
27Class
28 Foam::namedDictionary
29
30Description
31 A tuple of keyType and dictionary, which can be used when reading
32 named or unnamed dictionary entries or simply a name.
33
34 For example,
35 \verbatim
36 fields
37 (
38 U
39 T { relax false; }
40 );
41 \endverbatim
42
43 The namedDictionary can also be used in situations where an individual
44 dictionary entry should be read. The keyword() and dict() methods
45 correspond to Foam::entry naming conventions.
46 \verbatim
47 actions
48 (
49 testing { action new; ... } // An action with a name
50 { action subset; } // Unnamed action
51 );
52 \endverbatim
53 Normal dictionary reading would fail for this type of input since the
54 leading 'testing' keyword would cause the entire content to be considered
55 a single dictionary.
56
57Note
58 No distinction currently made between a missing and an empty dictionary.
59
60SourceFiles
61 namedDictionary.C
62
63\*---------------------------------------------------------------------------*/
64
65#ifndef Foam_namedDictionary_H
66#define Foam_namedDictionary_H
67
68#include "dictionary.H"
69#include "Tuple2.H"
70
71// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
72
73namespace Foam
74{
75
76// Forward Declarations
77class namedDictionary;
78
82/*---------------------------------------------------------------------------*\
83 Class namedDictionary Declaration
84\*---------------------------------------------------------------------------*/
85
87:
88 public Tuple2<keyType, dictionary>
89{
90public:
91
92 // Constructors
93
94 //- Inherit constructors
96
97 //- Default construct
98 namedDictionary() = default;
99
100 //- Construct from Istream
101 explicit namedDictionary(Istream& is);
102
103
104 //- Destructor
105 ~namedDictionary() = default;
106
107
108 // Member Functions
109
110 //- Clear keyword and dictionary
111 void clear();
112
113 //- Empty if both keyword and dictionary are empty
114 bool empty() const noexcept;
115
116 //- Return keyword
117 const keyType& keyword() const noexcept { return first(); }
118
119 //- Return non-const access to keyword
120 keyType& keyword() noexcept { return first(); }
121
122 //- Read-access to the dictionay
123 const dictionary& dict() const noexcept { return second(); }
124
125 //- Write access to the dictionay
127
128
129 // IOstream Operators
130
132 friend Ostream& operator<<(Ostream&, const namedDictionary&);
133};
134
135
136// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
137
138} // End namespace Foam
139
140// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
142#endif
143
144// ************************************************************************* //
An Istream is an abstract base class for all input systems (streams, files, token lists etc)....
Definition Istream.H:60
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition Ostream.H:59
const keyType & first() const noexcept
Definition Tuple2.H:132
const dictionary & second() const noexcept
Definition Tuple2.H:142
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition dictionary.H:133
A class for handling keywords in dictionaries.
Definition keyType.H:69
A tuple of keyType and dictionary, which can be used when reading named or unnamed dictionary entries...
friend Ostream & operator<<(Ostream &, const namedDictionary &)
dictionary & dict() noexcept
Write access to the dictionay.
friend Istream & operator>>(Istream &, namedDictionary &)
bool empty() const noexcept
Empty if both keyword and dictionary are empty.
~namedDictionary()=default
Destructor.
keyType & keyword() noexcept
Return non-const access to keyword.
namedDictionary()=default
Default construct.
const keyType & keyword() const noexcept
Return keyword.
void clear()
Clear keyword and dictionary.
const dictionary & dict() const noexcept
Read-access to the dictionay.
Namespace for OpenFOAM.
Ostream & operator<<(Ostream &, const boundaryPatch &p)
Write boundaryPatch as dictionary entries (without surrounding braces).
Istream & operator>>(Istream &, directionInfo &)
const direction noexcept
Definition scalarImpl.H:265