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 -------------------------------------------------------------------------------
11 License
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 
27 Class
28  Foam::dictionaryEntry
29 
30 Description
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 
39 SourceFiles
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 
54 namespace Foam
55 {
56 
57 // Forward declarations
58 class dictionaryEntry;
59 Ostream& operator<<(Ostream& os, const dictionaryEntry& e);
60 
61 
62 /*---------------------------------------------------------------------------*\
63  Class dictionaryEntry Declaration
64 \*---------------------------------------------------------------------------*/
65 
66 class dictionaryEntry
67 :
68  public entry,
69  public dictionary
70 {
71  // Private Member Functions
72 
73  //- No copy construct
74  dictionaryEntry(const dictionaryEntry&) = delete;
75 
76 
77 public:
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  );
107 
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  {
131  return dictionary::relativeName();
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
170 
171  friend Ostream& operator<<(Ostream& os, const dictionaryEntry& e);
172 };
173 
174 
175 template<>
176 Ostream& operator<<(Ostream& os, const InfoProxy<dictionaryEntry>& ip);
177 
178 
179 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
180 
181 } // End namespace Foam
182 
183 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
184 
185 #endif
186 
187 // ************************************************************************* //
Foam::entry
A keyword and a list of tokens is an 'entry'.
Definition: entry.H:67
Foam::dictionaryEntry
A keyword and a list of tokens is a 'dictionaryEntry'.
Definition: dictionaryEntry.H:65
Foam::dictionaryEntry::clone
autoPtr< entry > clone(const dictionary &parentDict) const
Construct on freestore as copy with reference to the.
Definition: dictionaryEntry.H:107
Foam::dictionaryEntry::name
virtual const fileName & name() const
Return the scoped dictionary name (eg, dictA.dictB.dictC)
Definition: dictionaryEntry.H:116
Foam::InfoProxy
A helper class for outputting values to Ostream.
Definition: InfoProxy.H:47
Foam::fileName
A class for handling file names.
Definition: fileName.H:73
Foam::dictionaryEntry::operator<<
friend Ostream & operator<<(Ostream &os, const dictionaryEntry &e)
InfoProxy.H
Foam::dictionaryEntry::dict
virtual const dictionary & dict() const noexcept
Return dictionary (ie, this)
Definition: dictionaryEntry.C:102
Foam::glTF::key
auto key(const Type &t) -> typename std::enable_if< std::is_enum< Type >::value, typename std::underlying_type< Type >::type >::type
Definition: foamGltfBase.H:108
Foam::dictionary::name
const fileName & name() const noexcept
The dictionary name.
Definition: dictionaryI.H:48
entry.H
Foam::operator<<
Ostream & operator<<(Ostream &, const boundaryPatch &p)
Write boundaryPatch as dictionary entries (without surrounding braces)
Definition: boundaryPatch.C:83
Foam::keyType
A class for handling keywords in dictionaries.
Definition: keyType.H:68
Foam::dictionaryEntry::write
virtual void write(Ostream &os) const
Write.
Definition: dictionaryEntryIO.C:63
Foam::dictionaryEntry::stream
virtual ITstream & stream() const
Definition: dictionaryEntry.C:80
Foam::dictionaryEntry::info
InfoProxy< dictionaryEntry > info() const
Return info proxy.
Definition: dictionaryEntry.H:162
Foam::ITstream
An input stream of tokens.
Definition: ITstream.H:52
Foam::Istream
An Istream is an abstract base class for all input systems (streams, files, token lists etc)....
Definition: Istream.H:61
Foam::dictionary::relativeName
fileName relativeName(const bool caseTag=false) const
The dictionary name relative to the case.
Definition: dictionary.C:186
Foam::dictionary
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:123
os
OBJstream os(runTime.globalPath()/outputName)
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Foam::dictionaryEntry::endLineNumber
virtual label endLineNumber() const
Return line number of last token in dictionary.
Definition: dictionaryEntry.C:69
Foam::autoPtr
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
Definition: HashPtrTable.H:53
Foam::dictionaryEntry::dictPtr
virtual const dictionary * dictPtr() const noexcept
Return pointer to this dictionary.
Definition: dictionaryEntry.C:90
Foam::constant::electromagnetic::e
const dimensionedScalar e
Elementary charge.
Definition: createFields.H:11
Foam::dictionary::clone
autoPtr< dictionary > clone() const
Construct and return clone.
Definition: dictionary.C:172
dictionary.H
Foam::dictionaryEntry::name
virtual fileName & name()
Return scoped dictionary name for modification.
Definition: dictionaryEntry.H:122
Foam::dictionaryEntry::relativeName
virtual fileName relativeName() const
Return scoped dictionary name relative to the current case.
Definition: dictionaryEntry.H:128
Foam::Ostream
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:56
Foam::dictionaryEntry::startLineNumber
virtual label startLineNumber() const
Return line number of first token in dictionary.
Definition: dictionaryEntry.C:58