![]() |
|
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 ITstream 00027 00028 Description 00029 Input token stream. 00030 00031 SourceFiles 00032 ITread.C 00033 ITprint.C 00034 00035 \*---------------------------------------------------------------------------*/ 00036 00037 #ifndef ITstream_H 00038 #define ITstream_H 00039 00040 #include "Istream.H" 00041 #include "tokenList.H" 00042 00043 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 00044 00045 namespace Foam 00046 { 00047 00048 /*---------------------------------------------------------------------------*\ 00049 Class ITstream Declaration 00050 \*---------------------------------------------------------------------------*/ 00051 00052 class ITstream 00053 : 00054 public Istream, 00055 public tokenList 00056 { 00057 // Private data 00058 00059 //- Name of ITstream 00060 fileName name_; 00061 00062 //- Index of token currently being read 00063 label tokenIndex_; 00064 00065 00066 public: 00067 00068 // Constructors 00069 00070 //- Construct from components 00071 ITstream 00072 ( 00073 const string& name, 00074 const tokenList& tokens, 00075 streamFormat format=ASCII, 00076 versionNumber version=currentVersion 00077 ) 00078 : 00079 Istream(format, version), 00080 tokenList(tokens), 00081 name_(name), 00082 tokenIndex_(0) 00083 { 00084 setOpened(); 00085 setGood(); 00086 } 00087 00088 00089 //- Construct as copy 00090 ITstream(const ITstream& its) 00091 : 00092 Istream(ASCII, currentVersion), 00093 tokenList(its), 00094 name_(its.name_), 00095 tokenIndex_(0) 00096 { 00097 setOpened(); 00098 setGood(); 00099 } 00100 00101 00102 // Member functions 00103 00104 // Inquiry 00105 00106 //- Return the name of the stream 00107 const fileName& name() const 00108 { 00109 return name_; 00110 } 00111 00112 //- Return non-const access to the name of the stream 00113 fileName& name() 00114 { 00115 return name_; 00116 } 00117 00118 //- Return the current token index 00119 label tokenIndex() const 00120 { 00121 return tokenIndex_; 00122 } 00123 00124 //- Return the number of remaining tokens 00125 label nRemainingTokens() const 00126 { 00127 return size() - tokenIndex_; 00128 } 00129 00130 //- Return flags of output stream 00131 ios_base::fmtflags flags() const 00132 { 00133 return ios_base::fmtflags(0); 00134 } 00135 00136 00137 // Read functions 00138 00139 //- Return next token from stream 00140 Istream& read(token&); 00141 00142 //- Read a character 00143 Istream& read(char&); 00144 00145 //- Read a word 00146 Istream& read(word&); 00147 00148 // Read a string (including enclosing double-quotes) 00149 Istream& read(string&); 00150 00151 //- Read a label 00152 Istream& read(label&); 00153 00154 //- Read a floatScalar 00155 Istream& read(floatScalar&); 00156 00157 //- Read a doubleScalar 00158 Istream& read(doubleScalar&); 00159 00160 //- Read binary block 00161 Istream& read(char*, std::streamsize); 00162 00163 //- Rewind and return the stream so that it may be read again 00164 Istream& rewind(); 00165 00166 00167 // Edit 00168 00169 //- Set flags of stream 00170 ios_base::fmtflags flags(const ios_base::fmtflags) 00171 { 00172 return ios_base::fmtflags(0); 00173 } 00174 00175 00176 // Print 00177 00178 //- Print description of IOstream to Ostream 00179 void print(Ostream&) const; 00180 }; 00181 00182 00183 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 00184 00185 } // End namespace Foam 00186 00187 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 00188 00189 #endif 00190 00191 // ************************************************************************* //