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