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