OpenFOAM logo
Open Source CFD Toolkit

primitiveEntry.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     primitiveEntry
00027 
00028 Description
00029     A keyword and a list of tokens is a 'primitiveEntry'.
00030     An primitiveEntry can be read, written and printed, and the types and
00031     values of its tokens analysed.  A primitiveEntry 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     primitiveEntry.C
00038     primitiveEntryIO.C
00039 
00040 \*---------------------------------------------------------------------------*/
00041 
00042 #ifndef primitiveEntry_H
00043 #define primitiveEntry_H
00044 
00045 #include "IStringStream.H"
00046 #include "OStringStream.H"
00047 
00048 #include "entry.H"
00049 #include "ITstream.H"
00050 #include "InfoProxy.H"
00051 
00052 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00053 
00054 namespace Foam
00055 {
00056 
00057 class dictionary;
00058 
00059 /*---------------------------------------------------------------------------*\
00060                            Class primitiveEntry Declaration
00061 \*---------------------------------------------------------------------------*/
00062 
00063 class primitiveEntry
00064 :
00065     public entry,
00066     public ITstream
00067 {
00068     // Private member functions
00069 
00070         void readData(Istream&);
00071 
00072 
00073 public:
00074 
00075     // Constructors
00076 
00077         //- Construct from keyword and a Istream
00078         primitiveEntry(const word& keyword, Istream&);
00079 
00080         //- Construct from keyword and a ITstream
00081         primitiveEntry(const word& keyword, const ITstream&);
00082 
00083         //- Construct from keyword and a token
00084         primitiveEntry(const word&, const token&);
00085 
00086         //- Construct from keyword and a tokenList
00087         primitiveEntry(const word&, const tokenList&);
00088 
00089         //- Construct from keyword and a T
00090         template<class T>
00091         primitiveEntry(const word&, const T&);
00092 
00093         autoPtr<entry> clone() const
00094         {
00095             return autoPtr<entry>(new primitiveEntry(*this));
00096         }
00097 
00098 
00099     // Member functions
00100 
00101         //- Return the dictionary name
00102         const fileName& name() const
00103         {
00104             return ITstream::name();
00105         }
00106 
00107         //- Return the dictionary name
00108         fileName& name()
00109         {
00110             return ITstream::name();
00111         }
00112 
00113         //- Return line number of first token in dictionary
00114         label startLineNumber() const;
00115 
00116         //- Return line number of last token in dictionary
00117         label endLineNumber() const;
00118 
00119         //- Return true because this entry is a stream
00120         bool isStream() const
00121         {
00122             return true;
00123         }
00124 
00125         //- Return token stream if this entry is a primitive entry
00126         ITstream& stream() const;
00127 
00128         //- Return token stream if this entry is a primitive entry
00129         const dictionary& dict() const;
00130 
00131         // Write
00132         void write(Ostream&) const;
00133 
00134         //- Return info proxy.
00135         //  Used to print token information to a stream
00136         InfoProxy<primitiveEntry> info() const
00137         {
00138             return *this;
00139         }
00140 };
00141 
00142 
00143 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00144 
00145 } // End namespace Foam
00146 
00147 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00148 
00149 #ifdef NoRepository
00150 #   include "primitiveEntryTemplates.C"
00151 #endif
00152 
00153 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00154 
00155 #endif
00156 
00157 // ************************************************************************* //
For further information go to www.openfoam.org