OpenFOAM logo
Open Source CFD Toolkit

IFstream.H

Go 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-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     IFstream
00027 
00028 Description
00029     Input from file stream.
00030 
00031 SourceFiles
00032     IFstream.C
00033 
00034 \*---------------------------------------------------------------------------*/
00035 
00036 #ifndef IFstream_H
00037 #define IFstream_H
00038 
00039 #include "ISstream.H"
00040 #include "fileName.H"
00041 #include "className.H"
00042 
00043 #include <fstream>
00044 using std::ifstream;
00045 
00046 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00047 
00048 namespace Foam
00049 {
00050 
00051 class IFstream;
00052 
00053 /*---------------------------------------------------------------------------*\
00054                        Class IFstreamAllocator Declaration
00055 \*---------------------------------------------------------------------------*/
00056 
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 
00079 /*---------------------------------------------------------------------------*\
00080                            Class IFstream Declaration
00081 \*---------------------------------------------------------------------------*/
00082 
00083 class IFstream
00084 :
00085     private IFstreamAllocator,
00086     public ISstream
00087 {
00088     // Private data
00089 
00090         fileName pathname_;
00091 
00092 public:
00093 
00094     // Declare name of the class and it's debug switch
00095     ClassName("IFstream");
00096 
00097 
00098     // Constructors
00099 
00100         //- Construct from pathname
00101         IFstream
00102         (
00103             const fileName& pathname,
00104             streamFormat format=ASCII,
00105             versionNumber version=currentVersion
00106         );
00107 
00108 
00109     // Destructor
00110 
00111         ~IFstream();
00112 
00113 
00114     // Member functions
00115 
00116         // Access
00117 
00118             //- Return the name of the stream
00119             const fileName& name() const
00120             {
00121                 return pathname_;
00122             }
00123 
00124             //- Return non-const access to the name of the stream
00125             fileName& name()
00126             {
00127                 return pathname_;
00128             }
00129 
00130 
00131         // Print
00132 
00133             //- Print description of IOstream to Ostream
00134             virtual void print(Ostream&) const;
00135 
00136 
00137     // Member operators
00138 
00139         //- Return a non-const reference to const IFstream
00140         //  Needed for read-constructors where the stream argument is temporary:
00141         //  e.g. thing thisThing(IFstream("thingFileName")());
00142         IFstream& operator()() const;
00143 };
00144 
00145 
00146 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00147 
00148 } // End namespace Foam
00149 
00150 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00151 
00152 #endif
00153 
00154 // ************************************************************************* //
For further information go to www.openfoam.org