|
|
|
entry.HGo 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-2009 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 Foam::entry 00027 00028 Description 00029 A keyword and a list of tokens is an 'entry'. 00030 00031 An entry can be read, written and printed, and the types and values of 00032 its tokens analysed. An entry is a high-level building block for data 00033 description. It is a front-end for the token parser. A list of entries 00034 can be used as a set of keyword syntax elements, for example. 00035 00036 SourceFiles 00037 entry.C 00038 entryIO.C 00039 00040 \*---------------------------------------------------------------------------*/ 00041 00042 #ifndef entry_H 00043 #define entry_H 00044 00045 #include "keyType.H" 00046 #include "IDLList.H" 00047 #include "fileName.H" 00048 #include "autoPtr.H" 00049 00050 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 00051 00052 namespace Foam 00053 { 00054 00055 class ITstream; 00056 class dictionary; 00057 00058 // Forward declaration of friend functions and operators 00059 00060 class entry; 00061 Ostream& operator<<(Ostream&, const entry&); 00062 00063 /*---------------------------------------------------------------------------*\ 00064 Class entry Declaration 00065 \*---------------------------------------------------------------------------*/ 00066 00067 class entry 00068 : 00069 public IDLList<entry>::link 00070 { 00071 // Private data 00072 00073 //- Keyword of entry 00074 keyType keyword_; 00075 00076 00077 // Private Member Functions 00078 00079 //- Get the next valid keyword otherwise return false 00080 static bool getKeyword(keyType& keyword, Istream& is); 00081 00082 00083 public: 00084 00085 // Constructors 00086 00087 //- Construct from keyword 00088 entry(const keyType& keyword); 00089 00090 //- Construct as copy 00091 entry(const entry&); 00092 00093 //- Construct on freestore as copy with reference to the 00094 // dictionary the copy belongs to 00095 virtual autoPtr<entry> clone 00096 ( 00097 const dictionary& parentDict 00098 ) const = 0; 00099 00100 //- Construct on freestore as copy 00101 // Note: the parent directory is set to dictionary::null 00102 virtual autoPtr<entry> clone() const; 00103 00104 //- Construct from Istream and insert into dictionary 00105 static bool New(dictionary& parentDict, Istream& is); 00106 00107 //- Construct on freestore from Istream and return 00108 static autoPtr<entry> New(Istream& is); 00109 00110 00111 // Destructor 00112 00113 virtual ~entry() 00114 {} 00115 00116 00117 // Member functions 00118 00119 //- Return keyword 00120 const keyType& keyword() const 00121 { 00122 return keyword_; 00123 } 00124 00125 //- Return non-const access to keyword 00126 keyType& keyword() 00127 { 00128 return keyword_; 00129 } 00130 00131 //- Return the dictionary name 00132 virtual const fileName& name() const = 0; 00133 00134 //- Return the dictionary name 00135 virtual fileName& name() = 0; 00136 00137 //- Return line number of first token in dictionary 00138 virtual label startLineNumber() const = 0; 00139 00140 //- Return line number of last token in dictionary 00141 virtual label endLineNumber() const = 0; 00142 00143 //- Return true if this entry is a stream 00144 virtual bool isStream() const 00145 { 00146 return false; 00147 } 00148 00149 //- Return token stream if this entry is a primitive entry 00150 virtual ITstream& stream() const = 0; 00151 00152 //- Return true if this entry is a dictionary 00153 virtual bool isDict() const 00154 { 00155 return false; 00156 } 00157 00158 //- Return dictionary if this entry is a dictionary 00159 virtual const dictionary& dict() const = 0; 00160 00161 //- Return non-const access to dictionary if this entry is a dictionary 00162 virtual dictionary& dict() = 0; 00163 00164 //- Write 00165 virtual void write(Ostream&) const = 0; 00166 00167 00168 // Member operators 00169 00170 void operator=(const entry&); 00171 00172 bool operator==(const entry&) const; 00173 bool operator!=(const entry&) const; 00174 00175 00176 // Ostream operator 00177 00178 friend Ostream& operator<<(Ostream&, const entry&); 00179 }; 00180 00181 00182 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 00183 00184 } // End namespace Foam 00185 00186 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 00187 00188 #endif 00189 00190 // ************************************************************************* // |