initial commit for version 1.5.x patch release
[OpenFOAM-1.5.x.git] / src / OpenFOAM / db / IOstreams / Sstreams / OSstream.H
blobcd3a03ec0cb4531299379539835d86fec7cc74c5
1 /*---------------------------------------------------------------------------*\
2   =========                 |
3   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
4    \\    /   O peration     |
5     \\  /    A nd           | Copyright (C) 1991-2008 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::OSstream
28 Description
29     Generic output stream.
31 SourceFiles
32     OSstreamI.H
33     OSwrite.C
34     chkStream.C
36 \*---------------------------------------------------------------------------*/
38 #ifndef OSstream_H
39 #define OSstream_H
41 #include "Ostream.H"
42 #include "fileName.H"
43 #include <iostream>
45 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
47 namespace Foam
50 /*---------------------------------------------------------------------------*\
51                            Class OSstream Declaration
52 \*---------------------------------------------------------------------------*/
54 class OSstream
56     public Ostream
58     // Private data
60         fileName name_;
61         #ifndef __CINT__
62         ostream& os_;
63         #endif
66     // Private Member Functions
68         //- Disallow default bitwise assignment
69         void operator=(const OSstream&);
72 protected:
74         //- Return the stream reference
75         ostream& stream()
76         {
77             return os_;
78         }
80         //- Return the const stream reference
81         const ostream& stream() const
82         {
83             return os_;
84         }
87 public:
89     // Constructors
91         //- Set stream status
92         OSstream
93         (
94             ostream& os,
95             const string& name,
96             streamFormat format=ASCII,
97             versionNumber version=currentVersion,
98             compressionType compression=UNCOMPRESSED
99         );
102     // Member functions
104         // Enquiry
106             //- Return the name of the stream
107             //  Useful for Fstream to return the filename
108             virtual const fileName& name() const
109             {
110                 return name_;
111             }
113             //- Return non-const access to the name of the stream
114             //  Useful to alter the stream name
115             virtual fileName& name()
116             {
117                 return name_;
118             }
120             //- Return flags of output stream
121             virtual ios_base::fmtflags flags() const;
124         // Write functions
126             //- Write next token to stream
127             virtual Ostream& write(const token&);
129             //- Write character
130             virtual Ostream& write(const char);
132             //- Write character string
133             virtual Ostream& write(const char*);
135             //- Write word
136             virtual Ostream& write(const word&);
138             //- Write string
139             virtual Ostream& write(const string&);
141             //- Write label
142             virtual Ostream& write(const label);
144             //- Write floatScalar
145             virtual Ostream& write(const floatScalar);
147             //- Write doubleScalar
148             virtual Ostream& write(const doubleScalar);
150             //- Write binary block
151             virtual Ostream& write(const char*, std::streamsize);
153             //- Add indentation characters
154             virtual void indent();
157         // Stream state functions
159             //- Set flags of output stream
160             virtual ios_base::fmtflags flags(const ios_base::fmtflags flags);
162             //- Flush stream
163             virtual void flush();
165             //- Add '\n' and flush stream
166             virtual void endl();
168             //- Get width of output field
169             virtual int width() const;
171             //- Set width of output field (and return old width)
172             virtual int width(const int w);
174             //- Get precision of output field
175             virtual int precision() const;
177             //- Set precision of output field (and return old precision)
178             virtual int precision(const int p);
181         // Print
183             //- Print description of IOstream to Ostream
184             virtual void print(Ostream&) const;
188 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
190 } // End namespace Foam
192 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
194 #include "OSstreamI.H"
196 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
198 #endif
200 // ************************************************************************* //