OpenFOAM logo
Open Source CFD Toolkit

entry.H

Go to the documentation of this file.
00001 /*---------------------------------------------------------------------------*\
00002   =========                 |
00003   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
00004    \\    /   O peration     |
00005     \\  /    A nd           | Copyright (C) 1991-2005 OpenCFD Ltd.
00006      \\/     M anipulation  |
00007 -------------------------------------------------------------------------------
00008 License
00009     This file is part of OpenFOAM.
00010 
00011     OpenFOAM is free software; you can redistribute it and/or modify it
00012     under the terms of the GNU General Public License as published by the
00013     Free Software Foundation; either version 2 of the License, or (at your
00014     option) any later version.
00015 
00016     OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
00017     ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00018     FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
00019     for more details.
00020 
00021     You should have received a copy of the GNU General Public License
00022     along with OpenFOAM; if not, write to the Free Software Foundation,
00023     Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
00024 
00025 Class
00026     entry
00027 
00028 Description
00029     A keyword and a list of tokens is an 'entry'.
00030     An entry can be read, written and printed, and the types and values of its
00031     tokens analysed.  An entry is a high-level building block for data
00032     description.  It is a front-end for the token parser. A list of entries can
00033     be used as a set of keyword syntax elements, for example.
00034 
00035 SourceFiles
00036     entry.C
00037     entryIO.C
00038 
00039 \*---------------------------------------------------------------------------*/
00040 
00041 #ifndef entry_H
00042 #define entry_H
00043 
00044 #include "IDLList.H"
00045 #include "fileName.H"
00046 #include "autoPtr.H"
00047 
00048 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00049 
00050 namespace Foam
00051 {
00052 
00053 class ITstream;
00054 class dictionary;
00055 
00056 /*---------------------------------------------------------------------------*\
00057                            Class entry Declaration
00058 \*---------------------------------------------------------------------------*/
00059 
00060 class entry
00061 :
00062     public IDLList<entry>::link
00063 {
00064     // Private data
00065 
00066         //- Keyword of entry
00067         word keyword_;
00068 
00069 
00070 public:
00071 
00072     // Constructors
00073 
00074         //- Construct from keyword
00075         entry(const word& keyword);
00076 
00077         //- Construct as copy
00078         entry(const entry&);
00079 
00080         virtual autoPtr<entry> clone() const = 0;
00081 
00082         //- Construct on freestore from Istream
00083         static autoPtr<entry> New(Istream& is);
00084 
00085 
00086     // Destructor
00087 
00088         virtual ~entry()
00089         {}
00090 
00091 
00092     // Member functions
00093 
00094         //- Return keyword
00095         const word& keyword() const
00096         {
00097             return keyword_;
00098         }
00099 
00100         //- Return the dictionary name
00101         virtual const fileName& name() const = 0;
00102 
00103         //- Return the dictionary name
00104         virtual fileName& name() = 0;
00105 
00106         //- Return line number of first token in dictionary
00107         virtual label startLineNumber() const = 0;
00108 
00109         //- Return line number of last token in dictionary
00110         virtual label endLineNumber() const = 0;
00111 
00112         //- Return true if this entry is a stream
00113         virtual bool isStream() const
00114         {
00115             return false;
00116         }
00117 
00118         //- Return token stream if this entry is a primitive entry
00119         virtual ITstream& stream() const = 0;
00120 
00121         //- Return true if this entry is a dictionary
00122         virtual bool isDict() const
00123         {
00124             return false;
00125         }
00126 
00127         //- Return token stream if this entry is a primitive entry
00128         virtual const dictionary& dict() const = 0;
00129 
00130         //- Write
00131         virtual void write(Ostream&) const = 0;
00132 
00133 
00134     // Member operators
00135 
00136         void operator=(const entry&);
00137 
00138 
00139     // Ostream operator
00140 
00141         friend Ostream& operator<<(Ostream&, const entry&);
00142 };
00143 
00144 
00145 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00146 
00147 } // End namespace Foam
00148 
00149 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00150 
00151 #endif
00152 
00153 // ************************************************************************* //
For further information go to www.openfoam.org