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 a 'primitiveEntry'.
30 An primitiveEntry can be read, written and printed, and the types and
31 values of its tokens analysed.
33 A primitiveEntry is a high-level building block for data description. It
34 is a front-end for the token parser. A list of entries can be used as a
35 set of keyword syntax elements, for example.
41 \*---------------------------------------------------------------------------*/
43 #ifndef primitiveEntry_H
44 #define primitiveEntry_H
46 #include "IStringStream.H"
47 #include "OStringStream.H"
51 #include "InfoProxy.H"
53 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
60 /*---------------------------------------------------------------------------*\
61 Class primitiveEntry Declaration
62 \*---------------------------------------------------------------------------*/
69 // Private member functions
71 //- Append the given token to this entry
74 const token& currToken,
79 //- Append the given tokens starting at the current tokenIndex
80 void append(const tokenList&);
82 //- Expand the given variable (keyword starts with $)
83 bool expandVariable(const word&, const dictionary&);
85 //- Expand the given function (keyword starts with #)
93 //- Read the complete entry from the given stream
94 void readEntry(const dictionary&, Istream&);
96 //- Insert the given tokens at token posI
97 void insert(const tokenList&, const label posI);
104 //- Construct from keyword and a Istream
105 primitiveEntry(const keyType&, Istream&);
107 //- Construct from keyword, parent dictionary and Istream
108 primitiveEntry(const keyType&, const dictionary& parentDict, Istream&);
110 //- Construct from keyword and a ITstream
111 primitiveEntry(const keyType&, const ITstream&);
113 //- Construct from keyword and a token
114 primitiveEntry(const keyType&, const token&);
116 //- Construct from keyword and a tokenList
117 primitiveEntry(const keyType&, const tokenList&);
119 //- Construct from keyword and a T
121 primitiveEntry(const keyType&, const T&);
123 autoPtr<entry> clone(const dictionary&) const
125 return autoPtr<entry>(new primitiveEntry(*this));
131 //- Return the dictionary name
132 const fileName& name() const
134 return ITstream::name();
137 //- Return the dictionary name
140 return ITstream::name();
143 //- Return line number of first token in dictionary
144 label startLineNumber() const;
146 //- Return line number of last token in dictionary
147 label endLineNumber() const;
149 //- Return true because this entry is a stream
150 bool isStream() const
155 //- Return token stream if this entry is a primitive entry
156 ITstream& stream() const;
158 //- This entry is not a dictionary,
159 // calling this function generates a FatalError
160 const dictionary& dict() const;
162 //- This entry is not a dictionary,
163 // calling this function generates a FatalError
166 //- Read tokens from the given stream
167 bool read(const dictionary&, Istream&);
170 void write(Ostream&) const;
172 //- Return info proxy.
173 // Used to print token information to a stream
174 InfoProxy<primitiveEntry> info() const
182 Ostream& operator<<(Ostream&, const InfoProxy<primitiveEntry>&);
185 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
187 } // End namespace Foam
189 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
192 # include "primitiveEntryTemplates.C"
195 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
199 // ************************************************************************* //