masterOFstream.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) 2017 OpenFOAM Foundation
9 -------------------------------------------------------------------------------
10 License
11  This file is part of OpenFOAM.
12 
13  OpenFOAM is free software: you can redistribute it and/or modify it
14  under the terms of the GNU General Public License as published by
15  the Free Software Foundation, either version 3 of the License, or
16  (at your option) any later version.
17 
18  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
19  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
20  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21  for more details.
22 
23  You should have received a copy of the GNU General Public License
24  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
25 
26 Class
27  Foam::masterOFstream
28 
29 Description
30  Master-only drop-in replacement for OFstream.
31 
32 SourceFiles
33  masterOFstream.C
34 
35 \*---------------------------------------------------------------------------*/
36 
37 #ifndef masterOFstream_H
38 #define masterOFstream_H
39 
40 #include "StringStream.H"
41 
42 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
43 
44 namespace Foam
45 {
46 
47 /*---------------------------------------------------------------------------*\
48  Class masterOFstream Declaration
49 \*---------------------------------------------------------------------------*/
50 
51 class masterOFstream
52 :
53  public OStringStream
54 {
55  // Private data
56 
57  const fileName pathName_;
58 
59  const IOstream::compressionType compression_;
60 
61  const bool append_;
62 
63  //- Should file be written
64  const bool valid_;
65 
66 
67  // Private Member Functions
68 
69  //- Open file with checking
70  void checkWrite(const fileName& fName, const string& str);
71 
72 
73 public:
74 
75  // Constructors
76 
77  //- Construct and set stream status
79  (
80  const fileName& pathname,
84  const bool append = false,
85  const bool valid = true
86  );
87 
88 
89  //- Destructor
91 };
92 
93 
94 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
95 
96 } // End namespace Foam
97 
98 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
99 
100 #endif
101 
102 // ************************************************************************* //
Foam::IOstreamOption::UNCOMPRESSED
compression = false
Definition: IOstreamOption.H:73
Foam::masterOFstream::masterOFstream
masterOFstream(const fileName &pathname, streamFormat format=ASCII, versionNumber version=currentVersion, compressionType compression=UNCOMPRESSED, const bool append=false, const bool valid=true)
Construct and set stream status.
Definition: masterOFstream.C:73
Foam::fileName
A class for handling file names.
Definition: fileName.H:69
Foam::IOstreamOption::format
streamFormat format() const noexcept
Get the current stream format.
Definition: IOstreamOption.H:273
Foam::IOstreamOption::currentVersion
static const versionNumber currentVersion
The current version number.
Definition: IOstreamOption.H:193
StringStream.H
Input/output from string buffers.
Foam::masterOFstream::~masterOFstream
~masterOFstream()
Destructor.
Definition: masterOFstream.C:92
Foam::IOstreamOption::versionNumber
Representation of a major/minor version number.
Definition: IOstreamOption.H:79
Foam::IOstreamOption::version
versionNumber version() const noexcept
Get the stream version.
Definition: IOstreamOption.H:321
Foam::IOstreamOption::streamFormat
streamFormat
Data format (ascii | binary)
Definition: IOstreamOption.H:64
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Foam::Detail::StringStreamAllocator< std::ostringstream >::str
Foam::string str() const
Get the string - as Foam::string rather than std::string.
Definition: StringStream.H:92
Foam::IOstreamOption::ASCII
"ascii"
Definition: IOstreamOption.H:66
Foam::OStringStream
Output to string buffer, using a OSstream.
Definition: StringStream.H:189
Foam::IOstreamOption::compressionType
compressionType
Compression treatment (UNCOMPRESSED | COMPRESSED)
Definition: IOstreamOption.H:71
append
rAUs append(new volScalarField(IOobject::groupName("rAU", phase1.name()), 1.0/(U1Eqn.A()+byDt(max(phase1.residualAlpha() - alpha1, scalar(0)) *rho1))))
Foam::IOstreamOption::compression
compressionType compression() const noexcept
Get the stream compression.
Definition: IOstreamOption.H:297
Foam::masterOFstream
Master-only drop-in replacement for OFstream.
Definition: masterOFstream.H:50