FreeFOAM The Cross-Platform CFD Toolkit
Hosted by SourceForge:
Get FreeFOAM at SourceForge.net.
            Fast, secure and Free Open Source software downloads

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-2010 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
00013     the Free Software Foundation, either version 3 of the License, or
00014     (at your 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, see <http://www.gnu.org/licenses/>.
00023 
00024 Class
00025     Foam::entry
00026 
00027 Description
00028     A keyword and a list of tokens is an 'entry'.
00029 
00030     An entry can be read, written and printed, and the types and values of
00031     its 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
00033     can 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 <OpenFOAM/keyType.H>
00045 #include <OpenFOAM/IDLList.H>
00046 #include <OpenFOAM/fileName.H>
00047 #include <OpenFOAM/autoPtr.H>
00048 
00049 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00050 
00051 namespace Foam
00052 {
00053 
00054 class ITstream;
00055 class dictionary;
00056 
00057 // Forward declaration of friend functions and operators
00058 
00059 class entry;
00060 Ostream& operator<<(Ostream&, const entry&);
00061 
00062 /*---------------------------------------------------------------------------*\
00063                            Class entry Declaration
00064 \*---------------------------------------------------------------------------*/
00065 
00066 class entry
00067 :
00068     public IDLList<entry>::link
00069 {
00070     // Private data
00071 
00072         //- Keyword of entry
00073         keyType keyword_;
00074 
00075 
00076     // Private Member Functions
00077 
00078         //- Get the next valid keyword otherwise return false
00079         static bool getKeyword(keyType&, Istream&);
00080 
00081 
00082 public:
00083 
00084     // Constructors
00085 
00086         //- Construct from keyword
00087         entry(const keyType&);
00088 
00089         //- Construct as copy
00090         entry(const entry&);
00091 
00092         //- Construct on freestore as copy with reference to the
00093         //  dictionary the copy belongs to
00094         virtual autoPtr<entry> clone
00095         (
00096             const dictionary& parentDict
00097         ) const = 0;
00098 
00099         //- Construct on freestore as copy
00100         //  Note: the parent directory is set to dictionary::null
00101         virtual autoPtr<entry> clone() const;
00102 
00103         //- Construct from Istream and insert into dictionary
00104         static bool New(dictionary& parentDict, Istream&);
00105 
00106         //- Construct on freestore from Istream and return
00107         static autoPtr<entry> New(Istream& is);
00108 
00109 
00110     //- Destructor
00111     virtual ~entry()
00112     {}
00113 
00114 
00115     // Member functions
00116 
00117         //- Return keyword
00118         const keyType& keyword() const
00119         {
00120             return keyword_;
00121         }
00122 
00123         //- Return non-const access to keyword
00124         keyType& keyword()
00125         {
00126             return keyword_;
00127         }
00128 
00129         //- Return the dictionary name
00130         virtual const fileName& name() const = 0;
00131 
00132         //- Return the dictionary name
00133         virtual fileName& name() = 0;
00134 
00135         //- Return line number of first token in dictionary
00136         virtual label startLineNumber() const = 0;
00137 
00138         //- Return line number of last token in dictionary
00139         virtual label endLineNumber() const = 0;
00140 
00141         //- Return true if this entry is a stream
00142         virtual bool isStream() const
00143         {
00144             return false;
00145         }
00146 
00147         //- Return token stream if this entry is a primitive entry
00148         virtual ITstream& stream() const = 0;
00149 
00150         //- Return true if this entry is a dictionary
00151         virtual bool isDict() const
00152         {
00153             return false;
00154         }
00155 
00156         //- Return dictionary if this entry is a dictionary
00157         virtual const dictionary& dict() const = 0;
00158 
00159         //- Return non-const access to dictionary if this entry is a dictionary
00160         virtual dictionary& dict() = 0;
00161 
00162         //- Write
00163         virtual void write(Ostream&) const = 0;
00164 
00165 
00166     // Member operators
00167 
00168         void operator=(const entry&);
00169 
00170         bool operator==(const entry&) const;
00171         bool operator!=(const entry&) const;
00172 
00173 
00174     // Ostream operator
00175 
00176         friend Ostream& operator<<(Ostream&, const entry&);
00177 };
00178 
00179 
00180 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00181 
00182 } // End namespace Foam
00183 
00184 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00185 
00186 #endif
00187 
00188 // ************************ vim: set sw=4 sts=4 et: ************************ //
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines