dictionaryEntry.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) 2011-2016 OpenFOAM Foundation
9 Copyright (C) 2017-2021 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::dictionaryEntry
29
30Description
31 A keyword and a list of tokens is a 'dictionaryEntry'.
32
33 An dictionaryEntry can be read, written and printed, and the types and
34 values of its tokens analysed. A dictionaryEntry is a high-level building
35 block for data description. It is a front-end for the token parser.
36 A list of entries can be used as a set of keyword syntax elements,
37 for example.
38
39SourceFiles
40 dictionaryEntry.C
41 dictionaryEntryIO.C
42
43\*---------------------------------------------------------------------------*/
44
45#ifndef dictionaryEntry_H
46#define dictionaryEntry_H
47
48#include "entry.H"
49#include "dictionary.H"
50#include "InfoProxy.H"
51
52// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
53
54namespace Foam
55{
56
57// Forward declarations
58class dictionaryEntry;
59Ostream& operator<<(Ostream& os, const dictionaryEntry& e);
60
61
62/*---------------------------------------------------------------------------*\
63 Class dictionaryEntry Declaration
64\*---------------------------------------------------------------------------*/
67:
68 public entry,
69 public dictionary
70{
71 // Private Member Functions
72
73 //- No copy construct
74 dictionaryEntry(const dictionaryEntry&) = delete;
75
76
77public:
78
79 // Constructors
80
81 //- Construct from the parent dictionary and Istream.
82 // The keyword is extracted from the stream
83 dictionaryEntry(const dictionary& parentDict, Istream& is);
84
85 //- Construct from the keyword, parent dictionary and a Istream
87 (
88 const keyType& key,
89 const dictionary& parentDict,
90 Istream& is
91 );
92
93 //- Construct from the keyword, parent dictionary and a dictionary
95 (
96 const keyType& key,
97 const dictionary& parentDict,
98 const dictionary& dict
99 );
100
101 //- Construct as copy for the given parent dictionary
103 (
104 const dictionary& parentDict,
105 const dictionaryEntry& dictEnt
106 );
108 autoPtr<entry> clone(const dictionary& parentDict) const
109 {
110 return autoPtr<entry>(new dictionaryEntry(parentDict, *this));
111 }
112
113
114 // Member functions
115
116 //- Return the scoped dictionary name (eg, dictA.dictB.dictC)
117 virtual const fileName& name() const
118 {
119 return dictionary::name();
120 }
121
122 //- Return scoped dictionary name for modification
123 virtual fileName& name()
124 {
125 return dictionary::name();
126 }
127
128 //- Return scoped dictionary name relative to the current case
129 virtual fileName relativeName() const
130 {
132 }
133
134 //- Return line number of first token in dictionary
135 virtual label startLineNumber() const;
136
137 //- Return line number of last token in dictionary
138 virtual label endLineNumber() const;
139
140 //- This entry is not a primitive,
141 //- calling this function generates a FatalError
142 virtual ITstream& stream() const;
143
144
145 //- Return pointer to this dictionary
146 virtual const dictionary* dictPtr() const noexcept;
147
148 //- Return non-const pointer to this dictionary
149 virtual dictionary* dictPtr() noexcept;
150
151 //- Return dictionary (ie, this)
152 virtual const dictionary& dict() const noexcept;
153
154 //- Return non-const access to dictionary
155 virtual dictionary& dict() noexcept;
156
157
158 //- Write
159 virtual void write(Ostream& os) const;
160
161 //- Return info proxy.
162 // Used to print token information to a stream
164 {
165 return *this;
166 }
167
168
169 // Ostream Operator
171 friend Ostream& operator<<(Ostream& os, const dictionaryEntry& e);
172};
173
174
175template<>
177
178
179// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
180
181} // End namespace Foam
182
183// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
184
185#endif
186
187// ************************************************************************* //
An input stream of tokens.
Definition: ITstream.H:56
A helper class for outputting values to Ostream.
Definition: InfoProxy.H:52
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
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
Definition: autoPtr.H:66
A keyword and a list of tokens is a 'dictionaryEntry'.
virtual fileName & name()
Return scoped dictionary name for modification.
autoPtr< entry > clone(const dictionary &parentDict) const
Construct on freestore as copy with reference to the.
InfoProxy< dictionaryEntry > info() const
Return info proxy.
virtual fileName relativeName() const
Return scoped dictionary name relative to the current case.
virtual const fileName & name() const
Return the scoped dictionary name (eg, dictA.dictB.dictC)
virtual const dictionary & dict() const noexcept
Return dictionary (ie, this)
friend Ostream & operator<<(Ostream &os, const dictionaryEntry &e)
virtual const dictionary * dictPtr() const noexcept
Return pointer to this dictionary.
virtual label endLineNumber() const
Return line number of last token in dictionary.
virtual ITstream & stream() const
virtual label startLineNumber() const
Return line number of first token in dictionary.
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:126
const fileName & name() const noexcept
The dictionary name.
Definition: dictionaryI.H:48
autoPtr< dictionary > clone() const
Construct and return clone.
Definition: dictionary.C:172
A keyword and a list of tokens is an 'entry'.
Definition: entry.H:70
A class for handling file names.
Definition: fileName.H:76
A class for handling keywords in dictionaries.
Definition: keyType.H:71
OBJstream os(runTime.globalPath()/outputName)
Namespace for OpenFOAM.
Ostream & operator<<(Ostream &, const boundaryPatch &p)
Write boundaryPatch as dictionary entries (without surrounding braces)
Definition: boundaryPatch.C:83
const direction noexcept
Definition: Scalar.H:223
runTime write()
volScalarField & e
Definition: createFields.H:11