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 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 the scoped dictionary name (eg, dictA.dictB.dictC)
123  virtual fileName& name()
124  {
125  return dictionary::name();
126  }
127 
128  //- Return line number of first token in dictionary
129  virtual label startLineNumber() const;
130 
131  //- Return line number of last token in dictionary
132  virtual label endLineNumber() const;
133 
134  //- This entry is not a primitive,
135  // calling this function generates a FatalError
136  virtual ITstream& stream() const;
137 
138 
139  //- Return pointer to this dictionary
140  virtual const dictionary* dictPtr() const;
141 
142  //- Return non-const pointer to this dictionary
143  virtual dictionary* dictPtr();
144 
145  //- Return dictionary
146  virtual const dictionary& dict() const;
147 
148  //- Return non-const access to dictionary
149  virtual dictionary& dict();
150 
151 
152  //- Write
153  virtual void write(Ostream& os) const;
154 
155  //- Return info proxy.
156  // Used to print token information to a stream
158  {
159  return *this;
160  }
161 
162 
163  // Ostream operator
164 
165  friend Ostream& operator<<(Ostream& os, const dictionaryEntry& e);
166 };
167 
168 
169 template<>
170 Ostream& operator<<(Ostream& os, const InfoProxy<dictionaryEntry>& ip);
171 
172 
173 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
174 
175 } // End namespace Foam
176 
177 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
178 
179 #endif
180 
181 // ************************************************************************* //
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:69
Foam::dictionaryEntry::operator<<
friend Ostream & operator<<(Ostream &os, const dictionaryEntry &e)
InfoProxy.H
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:60
Foam::dictionaryEntry::write
virtual void write(Ostream &os) const
Write.
Definition: dictionaryEntryIO.C:63
Foam::dictionaryEntry::dictPtr
virtual const dictionary * dictPtr() const
Return pointer to this dictionary.
Definition: dictionaryEntry.C:90
Foam::dictionaryEntry::stream
virtual ITstream & stream() const
This entry is not a primitive,.
Definition: dictionaryEntry.C:80
Foam::dictionary::name
const fileName & name() const
The dictionary name.
Definition: dictionary.H:446
Foam::dictionaryEntry::info
InfoProxy< dictionaryEntry > info() const
Return info proxy.
Definition: dictionaryEntry.H:156
Foam::ITstream
An input stream of tokens.
Definition: ITstream.H:55
Foam::Istream
An Istream is an abstract base class for all input systems (streams, files, token lists etc)....
Definition: Istream.H:61
Foam::dictionary
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:121
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::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:178
dictionary.H
Foam::dictionaryEntry::name
virtual fileName & name()
Return the scoped dictionary name (eg, dictA.dictB.dictC)
Definition: dictionaryEntry.H:122
Foam::dictionaryEntry::dict
virtual const dictionary & dict() const
Return dictionary.
Definition: dictionaryEntry.C:102
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