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 | www.openfoam.com
6 \\/ M anipulation |
7-------------------------------------------------------------------------------
8 Copyright (C) 2011-2017 OpenFOAM Foundation
9 Copyright (C) 2017-2021 OpenCFD Ltd.
10-------------------------------------------------------------------------------
11License
12 This file is part of OpenFOAM.
13
14 OpenFOAM is free software: you can redistribute it and/or modify it
15 under the terms of the GNU General Public License as published by
16 the Free Software Foundation, either version 3 of the License, or
17 (at your option) any later version.
18
19 OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
20 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
21 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
22 for more details.
23
24 You should have received a copy of the GNU General Public License
25 along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
26
27Class
28 Foam::OFstream
29
30Description
31 Output to file stream, using an OSstream
32
33SourceFiles
34 OFstream.C
35
36\*---------------------------------------------------------------------------*/
37
38#ifndef OFstream_H
39#define OFstream_H
40
41#include "OSstream.H"
42#include "className.H"
43#include "fstreamPointer.H"
44
45// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
46
47namespace Foam
48{
49
50/*---------------------------------------------------------------------------*\
51 Class OFstream Declaration
52\*---------------------------------------------------------------------------*/
54class OFstream
55:
57 public OSstream
58{
59public:
60
61 //- Declare type-name (with debug switch)
62 ClassName("OFstream");
63
64
65 // Constructors
66
67 //- Construct a null output file stream.
68 // Behaves like \c /dev/null and is named accordingly
69 explicit OFstream(std::nullptr_t);
70
71 //- Construct from pathname
72 explicit OFstream
73 (
74 const fileName& pathname,
75 IOstreamOption streamOpt = IOstreamOption(),
76 const bool append = false
77 );
78
79 //- Construct from pathname, format (version, compression)
81 (
82 const fileName& pathname,
86 const bool append = false
87 )
88 :
89 OFstream(pathname, IOstreamOption(fmt, ver, cmp), append)
90 {}
91
92
93 //- Destructor
94 ~OFstream() = default;
95
96
97 // Member Functions
98
99 //- Read/write access to the name of the stream
100 using OSstream::name;
101
102
103 // STL stream
104
105 //- Access to underlying std::ostream
106 virtual std::ostream& stdStream();
107
108 //- Const access to underlying std::ostream
109 virtual const std::ostream& stdStream() const;
110
111 //- Rewind the stream so that it may be written again.
112 //- Reopens the file (truncation)
113 virtual void rewind();
114
115
116 // Print
117
118 //- Print stream description
119 void print(Ostream& os) const;
120};
121
122
123// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
124
125//- Global predefined null output stream "/dev/null"
126extern OFstream Snull;
127
128// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
129
130} // End namespace Foam
131
132// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
133
134#endif
135
136// ************************************************************************* //
Representation of a major/minor version number.
The IOstreamOption is a simple container for options an IOstream can normally have.
streamFormat
Data format (ascii | binary)
compressionType
Compression treatment (UNCOMPRESSED | COMPRESSED)
@ UNCOMPRESSED
compression = false
static const versionNumber currentVersion
The current version number (2.0)
Output to file stream, using an OSstream.
Definition: OFstream.H:57
virtual std::ostream & stdStream()
Access to underlying std::ostream.
Definition: OFstream.C:102
ClassName("OFstream")
Declare type-name (with debug switch)
void print(Ostream &os) const
Print stream description.
Definition: OFstream.C:163
virtual void rewind()
Definition: OFstream.C:132
OFstream(const fileName &pathname, IOstreamOption::streamFormat fmt, IOstreamOption::versionNumber ver=IOstreamOption::currentVersion, IOstreamOption::compressionType cmp=IOstreamOption::UNCOMPRESSED, const bool append=false)
Construct from pathname, format (version, compression)
Definition: OFstream.H:80
~OFstream()=default
Destructor.
Generic output stream using a standard (STL) stream.
Definition: OSstream.H:57
virtual const fileName & name() const
Get the name of the stream.
Definition: OSstream.H:107
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:62
A class for handling file names.
Definition: fileName.H:76
A wrapped std::ofstream with possible compression handling (ogzstream) that behaves much like a std::...
Macro definitions for declaring ClassName(), NamespaceName(), etc.
#define ClassName(TypeNameString)
Add typeName information from argument TypeNameString to a class.
Definition: className.H:67
OBJstream os(runTime.globalPath()/outputName)
rAUs append(new volScalarField(IOobject::groupName("rAU", phase1.name()), 1.0/(U1Eqn.A()+byDt(max(phase1.residualAlpha() - alpha1, scalar(0)) *rho1))))
Namespace for OpenFOAM.
OFstream Snull
Global predefined null output stream "/dev/null".