00001 /*---------------------------------------------------------------------------*\ 00002 ========= | 00003 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox 00004 \\ / O peration | 00005 \\ / A nd | Copyright (C) 1991-2010 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 00013 the Free Software Foundation, either version 3 of the License, or 00014 (at your 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, see <http://www.gnu.org/licenses/>. 00023 00024 Class 00025 Foam::IFstream 00026 00027 Description 00028 Input from file stream. 00029 00030 SourceFiles 00031 IFstream.C 00032 00033 \*---------------------------------------------------------------------------*/ 00034 00035 #ifndef IFstream_H 00036 #define IFstream_H 00037 00038 #include <OpenFOAM/ISstream.H> 00039 #include <OpenFOAM/fileName.H> 00040 #include <OpenFOAM/className.H> 00041 00042 #include <fstream> 00043 using std::ifstream; 00044 00045 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 00046 00047 namespace Foam 00048 { 00049 00050 class IFstream; 00051 00052 /*---------------------------------------------------------------------------*\ 00053 Class IFstreamAllocator Declaration 00054 \*---------------------------------------------------------------------------*/ 00055 00056 //- A std::istream with ability to handle compressed files 00057 class IFstreamAllocator 00058 { 00059 friend class IFstream; 00060 00061 // Private data 00062 00063 istream* ifPtr_; 00064 IOstream::compressionType compression_; 00065 00066 00067 // Constructors 00068 00069 //- Construct from pathname 00070 IFstreamAllocator(const fileName& pathname); 00071 00072 00073 // Destructor 00074 00075 ~IFstreamAllocator(); 00076 00077 00078 public: 00079 00080 // Member functions 00081 00082 //- Access to underlying std::istream (for e.g. lexer) 00083 istream& stdStream(); 00084 }; 00085 00086 00087 /*---------------------------------------------------------------------------*\ 00088 Class IFstream Declaration 00089 \*---------------------------------------------------------------------------*/ 00090 00091 class IFstream 00092 : 00093 public IFstreamAllocator, 00094 public ISstream 00095 { 00096 // Private data 00097 00098 fileName pathname_; 00099 00100 public: 00101 00102 // Declare name of the class and its debug switch 00103 ClassName("IFstream"); 00104 00105 00106 // Constructors 00107 00108 //- Construct from pathname 00109 IFstream 00110 ( 00111 const fileName& pathname, 00112 streamFormat format=ASCII, 00113 versionNumber version=currentVersion 00114 ); 00115 00116 00117 // Destructor 00118 00119 ~IFstream(); 00120 00121 00122 // Member functions 00123 00124 // Access 00125 00126 //- Return the name of the stream 00127 const fileName& name() const 00128 { 00129 return pathname_; 00130 } 00131 00132 //- Return non-const access to the name of the stream 00133 fileName& name() 00134 { 00135 return pathname_; 00136 } 00137 00138 // Print 00139 00140 //- Print description of IOstream to Ostream 00141 virtual void print(Ostream&) const; 00142 00143 00144 // Member operators 00145 00146 //- Return a non-const reference to const IFstream 00147 // Needed for read-constructors where the stream argument is temporary: 00148 // e.g. thing thisThing(IFstream("thingFileName")()); 00149 IFstream& operator()() const; 00150 }; 00151 00152 00153 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 00154 00155 } // End namespace Foam 00156 00157 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 00158 00159 #endif 00160 00161 // ************************ vim: set sw=4 sts=4 et: ************************ //