FreeFOAM The Cross-Platform CFD Toolkit
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) 1991-2010 OpenCFD Ltd.
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 <OpenFOAM/entry.H>
46 #include <OpenFOAM/dictionary.H>
47 #include <OpenFOAM/InfoProxy.H>
48 
49 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
50 
51 namespace Foam
52 {
53 
54 /*---------------------------------------------------------------------------*\
55  Class dictionaryEntry Declaration
56 \*---------------------------------------------------------------------------*/
57 
59 :
60  public entry,
61  public dictionary
62 {
63  // Private member functions
64 
65  void readData(Istream&);
66 
67  //- Dissallow bitwise copy
69 
70 
71 public:
72 
73  // Constructors
74 
75  //- Construct from the parent dictionary and Istream
76  dictionaryEntry(const dictionary& parentDict, Istream&);
77 
78  //- Construct from the keyword, parent dictionary and a Istream
80  (
81  const keyType&,
82  const dictionary& parentDict,
83  Istream&
84  );
85 
86  //- Construct from the keyword, parent dictionary and a dictionary
88  (
89  const keyType&,
90  const dictionary& parentDict,
91  const dictionary& dict
92  );
93 
94  //- Construct as copy for the given parentDict
96  (
97  const dictionary& parentDict,
98  const dictionaryEntry&
99  );
100 
101  autoPtr<entry> clone(const dictionary& parentDict) const
102  {
103  return autoPtr<entry>(new dictionaryEntry(parentDict, *this));
104  }
105 
106 
107  // Member functions
108 
109  //- Return the dictionary name
110  const fileName& name() const
111  {
112  return dictionary::name();
113  }
114 
115  //- Return the dictionary name
117  {
118  return dictionary::name();
119  }
120 
121  //- Return line number of first token in dictionary
122  label startLineNumber() const;
123 
124  //- Return line number of last token in dictionary
125  label endLineNumber() const;
126 
127  //- This entry is not a primitive,
128  // calling this function generates a FatalError
129  ITstream& stream() const;
130 
131  //- Return true because this entry is a dictionary
132  bool isDict() const
133  {
134  return true;
135  }
136 
137  //- Return dictionary
138  const dictionary& dict() const;
139 
140  //- Return non-const access to dictionary
141  dictionary& dict();
142 
143  // Write
144  void write(Ostream&) const;
145 
146  //- Return info proxy.
147  // Used to print token information to a stream
149  {
150  return *this;
151  }
152 
153 
154  // Ostream operator
155 
156  friend Ostream& operator<<(Ostream&, const dictionaryEntry&);
157 };
158 
159 
160 template<>
161 Ostream& operator<<(Ostream&, const InfoProxy<dictionaryEntry>&);
162 
163 
164 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
165 
166 } // End namespace Foam
167 
168 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
169 
170 #endif
171 
172 // ************************ vim: set sw=4 sts=4 et: ************************ //