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

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-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::dictionaryEntry
00026 
00027 Description
00028     A keyword and a list of tokens is a 'dictionaryEntry'.
00029 
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 <OpenFOAM/entry.H>
00046 #include <OpenFOAM/dictionary.H>
00047 #include <OpenFOAM/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         //- Dissallow bitwise copy
00068         dictionaryEntry(const dictionary&);
00069 
00070 
00071 public:
00072 
00073     // Constructors
00074 
00075         //- Construct from the parent dictionary and Istream
00076         dictionaryEntry(const dictionary& parentDict, Istream&);
00077 
00078         //- Construct from the keyword, parent dictionary and a Istream
00079         dictionaryEntry
00080         (
00081             const keyType&,
00082             const dictionary& parentDict,
00083             Istream&
00084         );
00085 
00086         //- Construct from the keyword, parent dictionary and a dictionary
00087         dictionaryEntry
00088         (
00089             const keyType&,
00090             const dictionary& parentDict,
00091             const dictionary& dict
00092         );
00093 
00094         //- Construct as copy for the given parentDict
00095         dictionaryEntry
00096         (
00097             const dictionary& parentDict,
00098             const dictionaryEntry&
00099         );
00100 
00101         autoPtr<entry> clone(const dictionary& parentDict) const
00102         {
00103             return autoPtr<entry>(new dictionaryEntry(parentDict, *this));
00104         }
00105 
00106 
00107     // Member functions
00108 
00109         //- Return the dictionary name
00110         const fileName& name() const
00111         {
00112             return dictionary::name();
00113         }
00114 
00115         //- Return the dictionary name
00116         fileName& name()
00117         {
00118             return dictionary::name();
00119         }
00120 
00121         //- Return line number of first token in dictionary
00122         label startLineNumber() const;
00123 
00124         //- Return line number of last token in dictionary
00125         label endLineNumber() const;
00126 
00127         //- This entry is not a primitive,
00128         //  calling this function generates a FatalError
00129         ITstream& stream() const;
00130 
00131         //- Return true because this entry is a dictionary
00132         bool isDict() const
00133         {
00134             return true;
00135         }
00136 
00137         //- Return dictionary
00138         const dictionary& dict() const;
00139 
00140         //- Return non-const access to dictionary
00141         dictionary& dict();
00142 
00143         // Write
00144         void write(Ostream&) const;
00145 
00146         //- Return info proxy.
00147         //  Used to print token information to a stream
00148         InfoProxy<dictionaryEntry> info() const
00149         {
00150             return *this;
00151         }
00152 
00153 
00154     // Ostream operator
00155 
00156         friend Ostream& operator<<(Ostream&, const dictionaryEntry&);
00157 };
00158 
00159 
00160 template<>
00161 Ostream& operator<<(Ostream&, const InfoProxy<dictionaryEntry>&);
00162 
00163 
00164 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00165 
00166 } // End namespace Foam
00167 
00168 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00169 
00170 #endif
00171 
00172 // ************************ vim: set sw=4 sts=4 et: ************************ //
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines