initial commit for version 1.5.x patch release
[OpenFOAM-1.5.x.git] / src / OpenFOAM / db / dictionary / dictionaryEntry / dictionaryEntry.H
blob2812c1b0bb47efcf73d4b08feaaf3d07bb0c4091
1 /*---------------------------------------------------------------------------*\
2   =========                 |
3   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
4    \\    /   O peration     |
5     \\  /    A nd           | Copyright (C) 1991-2008 OpenCFD Ltd.
6      \\/     M anipulation  |
7 -------------------------------------------------------------------------------
8 License
9     This file is part of OpenFOAM.
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 the
13     Free Software Foundation; either version 2 of the License, or (at your
14     option) any later version.
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.
21     You should have received a copy of the GNU General Public License
22     along with OpenFOAM; if not, write to the Free Software Foundation,
23     Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
25 Class
26     Foam::dictionaryEntry
28 Description
29     A keyword and a list of tokens is a 'dictionaryEntry'.
31     An dictionaryEntry can be read, written and printed, and the types and
32     values of its tokens analysed.  A dictionaryEntry is a high-level building
33     block for data description.  It is a front-end for the token parser.
34     A list of entries can be used as a set of keyword syntax elements,
35     for example.
37 SourceFiles
38     dictionaryEntry.C
39     dictionaryEntryIO.C
41 \*---------------------------------------------------------------------------*/
43 #ifndef dictionaryEntry_H
44 #define dictionaryEntry_H
46 #include "entry.H"
47 #include "dictionary.H"
48 #include "InfoProxy.H"
50 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
52 namespace Foam
55 /*---------------------------------------------------------------------------*\
56                            Class dictionaryEntry Declaration
57 \*---------------------------------------------------------------------------*/
59 class dictionaryEntry
61     public entry,
62     public dictionary
64     // Private member functions
66         void readData(Istream&);
68         //- Dissallow bitwise copy
69         dictionaryEntry(const dictionary&);
72 public:
74     // Constructors
76         //- Construct from the parent dictionary and Istream
77         dictionaryEntry(const dictionary& parentDict, Istream& is);
79         //- Construct from the keyword, parent dictionary and a Istream
80         dictionaryEntry
81         (
82             const word& keyword,
83             const dictionary& parentDict,
84             Istream& is
85         );
87         //- Construct from the keyword, parent dictionary and a dictionary
88         dictionaryEntry
89         (
90             const word& keyword,
91             const dictionary& parentDict,
92             const dictionary& dict
93         );
95         //- Construct as copy for the given parentDict
96         dictionaryEntry
97         (
98             const dictionary& parentDict,
99             const dictionaryEntry& dictEnt
100         );
102         autoPtr<entry> clone(const dictionary& parentDict) const
103         {
104             return autoPtr<entry>(new dictionaryEntry(parentDict, *this));
105         }
108     // Member functions
110         //- Return the dictionary name
111         const fileName& name() const
112         {
113             return dictionary::name();
114         }
116         //- Return the dictionary name
117         fileName& name()
118         {
119             return dictionary::name();
120         }
122         //- Return line number of first token in dictionary
123         label startLineNumber() const;
125         //- Return line number of last token in dictionary
126         label endLineNumber() const;
128         //- This entry is not a primitive,
129         //  calling this function generates a FatalError
130         ITstream& stream() const;
132         //- Return true because this entry is a dictionary
133         bool isDict() const
134         {
135             return true;
136         }
138         //- Return dictionary
139         const dictionary& dict() const;
141         //- Return non-const access to dictionary
142         dictionary& dict();
144         // Write
145         void write(Ostream&) const;
147         //- Return info proxy.
148         //  Used to print token information to a stream
149         InfoProxy<dictionaryEntry> info() const
150         {
151             return *this;
152         }
155     // Ostream operator
157         friend Ostream& operator<<(Ostream&, const dictionaryEntry&);
161 #if defined (__GNUC__)
162 template<>
163 #endif
164 Ostream& operator<<(Ostream& os, const InfoProxy<dictionaryEntry>& ip);
167 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
169 } // End namespace Foam
171 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
173 #endif
175 // ************************************************************************* //