ENH: autoLayerDriver: better layering information message
[OpenFOAM-2.0.x.git] / src / OpenFOAM / db / IOstreams / Fstreams / OFstream.H
blob2350e3f394262157b01221fade33e30939ed0ca1
1 /*---------------------------------------------------------------------------*\
2   =========                 |
3   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
4    \\    /   O peration     |
5     \\  /    A nd           | Copyright (C) 2011 OpenFOAM Foundation
6      \\/     M anipulation  |
7 -------------------------------------------------------------------------------
8 License
9     This file is part of OpenFOAM.
11     OpenFOAM is free software: you can redistribute it and/or modify it
12     under the terms of the GNU General Public License as published by
13     the Free Software Foundation, either version 3 of the License, or
14     (at your option) any later version.
16     OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
17     ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18     FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
19     for more details.
21     You should have received a copy of the GNU General Public License
22     along with OpenFOAM.  If not, see <http://www.gnu.org/licenses/>.
24 Class
25     Foam::OFstream
27 Description
28     Output to file stream.
30 SourceFiles
31     OFstream.C
33 \*---------------------------------------------------------------------------*/
35 #ifndef OFstream_H
36 #define OFstream_H
38 #include "OSstream.H"
39 #include "fileName.H"
40 #include "className.H"
42 #include <fstream>
43 using std::ofstream;
45 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
47 namespace Foam
50 class OFstream;
52 /*---------------------------------------------------------------------------*\
53                       Class OFstreamAllocator Declaration
54 \*---------------------------------------------------------------------------*/
56 //- A std::ostream with ability to handle compressed files
57 class OFstreamAllocator
59     friend class OFstream;
61     ostream* ofPtr_;
63     // Constructors
65         //- Construct from pathname
66         OFstreamAllocator
67         (
68             const fileName& pathname,
69             IOstream::compressionType compression=IOstream::UNCOMPRESSED
70         );
72     //- Destructor
73     ~OFstreamAllocator();
78 /*---------------------------------------------------------------------------*\
79                           Class OFstream Declaration
80 \*---------------------------------------------------------------------------*/
82 class OFstream
84     private OFstreamAllocator,
85     public OSstream
87     // Private data
89         fileName pathname_;
92 public:
94     // Declare name of the class and its debug switch
95     ClassName("OFstream");
98     // Constructors
100         //- Construct from pathname
101         OFstream
102         (
103             const fileName& pathname,
104             streamFormat format=ASCII,
105             versionNumber version=currentVersion,
106             compressionType compression=UNCOMPRESSED
107         );
110     //- Destructor
111     ~OFstream();
114     // Member functions
116         // Access
118             //- Return the name of the stream
119             const fileName& name() const
120             {
121                 return pathname_;
122             }
124             //- Return non-const access to the name of the stream
125             fileName& name()
126             {
127                 return pathname_;
128             }
131         // STL stream
133             //- Access to underlying std::ostream
134             virtual ostream& stdStream();
136             //- Const access to underlying std::ostream
137             virtual const ostream& stdStream() const;
140         // Print
142             //- Print description of IOstream to Ostream
143             void print(Ostream&) const;
147 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
149 //- Global predefined null output stream "/dev/null"
150 extern OFstream Snull;
152 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
154 } // End namespace Foam
156 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
158 #endif
160 // ************************************************************************* //