fixed writing out entries in advective bc
[OpenFOAM-1.6-ext.git] / src / OpenFOAM / db / IOstreams / Fstreams / OFstream.H
blob0138f52eb2679d817521710637f3cd8d1754f546
1 /*---------------------------------------------------------------------------*\
2   =========                 |
3   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
4    \\    /   O peration     |
5     \\  /    A nd           | Copyright held by original author
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 the
13     Free Software Foundation; either version 2 of the License, or (at your
14     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, write to the Free Software Foundation,
23     Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
25 Class
26     Foam::OFstream
28 Description
29     Output to file stream.
31 SourceFiles
32     OFstream.C
34 \*---------------------------------------------------------------------------*/
36 #ifndef OFstream_H
37 #define OFstream_H
39 #include "OSstream.H"
40 #include "fileName.H"
41 #include "className.H"
43 #include <fstream>
44 using std::ofstream;
46 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
48 namespace Foam
51 class OFstream;
53 /*---------------------------------------------------------------------------*\
54                        Class OFstreamAllocator Declaration
55 \*---------------------------------------------------------------------------*/
57 //- A std::ostream with ability to handle compressed files
58 class OFstreamAllocator
60     friend class OFstream;
62     ostream* ofPtr_;
64     // Constructors
66         //- Construct from pathname
67         OFstreamAllocator
68         (
69             const fileName& pathname,
70             ios_base::openmode mode,
71             IOstream::compressionType compression = IOstream::UNCOMPRESSED
73         );
75     // Destructor
77         ~OFstreamAllocator();
80 public:
82     // Member functions
84         //- Access to underlying std::ostream
85         ostream& stdStream();
89 /*---------------------------------------------------------------------------*\
90                            Class OFstream Declaration
91 \*---------------------------------------------------------------------------*/
93 class OFstream
95     private OFstreamAllocator,
96     public OSstream
98     // Private data
100         fileName pathname_;
103 public:
105     // Declare name of the class and its debug switch
106     ClassName("OFstream");
109     // Constructors
111         //- Construct from pathname
112         OFstream
113         (
114             const fileName& pathname,
115             ios_base::openmode mode = ios_base::out|ios_base::trunc,
116             streamFormat format=ASCII,
117             versionNumber version=currentVersion,
118             compressionType compression=UNCOMPRESSED
119         );
122     // Destructor
124         ~OFstream();
127     // Member functions
129         // Access
131             //- Return the name of the stream
132             const fileName& name() const
133             {
134                 return pathname_;
135             }
137             //- Return non-const access to the name of the stream
138             fileName& name()
139             {
140                 return pathname_;
141             }
144         // Print
146             //- Print description of IOstream to Ostream
147             void print(Ostream&) const;
151 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
152 // Global predefined null output stream
154 extern OFstream Snull;
156 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
158 } // End namespace Foam
160 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
162 #endif
164 // ************************************************************************* //