1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
7 -------------------------------------------------------------------------------
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
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/>.
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.
39 \*---------------------------------------------------------------------------*/
49 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
57 // Forward declaration of friend functions and operators
60 Ostream& operator<<(Ostream&, const entry&);
62 /*---------------------------------------------------------------------------*\
63 Class entry Declaration
64 \*---------------------------------------------------------------------------*/
68 public IDLList<entry>::link
76 // Private Member Functions
78 //- Get the next valid keyword otherwise return false
79 static bool getKeyword(keyType&, Istream&);
84 static int disableFunctionEntries;
89 //- Construct from keyword
90 entry(const keyType&);
95 //- Construct on freestore as copy with reference to the
96 // dictionary the copy belongs to
97 virtual autoPtr<entry> clone
99 const dictionary& parentDict
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);
121 const keyType& keyword() const
126 //- Return non-const access to keyword
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
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
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;
166 virtual void write(Ostream&) const = 0;
171 void operator=(const entry&);
173 bool operator==(const entry&) const;
174 bool operator!=(const entry&) const;
179 friend Ostream& operator<<(Ostream&, const entry&);
183 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
185 } // End namespace Foam
187 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
191 // ************************************************************************* //