1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 1991-2008 OpenCFD Ltd.
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 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
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
29 A keyword and a list of tokens is an 'entry'.
31 An entry can be read, written and printed, and the types and values of
32 its tokens analysed. An entry is a high-level building block for data
33 description. It is a front-end for the token parser. A list of entries
34 can be used as a set of keyword syntax elements, for example.
40 \*---------------------------------------------------------------------------*/
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(word& keyword, Istream& is);
86 //- Construct from keyword
87 entry(const word& keyword);
92 //- Construct on freestore as copy with reference to the
93 // dictionary the copy belongs to
94 virtual Foam::autoPtr<entry> clone
96 const dictionary& parentDict
99 //- Construct on freestore as copy
100 // Note: the parent directory is set to dictionary::null
101 virtual Foam::autoPtr<entry> clone() const;
103 //- Construct from Istream and insert into dictionary
104 static bool New(dictionary& parentDict, Istream& is);
106 //- Construct on freestore from Istream and return
107 static Foam::autoPtr<entry> New(Istream& is);
119 const word& keyword() const
124 //- Return non-const access to keyword
130 //- Return the dictionary name
131 virtual const fileName& name() const = 0;
133 //- Return the dictionary name
134 virtual fileName& name() = 0;
136 //- Return line number of first token in dictionary
137 virtual label startLineNumber() const = 0;
139 //- Return line number of last token in dictionary
140 virtual label endLineNumber() const = 0;
142 //- Return true if this entry is a stream
143 virtual bool isStream() const
148 //- Return token stream if this entry is a primitive entry
149 virtual ITstream& stream() const = 0;
151 //- Return true if this entry is a dictionary
152 virtual bool isDict() const
157 //- Return dictionary if this entry is a dictionary
158 virtual const dictionary& dict() const = 0;
160 //- Return non-const access to dictionary if this entry is a dictionary
161 virtual dictionary& dict() = 0;
164 virtual void write(Ostream&) const = 0;
169 void operator=(const entry&);
171 bool operator==(const entry&) const;
172 bool operator!=(const entry&) const;
177 friend Ostream& operator<<(Ostream&, const entry&);
181 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
183 } // End namespace Foam
185 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
189 // ************************************************************************* //