initial commit for version 1.6.x patch release
[OpenFOAM-1.6.x.git] / src / OpenFOAM / db / IOstreams / Sstreams / OSstream.H
blob5c862afd9311328093b843440feb846e1baf2d09
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::OSstream
28 Description
29     Generic output stream.
31 SourceFiles
32     OSstreamI.H
33     OSstream.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         ostream& os_;
64     // Private Member Functions
66         //- Disallow default bitwise assignment
67         void operator=(const OSstream&);
70 protected:
72         //- Return the stream reference
73         ostream& stream()
74         {
75             return os_;
76         }
78         //- Return the const stream reference
79         const ostream& stream() const
80         {
81             return os_;
82         }
85 public:
87     // Constructors
89         //- Set stream status
90         OSstream
91         (
92             ostream& os,
93             const string& name,
94             streamFormat format=ASCII,
95             versionNumber version=currentVersion,
96             compressionType compression=UNCOMPRESSED
97         );
100     // Member functions
102         // Enquiry
104             //- Return the name of the stream
105             //  Useful for Fstream to return the filename
106             virtual const fileName& name() const
107             {
108                 return name_;
109             }
111             //- Return non-const access to the name of the stream
112             //  Useful to alter the stream name
113             virtual fileName& name()
114             {
115                 return name_;
116             }
118             //- Return flags of output stream
119             virtual ios_base::fmtflags flags() const;
122         // Write functions
124             //- Write next token to stream
125             virtual Ostream& write(const token&);
127             //- Write character
128             virtual Ostream& write(const char);
130             //- Write character string
131             virtual Ostream& write(const char*);
133             //- Write word
134             virtual Ostream& write(const word&);
136             //- Write string
137             //  In the rare case that the string contains a final trailing
138             //  backslash, it will be dropped to the appearance of an escaped
139             //  double-quote.
140             virtual Ostream& write(const string&);
142             //- Write std::string surrounded by quotes.
143             //  Optional write without quotes.
144             virtual Ostream& writeQuoted
145             (
146                 const std::string&,
147                 const bool quoted=true
148             );
150             //- Write label
151             virtual Ostream& write(const label);
153             //- Write floatScalar
154             virtual Ostream& write(const floatScalar);
156             //- Write doubleScalar
157             virtual Ostream& write(const doubleScalar);
159             //- Write binary block
160             virtual Ostream& write(const char*, std::streamsize);
162             //- Add indentation characters
163             virtual void indent();
166         // Stream state functions
168             //- Set flags of output stream
169             virtual ios_base::fmtflags flags(const ios_base::fmtflags flags);
171             //- Flush stream
172             virtual void flush();
174             //- Add newline and flush stream
175             virtual void endl();
177             //- Get width of output field
178             virtual int width() const;
180             //- Set width of output field (and return old width)
181             virtual int width(const int);
183             //- Get precision of output field
184             virtual int precision() const;
186             //- Set precision of output field (and return old precision)
187             virtual int precision(const int);
190         // Print
192             //- Print description of IOstream to Ostream
193             virtual void print(Ostream&) const;
197 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
199 } // End namespace Foam
201 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
203 #include "OSstreamI.H"
205 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
207 #endif
209 // ************************************************************************* //