00001 /*---------------------------------------------------------------------------*\ 00002 ========= | 00003 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox 00004 \\ / O peration | 00005 \\ / A nd | Copyright (C) 1991-2010 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 00013 the Free Software Foundation, either version 3 of the License, or 00014 (at your 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, see <http://www.gnu.org/licenses/>. 00023 00024 Class 00025 Foam::OSstream 00026 00027 Description 00028 Generic output stream. 00029 00030 SourceFiles 00031 OSstreamI.H 00032 OSstream.C 00033 chkStream.C 00034 00035 \*---------------------------------------------------------------------------*/ 00036 00037 #ifndef OSstream_H 00038 #define OSstream_H 00039 00040 #include <OpenFOAM/Ostream.H> 00041 #include <OpenFOAM/fileName.H> 00042 #include <iostream> 00043 00044 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 00045 00046 namespace Foam 00047 { 00048 00049 /*---------------------------------------------------------------------------*\ 00050 Class OSstream Declaration 00051 \*---------------------------------------------------------------------------*/ 00052 00053 class OSstream 00054 : 00055 public Ostream 00056 { 00057 // Private data 00058 00059 fileName name_; 00060 ostream& os_; 00061 00062 00063 // Private Member Functions 00064 00065 //- Disallow default bitwise assignment 00066 void operator=(const OSstream&); 00067 00068 00069 protected: 00070 00071 //- Return the stream reference 00072 ostream& stream() 00073 { 00074 return os_; 00075 } 00076 00077 //- Return the const stream reference 00078 const ostream& stream() const 00079 { 00080 return os_; 00081 } 00082 00083 00084 public: 00085 00086 // Constructors 00087 00088 //- Set stream status 00089 OSstream 00090 ( 00091 ostream& os, 00092 const string& name, 00093 streamFormat format=ASCII, 00094 versionNumber version=currentVersion, 00095 compressionType compression=UNCOMPRESSED 00096 ); 00097 00098 00099 // Member functions 00100 00101 // Enquiry 00102 00103 //- Return the name of the stream 00104 // Useful for Fstream to return the filename 00105 virtual const fileName& name() const 00106 { 00107 return name_; 00108 } 00109 00110 //- Return non-const access to the name of the stream 00111 // Useful to alter the stream name 00112 virtual fileName& name() 00113 { 00114 return name_; 00115 } 00116 00117 //- Return flags of output stream 00118 virtual ios_base::fmtflags flags() const; 00119 00120 00121 // Write functions 00122 00123 //- Write next token to stream 00124 virtual Ostream& write(const token&); 00125 00126 //- Write character 00127 virtual Ostream& write(const char); 00128 00129 //- Write character string 00130 virtual Ostream& write(const char*); 00131 00132 //- Write word 00133 virtual Ostream& write(const word&); 00134 00135 //- Write string 00136 // In the rare case that the string contains a final trailing 00137 // backslash, it will be dropped to the appearance of an escaped 00138 // double-quote. 00139 virtual Ostream& write(const string&); 00140 00141 //- Write std::string surrounded by quotes. 00142 // Optional write without quotes. 00143 virtual Ostream& writeQuoted 00144 ( 00145 const std::string&, 00146 const bool quoted=true 00147 ); 00148 00149 //- Write label 00150 virtual Ostream& write(const label); 00151 00152 //- Write floatScalar 00153 virtual Ostream& write(const floatScalar); 00154 00155 //- Write doubleScalar 00156 virtual Ostream& write(const doubleScalar); 00157 00158 //- Write binary block 00159 virtual Ostream& write(const char*, std::streamsize); 00160 00161 //- Add indentation characters 00162 virtual void indent(); 00163 00164 00165 // Stream state functions 00166 00167 //- Set flags of output stream 00168 virtual ios_base::fmtflags flags(const ios_base::fmtflags flags); 00169 00170 //- Flush stream 00171 virtual void flush(); 00172 00173 //- Add newline and flush stream 00174 virtual void endl(); 00175 00176 //- Get width of output field 00177 virtual int width() const; 00178 00179 //- Set width of output field (and return old width) 00180 virtual int width(const int); 00181 00182 //- Get precision of output field 00183 virtual int precision() const; 00184 00185 //- Set precision of output field (and return old precision) 00186 virtual int precision(const int); 00187 00188 00189 // Print 00190 00191 //- Print description of IOstream to Ostream 00192 virtual void print(Ostream&) const; 00193 }; 00194 00195 00196 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 00197 00198 } // End namespace Foam 00199 00200 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 00201 00202 #include <OpenFOAM/OSstreamI.H> 00203 00204 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 00205 00206 #endif 00207 00208 // ************************ vim: set sw=4 sts=4 et: ************************ //