![]() |
|
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 ISstream 00027 00028 Description 00029 Generic input stream. 00030 00031 SourceFiles 00032 ISstreamI.H 00033 ISread.C 00034 ISreadToken.C 00035 00036 \*---------------------------------------------------------------------------*/ 00037 00038 #ifndef ISstream_H 00039 #define ISstream_H 00040 00041 #include "Istream.H" 00042 00043 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 00044 00045 namespace Foam 00046 { 00047 00048 /*---------------------------------------------------------------------------*\ 00049 Class ISstream Declaration 00050 \*---------------------------------------------------------------------------*/ 00051 00052 class ISstream 00053 : 00054 public Istream 00055 { 00056 // Private data 00057 00058 fileName name_; 00059 istream& is_; 00060 00061 00062 // Private member functions 00063 00064 char nextValid(); 00065 00066 00067 protected: 00068 00069 // Protected member functions 00070 00071 //- Return the stream reference 00072 istream& stream() 00073 { 00074 return is_; 00075 } 00076 00077 //- Return the const stream reference 00078 const istream& stream() const 00079 { 00080 return is_; 00081 } 00082 00083 00084 public: 00085 00086 // Constructors 00087 00088 //- Construct as wrapper around istream 00089 ISstream 00090 ( 00091 istream& is, 00092 const string& name, 00093 streamFormat format=ASCII, 00094 versionNumber version=currentVersion, 00095 compressionType compression=UNCOMPRESSED 00096 ) 00097 : 00098 Istream(format, version, compression), 00099 name_(name), 00100 is_(is) 00101 { 00102 if (is_.good()) 00103 { 00104 setOpened(); 00105 setGood(); 00106 } 00107 else 00108 { 00109 setState(is_.rdstate()); 00110 } 00111 } 00112 00113 00114 // Destructor 00115 00116 virtual ~ISstream() 00117 {} 00118 00119 00120 // Member functions 00121 00122 // Inquiry 00123 00124 //- Return the name of the stream 00125 // Useful for Fstream to return the filename 00126 virtual const fileName& name() const 00127 { 00128 return name_; 00129 } 00130 00131 //- Return non-const access to the name of the stream 00132 // Useful to alter the stream name 00133 virtual fileName& name() 00134 { 00135 return name_; 00136 } 00137 00138 //- Return flags of output stream 00139 virtual ios_base::fmtflags flags() const; 00140 00141 00142 // Read functions 00143 00144 //- Raw, low-level get character function. 00145 inline ISstream& get(char&); 00146 00147 //- Raw, low-level putback character function. 00148 inline ISstream& putback(const char&); 00149 00150 //- Return next token from stream 00151 virtual Istream& read(token&); 00152 00153 //- Read a character 00154 virtual Istream& read(char&); 00155 00156 //- Read a word 00157 virtual Istream& read(word&); 00158 00159 // Read a string (including enclosing double-quotes) 00160 virtual Istream& read(string&); 00161 00162 //- Read a label 00163 virtual Istream& read(label&); 00164 00165 //- Read a floatScalar 00166 virtual Istream& read(floatScalar&); 00167 00168 //- Read a doubleScalar 00169 virtual Istream& read(doubleScalar&); 00170 00171 //- Read binary block 00172 virtual Istream& read(char*, std::streamsize); 00173 00174 //- Rewind and return the stream so that it may be read again 00175 virtual Istream& rewind(); 00176 00177 00178 // Stream state functions 00179 00180 //- Set flags of output stream 00181 virtual ios_base::fmtflags flags(const ios_base::fmtflags flags); 00182 00183 00184 // Print 00185 00186 //- Print description of IOstream to Ostream 00187 virtual void print(Ostream&) const; 00188 }; 00189 00190 00191 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 00192 00193 } // End namespace Foam 00194 00195 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 00196 00197 #include "ISstreamI.H" 00198 00199 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 00200 00201 #endif 00202 00203 // ************************************************************************* //