BUG: UListIO: byteSize overflowing on really big faceLists
[OpenFOAM-2.0.x.git] / src / OpenFOAM / db / dictionary / entry / entry.H
blob00373cb8da4890e63d4df6a12ecf80c6a3bfdc07
1 /*---------------------------------------------------------------------------*\
2   =========                 |
3   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
4    \\    /   O peration     |
5     \\  /    A nd           | Copyright (C) 2011 OpenFOAM Foundation
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
13     the Free Software Foundation, either version 3 of the License, or
14     (at your 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, see <http://www.gnu.org/licenses/>.
24 Class
25     Foam::entry
27 Description
28     A keyword and a list of tokens is an 'entry'.
30     An entry can be read, written and printed, and the types and values of
31     its tokens analysed.  An entry is a high-level building block for data
32     description.  It is a front-end for the token parser. A list of entries
33     can be used as a set of keyword syntax elements, for example.
35 SourceFiles
36     entry.C
37     entryIO.C
39 \*---------------------------------------------------------------------------*/
41 #ifndef entry_H
42 #define entry_H
44 #include "keyType.H"
45 #include "IDLList.H"
46 #include "fileName.H"
47 #include "autoPtr.H"
49 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
51 namespace Foam
54 class ITstream;
55 class dictionary;
57 // Forward declaration of friend functions and operators
59 class entry;
60 Ostream& operator<<(Ostream&, const entry&);
62 /*---------------------------------------------------------------------------*\
63                            Class entry Declaration
64 \*---------------------------------------------------------------------------*/
66 class entry
68     public IDLList<entry>::link
70     // Private data
72         //- Keyword of entry
73         keyType keyword_;
76     // Private Member Functions
78         //- Get the next valid keyword otherwise return false
79         static bool getKeyword(keyType&, Istream&);
82 public:
84     static int disableFunctionEntries;
87     // Constructors
89         //- Construct from keyword
90         entry(const keyType&);
92         //- Construct as copy
93         entry(const entry&);
95         //- Construct on freestore as copy with reference to the
96         //  dictionary the copy belongs to
97         virtual autoPtr<entry> clone
98         (
99             const dictionary& parentDict
100         ) const = 0;
102         //- Construct on freestore as copy
103         //  Note: the parent directory is set to dictionary::null
104         virtual autoPtr<entry> clone() const;
106         //- Construct from Istream and insert into dictionary
107         static bool New(dictionary& parentDict, Istream&);
109         //- Construct on freestore from Istream and return
110         static autoPtr<entry> New(Istream& is);
113     //- Destructor
114     virtual ~entry()
115     {}
118     // Member functions
120         //- Return keyword
121         const keyType& keyword() const
122         {
123             return keyword_;
124         }
126         //- Return non-const access to keyword
127         keyType& keyword()
128         {
129             return keyword_;
130         }
132         //- Return the dictionary name
133         virtual const fileName& name() const = 0;
135         //- Return the dictionary name
136         virtual fileName& name() = 0;
138         //- Return line number of first token in dictionary
139         virtual label startLineNumber() const = 0;
141         //- Return line number of last token in dictionary
142         virtual label endLineNumber() const = 0;
144         //- Return true if this entry is a stream
145         virtual bool isStream() const
146         {
147             return false;
148         }
150         //- Return token stream if this entry is a primitive entry
151         virtual ITstream& stream() const = 0;
153         //- Return true if this entry is a dictionary
154         virtual bool isDict() const
155         {
156             return false;
157         }
159         //- Return dictionary if this entry is a dictionary
160         virtual const dictionary& dict() const = 0;
162         //- Return non-const access to dictionary if this entry is a dictionary
163         virtual dictionary& dict() = 0;
165         //- Write
166         virtual void write(Ostream&) const = 0;
169     // Member operators
171         void operator=(const entry&);
173         bool operator==(const entry&) const;
174         bool operator!=(const entry&) const;
177     // Ostream operator
179         friend Ostream& operator<<(Ostream&, const entry&);
183 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
185 } // End namespace Foam
187 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
189 #endif
191 // ************************************************************************* //