![]() |
|
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 Istream 00027 00028 Description 00029 An Istream is an abstract base class for all input systems; 00030 be they streams, files, token lists etc. The basic operations 00031 are construct, close, read token, read primitive and read binary 00032 block. In addition version control and line number counting is 00033 incorporated. Usually one would use the read primitive member 00034 functions, but if one were reading a stream on unknown data 00035 sequence one can read token by token, and then analyse. 00036 00037 \*---------------------------------------------------------------------------*/ 00038 00039 #ifndef Istream_H 00040 #define Istream_H 00041 00042 #include "IOstream.H" 00043 #include "token.H" 00044 00045 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 00046 00047 namespace Foam 00048 { 00049 00050 /*---------------------------------------------------------------------------*\ 00051 Class Istream Declaration 00052 \*---------------------------------------------------------------------------*/ 00053 00054 class Istream 00055 : 00056 public IOstream 00057 { 00058 // Private data 00059 00060 //- Has a token been put back on the stream 00061 bool putBack_; 00062 00063 //- The last token put back on the stream 00064 token putBackToken_; 00065 00066 00067 public: 00068 00069 // Constructors 00070 00071 //- Set stream status 00072 Istream 00073 ( 00074 streamFormat format=ASCII, 00075 versionNumber version=currentVersion, 00076 compressionType compression=UNCOMPRESSED 00077 ) 00078 : 00079 IOstream(format, version, compression), 00080 putBack_(false) 00081 {} 00082 00083 00084 // Destructor 00085 00086 virtual ~Istream() 00087 {} 00088 00089 00090 // Member functions 00091 00092 // Read functions 00093 00094 //- Put back token 00095 void putBack(const token&); 00096 00097 //- Get the put back token 00098 bool getBack(token&); 00099 00100 //- Return next token from stream 00101 virtual Istream& read(token&) = 0; 00102 00103 //- Read a character 00104 virtual Istream& read(char&) = 0; 00105 00106 //- Read a word 00107 virtual Istream& read(word&) = 0; 00108 00109 // Read a string (including enclosing double-quotes) 00110 virtual Istream& read(string&) = 0; 00111 00112 //- Read a label 00113 virtual Istream& read(label&) = 0; 00114 00115 //- Read a floatScalar 00116 virtual Istream& read(floatScalar&) = 0; 00117 00118 //- Read a doubleScalar 00119 virtual Istream& read(doubleScalar&) = 0; 00120 00121 //- Read binary block 00122 virtual Istream& read(char*, std::streamsize) = 0; 00123 00124 //- Rewind and return the stream so that it may be read again 00125 virtual Istream& rewind() = 0; 00126 00127 00128 // Read List punctuation tokens 00129 00130 Istream& readBegin(const char* funcName); 00131 Istream& readEnd(const char* funcName); 00132 Istream& readEndBegin(const char* funcName); 00133 00134 char readBeginList(const char* funcName); 00135 char readEndList(const char* funcName); 00136 00137 00138 // Member operators 00139 00140 //- Return a non-const reference to const Istream 00141 // Needed for read-constructors where the stream argument is temporary: 00142 // e.g. thing thisThing(IFstream("thingFileName")()); 00143 Istream& operator()() const; 00144 }; 00145 00146 00147 // -------------------------------------------------------------------- 00148 // ------ Manipulators (not taking arguments) 00149 // -------------------------------------------------------------------- 00150 00151 typedef Istream& (*IstreamManip)(Istream&); 00152 00153 //- operator>> handling for manipulators without arguments 00154 inline Istream& operator>>(Istream& is, IstreamManip f) 00155 { 00156 return f(is); 00157 } 00158 00159 //- operator>> handling for manipulators without arguments 00160 inline Istream& operator>>(Istream& is, IOstreamManip f) 00161 { 00162 f(is); 00163 return is; 00164 } 00165 00166 00167 00168 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 00169 00170 } // End namespace Foam 00171 00172 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 00173 00174 #ifdef NoRepository 00175 # include "HashTable.C" 00176 #endif 00177 00178 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 00179 00180 #endif 00181 00182 // ************************************************************************* //