OpenFOAM logo
Open Source CFD Toolkit

dictionaryEntry.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     dictionaryEntry
00027 
00028 Description
00029     A keyword and a list of tokens is a 'dictionaryEntry'.
00030     An dictionaryEntry can be read, written and printed, and the types and
00031     values of its tokens analysed.  A dictionaryEntry is a high-level building
00032     block for data description.  It is a front-end for the token parser.
00033     A list of entries can be used as a set of keyword syntax elements,
00034     for example.
00035 
00036 SourceFiles
00037     dictionaryEntry.C
00038     dictionaryEntryIO.C
00039 
00040 \*---------------------------------------------------------------------------*/
00041 
00042 #ifndef dictionaryEntry_H
00043 #define dictionaryEntry_H
00044 
00045 #include "entry.H"
00046 #include "dictionary.H"
00047 #include "InfoProxy.H"
00048 
00049 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00050 
00051 namespace Foam
00052 {
00053 
00054 /*---------------------------------------------------------------------------*\
00055                            Class dictionaryEntry Declaration
00056 \*---------------------------------------------------------------------------*/
00057 
00058 class dictionaryEntry
00059 :
00060     public entry,
00061     public dictionary
00062 {
00063     // Private member functions
00064 
00065         void readData(Istream&);
00066 
00067 
00068 public:
00069 
00070     // Constructors
00071 
00072         //- Construct from Istream
00073         dictionaryEntry(Istream&);
00074 
00075         //- Construct from keyword and a Istream
00076         dictionaryEntry(const word& keyword, Istream&);
00077 
00078         //- Construct from keyword and a dictionary
00079         dictionaryEntry(const word& keyword, const dictionary&);
00080 
00081         autoPtr<entry> clone() const
00082         {
00083             return autoPtr<entry>(new dictionaryEntry(*this));
00084         }
00085 
00086 
00087     // Member functions
00088 
00089         //- Return the dictionary name
00090         const fileName& name() const
00091         {
00092             return dictionary::name();
00093         }
00094 
00095         //- Return the dictionary name
00096         fileName& name()
00097         {
00098             return dictionary::name();
00099         }
00100 
00101         //- Return line number of first token in dictionary
00102         label startLineNumber() const;
00103 
00104         //- Return line number of last token in dictionary
00105         label endLineNumber() const;
00106 
00107         //- Return token stream if this entry is a dictionary entry
00108         ITstream& stream() const;
00109 
00110         //- Return true because this entry is a dictionary
00111         bool isDict() const
00112         {
00113             return true;
00114         }
00115 
00116         //- Return token stream if this entry is a dictionary entry
00117         const dictionary& dict() const;
00118 
00119         // Write
00120         void write(Ostream&) const;
00121 
00122         //- Return info proxy.
00123         //  Used to print token information to a stream
00124         InfoProxy<dictionaryEntry> info() const
00125         {
00126             return *this;
00127         }
00128 
00129 
00130     // Ostream operator
00131 
00132         friend Ostream& operator<<(Ostream&, const dictionaryEntry&);
00133 };
00134 
00135 
00136 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00137 
00138 } // End namespace Foam
00139 
00140 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00141 
00142 #endif
00143 
00144 // ************************************************************************* //
For further information go to www.openfoam.org