OpenFOAM logo
The Open Source CFD Toolbox
  Source Guide OpenCFD Solutions Contact OpenFOAM

OSstream.H

Go to the documentation of this file.
00001 /*---------------------------------------------------------------------------*\
00002   =========                 |
00003   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
00004    \\    /   O peration     |
00005     \\  /    A nd           | Copyright (C) 1991-2009 OpenCFD Ltd.
00006      \\/     M anipulation  |
00007 -------------------------------------------------------------------------------
00008 License
00009     This file is part of OpenFOAM.
00010 
00011     OpenFOAM is free software; you can redistribute it and/or modify it
00012     under the terms of the GNU General Public License as published by the
00013     Free Software Foundation; either version 2 of the License, or (at your
00014     option) any later version.
00015 
00016     OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
00017     ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00018     FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
00019     for more details.
00020 
00021     You should have received a copy of the GNU General Public License
00022     along with OpenFOAM; if not, write to the Free Software Foundation,
00023     Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
00024 
00025 Class
00026     Foam::OSstream
00027 
00028 Description
00029     Generic output stream.
00030 
00031 SourceFiles
00032     OSstreamI.H
00033     OSstream.C
00034     chkStream.C
00035 
00036 \*---------------------------------------------------------------------------*/
00037 
00038 #ifndef OSstream_H
00039 #define OSstream_H
00040 
00041 #include "Ostream.H"
00042 #include "fileName.H"
00043 #include <iostream>
00044 
00045 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00046 
00047 namespace Foam
00048 {
00049 
00050 /*---------------------------------------------------------------------------*\
00051                           Class OSstream Declaration
00052 \*---------------------------------------------------------------------------*/
00053 
00054 class OSstream
00055 :
00056     public Ostream
00057 {
00058     // Private data
00059 
00060         fileName name_;
00061         ostream& os_;
00062 
00063 
00064     // Private Member Functions
00065 
00066         //- Disallow default bitwise assignment
00067         void operator=(const OSstream&);
00068 
00069 
00070 protected:
00071 
00072         //- Return the stream reference
00073         ostream& stream()
00074         {
00075             return os_;
00076         }
00077 
00078         //- Return the const stream reference
00079         const ostream& stream() const
00080         {
00081             return os_;
00082         }
00083 
00084 
00085 public:
00086 
00087     // Constructors
00088 
00089         //- Set stream status
00090         OSstream
00091         (
00092             ostream& os,
00093             const string& name,
00094             streamFormat format=ASCII,
00095             versionNumber version=currentVersion,
00096             compressionType compression=UNCOMPRESSED
00097         );
00098 
00099 
00100     // Member functions
00101 
00102         // Enquiry
00103 
00104             //- Return the name of the stream
00105             //  Useful for Fstream to return the filename
00106             virtual const fileName& name() const
00107             {
00108                 return name_;
00109             }
00110 
00111             //- Return non-const access to the name of the stream
00112             //  Useful to alter the stream name
00113             virtual fileName& name()
00114             {
00115                 return name_;
00116             }
00117 
00118             //- Return flags of output stream
00119             virtual ios_base::fmtflags flags() const;
00120 
00121 
00122         // Write functions
00123 
00124             //- Write next token to stream
00125             virtual Ostream& write(const token&);
00126 
00127             //- Write character
00128             virtual Ostream& write(const char);
00129 
00130             //- Write character string
00131             virtual Ostream& write(const char*);
00132 
00133             //- Write word
00134             virtual Ostream& write(const word&);
00135 
00136             //- Write string
00137             //  In the rare case that the string contains a final trailing
00138             //  backslash, it will be dropped to the appearance of an escaped
00139             //  double-quote.
00140             virtual Ostream& write(const string&);
00141 
00142             //- Write std::string surrounded by quotes.
00143             //  Optional write without quotes.
00144             virtual Ostream& writeQuoted
00145             (
00146                 const std::string&,
00147                 const bool quoted=true
00148             );
00149 
00150             //- Write label
00151             virtual Ostream& write(const label);
00152 
00153             //- Write floatScalar
00154             virtual Ostream& write(const floatScalar);
00155 
00156             //- Write doubleScalar
00157             virtual Ostream& write(const doubleScalar);
00158 
00159             //- Write binary block
00160             virtual Ostream& write(const char*, std::streamsize);
00161 
00162             //- Add indentation characters
00163             virtual void indent();
00164 
00165 
00166         // Stream state functions
00167 
00168             //- Set flags of output stream
00169             virtual ios_base::fmtflags flags(const ios_base::fmtflags flags);
00170 
00171             //- Flush stream
00172             virtual void flush();
00173 
00174             //- Add newline and flush stream
00175             virtual void endl();
00176 
00177             //- Get width of output field
00178             virtual int width() const;
00179 
00180             //- Set width of output field (and return old width)
00181             virtual int width(const int);
00182 
00183             //- Get precision of output field
00184             virtual int precision() const;
00185 
00186             //- Set precision of output field (and return old precision)
00187             virtual int precision(const int);
00188 
00189 
00190         // Print
00191 
00192             //- Print description of IOstream to Ostream
00193             virtual void print(Ostream&) const;
00194 };
00195 
00196 
00197 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00198 
00199 } // End namespace Foam
00200 
00201 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00202 
00203 #include "OSstreamI.H"
00204 
00205 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00206 
00207 #endif
00208 
00209 // ************************************************************************* //
Copyright © 2000-2009 OpenCFD Ltd