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 | Copyright (C) 2011-2016 OpenFOAM Foundation
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8 License
9  This file is part of OpenFOAM.
10 
11  OpenFOAM is free software: you can redistribute it and/or modify it
12  under the terms of the GNU General Public License as published by
13  the Free Software Foundation, either version 3 of the License, or
14  (at your option) any later version.
15 
16  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
17  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
19  for more details.
20 
21  You should have received a copy of the GNU General Public License
22  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
23 
24 Class
25  Foam::dictionaryEntry
26 
27 Description
28  A keyword and a list of tokens is a 'dictionaryEntry'.
29 
30  An dictionaryEntry can be read, written and printed, and the types and
31  values of its tokens analysed. A dictionaryEntry is a high-level building
32  block for data description. It is a front-end for the token parser.
33  A list of entries can be used as a set of keyword syntax elements,
34  for example.
35 
36 SourceFiles
37  dictionaryEntry.C
38  dictionaryEntryIO.C
39 
40 \*---------------------------------------------------------------------------*/
41 
42 #ifndef dictionaryEntry_H
43 #define dictionaryEntry_H
44 
45 #include "entry.H"
46 #include "dictionary.H"
47 #include "InfoProxy.H"
48 
49 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
50 
51 namespace Foam
52 {
53 
54 // Forward declaration of friend functions and operators
55 
56 class dictionaryEntry;
57 
58 Ostream& operator<<(Ostream&, const dictionaryEntry&);
59 
60 
61 /*---------------------------------------------------------------------------*\
62  Class dictionaryEntry Declaration
63 \*---------------------------------------------------------------------------*/
64 
65 class dictionaryEntry
66 :
67  public entry,
68  public dictionary
69 {
70  // Private Member Functions
71 
72  void readData(Istream&);
73 
74  //- Dissallow bitwise copy
76 
77 
78 public:
79 
80  // Constructors
81 
82  //- Construct from the parent dictionary and Istream
83  dictionaryEntry(const dictionary& parentDict, Istream&);
84 
85  //- Construct from the keyword, parent dictionary and a Istream
87  (
88  const keyType&,
89  const dictionary& parentDict,
90  Istream&
91  );
92 
93  //- Construct from the keyword, parent dictionary and a dictionary
95  (
96  const keyType&,
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&
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 local dictionary name (final part of scoped name)
117  const word dictName() const
118  {
119  return dictionary::dictName();
120  }
121 
122  //- Return the dictionary name (scoped, e.g. dictA::dictB::dictC)
123  const fileName& name() const
124  {
125  return dictionary::name();
126  }
127 
128  //- Return the dictionary name (scoped, e.g. dictA::dictB::dictC)
129  fileName& name()
130  {
131  return dictionary::name();
132  }
133 
134  //- Return line number of first token in dictionary
135  label startLineNumber() const;
136 
137  //- Return line number of last token in dictionary
138  label endLineNumber() const;
139 
140  //- This entry is not a primitive,
141  // calling this function generates a FatalError
142  ITstream& stream() const;
143 
144  //- Return true because this entry is a dictionary
145  bool isDict() const
146  {
147  return true;
148  }
149 
150  //- Return dictionary
151  const dictionary& dict() const;
152 
153  //- Return non-const access to dictionary
154  dictionary& dict();
155 
156  //- Write
157  void write(Ostream&) const;
158 
159  //- Return info proxy.
160  // Used to print token information to a stream
162  {
163  return *this;
164  }
165 
166 
167  // Ostream operator
168 
169  friend Ostream& operator<<(Ostream&, const dictionaryEntry&);
170 };
171 
172 
173 template<>
174 Ostream& operator<<(Ostream&, const InfoProxy<dictionaryEntry>&);
175 
176 
177 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
178 
179 } // End namespace Foam
180 
181 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
182 
183 #endif
184 
185 // ************************************************************************* //
A class for handling keywords in dictionaries.
Definition: keyType.H:64
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
Definition: label.H:59
A class for handling file names.
Definition: fileName.H:69
A list of keyword definitions, which are a keyword followed by any number of values (e...
Definition: dictionary.H:137
An Istream is an abstract base class for all input systems (streams, files, token lists etc)...
Definition: Istream.H:57
ITstream & stream() const
This entry is not a primitive,.
const fileName & name() const
Return the dictionary name (scoped, e.g. dictA::dictB::dictC)
InfoProxy< dictionaryEntry > info() const
Return info proxy.
A keyword and a list of tokens is a &#39;dictionaryEntry&#39;.
autoPtr< dictionary > clone() const
Construct and return clone.
Definition: dictionary.C:340
void write(Ostream &) const
Write.
const word dictName() const
Return the local dictionary name (final part of scoped name)
Definition: dictionary.H:115
label endLineNumber() const
Return line number of last token in dictionary.
const fileName & name() const
Return the dictionary name.
Definition: dictionary.H:103
A class for handling words, derived from string.
Definition: word.H:59
const dictionary & dict() const
Return dictionary.
An Ostream is an abstract base class for all output systems (streams, files, token lists...
Definition: Ostream.H:53
A helper class for outputting values to Ostream.
Definition: InfoProxy.H:45
Ostream & operator<<(Ostream &, const ensightPart &)
bool isDict() const
Return true because this entry is a dictionary.
label startLineNumber() const
Return line number of first token in dictionary.
const word dictName() const
Return the local dictionary name (final part of scoped name)
An auto-pointer similar to the STL auto_ptr but with automatic casting to a reference to the type and...
Definition: PtrList.H:52
friend Ostream & operator<<(Ostream &, const dictionaryEntry &)
Input token stream.
Definition: ITstream.H:49
Namespace for OpenFOAM.
A keyword and a list of tokens is an &#39;entry&#39;.
Definition: entry.H:65