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-2022 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 In can also be used in situations where an individual dictionary entry
44 should be read.
45 \verbatim
46 actions
47 (
48 testing { action new; ... } // An action with a name
49 { action subset; } // Unnamed action
50 );
51 \endverbatim
52 Normal dictionary reading would fail for this type of input since the
53 leading 'testing' keyword would cause the entire content to be considered
54 a single dictionary.
55
56Note
57 No distinction currently made between a missing and an empty dictionary.
58
59SourceFiles
60 namedDictionary.C
61
62\*---------------------------------------------------------------------------*/
63
64#ifndef Foam_namedDictionary_H
65#define Foam_namedDictionary_H
66
67#include "dictionary.H"
68#include "Tuple2.H"
69
70// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
71
72namespace Foam
73{
74
75// Forward Declarations
76class namedDictionary;
77
78Istream& operator>>(Istream&, namedDictionary&);
79Ostream& operator<<(Ostream&, const namedDictionary&);
80
81/*---------------------------------------------------------------------------*\
82 Class namedDictionary Declaration
83\*---------------------------------------------------------------------------*/
86:
87 public Tuple2<keyType, dictionary>
88{
89public:
90
91 // Constructors
92
93 //- Inherit constructors
95
96 //- Default construct
97 namedDictionary() = default;
98
99 //- Construct from Istream
100 explicit namedDictionary(Istream& is);
101
102
103 //- Destructor
104 ~namedDictionary() = default;
105
106
107 // Member Functions
108
109 //- Clear keyword and dictionary
110 void clear();
111
112 //- Empty if both keyword and dictionary are empty
113 bool empty() const noexcept;
114
115 //- Return keyword
116 const keyType& keyword() const noexcept
117 {
118 return first();
119 }
120
121 //- Return non-const access to keyword
123 {
124 return first();
125 }
126
127 //- Read-access to the dictionay
128 const dictionary& dict() const noexcept
129 {
130 return second();
131 }
132
133 //- Write access to the dictionay
135 {
136 return second();
137 }
138
139
140 // IOstream Operators
143 friend Ostream& operator<<(Ostream&, const namedDictionary&);
144};
145
146
147// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
148
149} // End namespace Foam
150
151// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
152
153#endif
154
155// ************************************************************************* //
An Istream is an abstract base class for all input systems (streams, files, token lists etc)....
Definition: Istream.H:64
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:62
A 2-tuple for storing two objects of dissimilar types. The container is similar in purpose to std::pa...
Definition: Tuple2.H:58
const keyType & first() const noexcept
Return first.
Definition: Tuple2.H:118
Tuple2()=default
Default construct.
const dictionary & second() const noexcept
Return second.
Definition: Tuple2.H:130
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:126
A class for handling keywords in dictionaries.
Definition: keyType.H:71
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)
Definition: boundaryPatch.C:83
Istream & operator>>(Istream &, directionInfo &)
const direction noexcept
Definition: Scalar.H:223