1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 1991-2009 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 \*---------------------------------------------------------------------------*/
50 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
58 // Forward declaration of friend functions and operators
61 Ostream& operator<<(Ostream&, const entry&);
63 /*---------------------------------------------------------------------------*\
64 Class entry Declaration
65 \*---------------------------------------------------------------------------*/
69 public IDLList<entry>::link
77 // Private Member Functions
79 //- Get the next valid keyword otherwise return false
80 static bool getKeyword(keyType& keyword, Istream& is);
87 //- Construct from keyword
88 entry(const keyType& keyword);
93 //- Construct on freestore as copy with reference to the
94 // dictionary the copy belongs to
95 virtual autoPtr<entry> clone
97 const dictionary& parentDict
100 //- Construct on freestore as copy
101 // Note: the parent directory is set to dictionary::null
102 virtual autoPtr<entry> clone() const;
104 //- Construct from Istream and insert into dictionary
105 static bool New(dictionary& parentDict, Istream& is);
107 //- Construct on freestore from Istream and return
108 static autoPtr<entry> New(Istream& is);
120 const keyType& keyword() const
125 //- Return non-const access to keyword
131 //- Return the dictionary name
132 virtual const fileName& name() const = 0;
134 //- Return the dictionary name
135 virtual fileName& name() = 0;
137 //- Return line number of first token in dictionary
138 virtual label startLineNumber() const = 0;
140 //- Return line number of last token in dictionary
141 virtual label endLineNumber() const = 0;
143 //- Return true if this entry is a stream
144 virtual bool isStream() const
149 //- Return token stream if this entry is a primitive entry
150 virtual ITstream& stream() const = 0;
152 //- Return true if this entry is a dictionary
153 virtual bool isDict() const
158 //- Return dictionary if this entry is a dictionary
159 virtual const dictionary& dict() const = 0;
161 //- Return non-const access to dictionary if this entry is a dictionary
162 virtual dictionary& dict() = 0;
165 virtual void write(Ostream&) const = 0;
170 void operator=(const entry&);
172 bool operator==(const entry&) const;
173 bool operator!=(const entry&) const;
178 friend Ostream& operator<<(Ostream&, const entry&);
182 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
184 } // End namespace Foam
186 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
190 // ************************************************************************* //