initial commit for version 1.6.x patch release
[OpenFOAM-1.6.x.git] / src / OpenFOAM / db / IOstreams / Sstreams / prefixOSstream.H
blob10ae981ca7522fb6d7dda6b1b3e27eb98a9e9f8d
1 /*---------------------------------------------------------------------------*\
2   =========                 |
3   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
4    \\    /   O peration     |
5     \\  /    A nd           | Copyright (C) 1991-2009 OpenCFD Ltd.
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::prefixOSstream
28 Description
29     Version of OSstream which prints a prefix on each line.
31     This is useful for running in parallel as it allows the processor number
32     to be automatically prepended to each message line.
34 SourceFiles
35     prefixOSstream.C
37 \*---------------------------------------------------------------------------*/
39 #ifndef prefixOSstream_H
40 #define prefixOSstream_H
42 #include "OSstream.H"
44 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
46 namespace Foam
49 /*---------------------------------------------------------------------------*\
50                            Class prefixOSstream Declaration
51 \*---------------------------------------------------------------------------*/
53 class prefixOSstream
55     public OSstream
57     // Private data
59         bool printPrefix_;
60         string prefix_;
63     // Private member functions
65         inline void checkWritePrefix();
68 public:
70     // Constructors
72         //- Set stream status
73         prefixOSstream
74         (
75             ostream& os,
76             const string& name,
77             streamFormat format=ASCII,
78             versionNumber version=currentVersion,
79             compressionType compression=UNCOMPRESSED
80         );
83     // Member functions
85         // Enquiry
87             //- Return the prefix of the stream
88             const string& prefix() const
89             {
90                 return prefix_;
91             }
93             //- Return non-const access to the prefix of the stream
94             string& prefix()
95             {
96                 return prefix_;
97             }
100         // Write functions
102             //- Write next token to stream
103             virtual Ostream& write(const token&);
105             //- Write character
106             virtual Ostream& write(const char);
108             //- Write character string
109             virtual Ostream& write(const char*);
111             //- Write word
112             virtual Ostream& write(const word&);
114             //- Write string
115             virtual Ostream& write(const string&);
117             //- Write std::string surrounded by quotes.
118             //  Optional write without quotes.
119             virtual Ostream& writeQuoted
120             (
121                 const std::string&,
122                 const bool quoted=true
123             );
125             //- Write label
126             virtual Ostream& write(const label);
128             //- Write floatScalar
129             virtual Ostream& write(const floatScalar);
131             //- Write doubleScalar
132             virtual Ostream& write(const doubleScalar);
134             //- Write binary block
135             virtual Ostream& write(const char*, std::streamsize);
137             //- Add indentation characters
138             virtual void indent();
141         // Print
143             //- Print description of IOstream to Ostream
144             virtual void print(Ostream&) const;
148 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
150 } // End namespace Foam
152 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
154 #endif
156 // ************************************************************************* //