Home
Downloads
Documentation
Installation
User Guide
man-pages
API Documentation
README
Release Notes
Changes
License
Support
SourceForge Project
Main Page
Related Pages
Namespaces
Classes
Files
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Pages
src
OpenFOAM
db
IOstreams
Fstreams
OFstream.H
Go to the documentation of this file.
1
/*---------------------------------------------------------------------------*\
2
========= |
3
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4
\\ / O peration |
5
\\ / A nd | Copyright (C) 1991-2010 OpenCFD Ltd.
6
\\/ M anipulation |
7
-------------------------------------------------------------------------------
8
License
9
This file is part of OpenFOAM.
10
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.
15
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.
20
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/>.
23
24
Class
25
Foam::OFstream
26
27
Description
28
Output to file stream.
29
30
SourceFiles
31
OFstream.C
32
33
\*---------------------------------------------------------------------------*/
34
35
#ifndef OFstream_H
36
#define OFstream_H
37
38
#include <
OpenFOAM/OSstream.H
>
39
#include <
OpenFOAM/fileName.H
>
40
#include <
OpenFOAM/className.H
>
41
42
#include <fstream>
43
using
std::ofstream;
44
45
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
46
47
namespace
Foam
48
{
49
50
class
OFstream;
51
52
/*---------------------------------------------------------------------------*\
53
Class OFstreamAllocator Declaration
54
\*---------------------------------------------------------------------------*/
55
56
//- A std::ostream with ability to handle compressed files
57
class
OFstreamAllocator
58
{
59
friend
class
OFstream
;
60
61
ostream* ofPtr_;
62
63
// Constructors
64
65
//- Construct from pathname
66
OFstreamAllocator
67
(
68
const
fileName
& pathname,
69
IOstream::compressionType
compression=
IOstream::UNCOMPRESSED
70
);
71
72
// Destructor
73
74
~
OFstreamAllocator
();
75
76
77
public
:
78
79
// Member functions
80
81
//- Access to underlying std::ostream
82
ostream&
stdStream
();
83
};
84
85
86
/*---------------------------------------------------------------------------*\
87
Class OFstream Declaration
88
\*---------------------------------------------------------------------------*/
89
90
class
OFstream
91
:
92
private
OFstreamAllocator
,
93
public
OSstream
94
{
95
// Private data
96
97
fileName
pathname_;
98
99
100
public
:
101
102
// Declare name of the class and its debug switch
103
ClassName
(
"OFstream"
);
104
105
106
// Constructors
107
108
//- Construct from pathname
109
OFstream
110
(
111
const
fileName
& pathname,
112
streamFormat
format
=
ASCII
,
113
versionNumber
version
=
currentVersion
,
114
compressionType
compression
=
UNCOMPRESSED
115
);
116
117
118
// Destructor
119
120
~OFstream
();
121
122
123
// Member functions
124
125
// Access
126
127
//- Return the name of the stream
128
const
fileName
&
name
()
const
129
{
130
return
pathname_;
131
}
132
133
//- Return non-const access to the name of the stream
134
fileName
&
name
()
135
{
136
return
pathname_;
137
}
138
139
140
// Print
141
142
//- Print description of IOstream to Ostream
143
void
print
(
Ostream
&)
const
;
144
};
145
146
147
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
148
// Global predefined null output stream
149
150
extern
OFstream
Snull
;
151
152
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
153
154
}
// End namespace Foam
155
156
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
157
158
#endif
159
160
// ************************ vim: set sw=4 sts=4 et: ************************ //