|
|
|
prefixOSstream.HGo 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::prefixOSstream 00027 00028 Description 00029 Version of OSstream which prints a prefix on each line. 00030 00031 This is useful for running in parallel as it allows the processor number 00032 to be automatically prepended to each message line. 00033 00034 SourceFiles 00035 prefixOSstream.C 00036 00037 \*---------------------------------------------------------------------------*/ 00038 00039 #ifndef prefixOSstream_H 00040 #define prefixOSstream_H 00041 00042 #include "OSstream.H" 00043 00044 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 00045 00046 namespace Foam 00047 { 00048 00049 /*---------------------------------------------------------------------------*\ 00050 Class prefixOSstream Declaration 00051 \*---------------------------------------------------------------------------*/ 00052 00053 class prefixOSstream 00054 : 00055 public OSstream 00056 { 00057 // Private data 00058 00059 bool printPrefix_; 00060 string prefix_; 00061 00062 00063 // Private member functions 00064 00065 inline void checkWritePrefix(); 00066 00067 00068 public: 00069 00070 // Constructors 00071 00072 //- Set stream status 00073 prefixOSstream 00074 ( 00075 ostream& os, 00076 const string& name, 00077 streamFormat format=ASCII, 00078 versionNumber version=currentVersion, 00079 compressionType compression=UNCOMPRESSED 00080 ); 00081 00082 00083 // Member functions 00084 00085 // Enquiry 00086 00087 //- Return the prefix of the stream 00088 const string& prefix() const 00089 { 00090 return prefix_; 00091 } 00092 00093 //- Return non-const access to the prefix of the stream 00094 string& prefix() 00095 { 00096 return prefix_; 00097 } 00098 00099 00100 // Write functions 00101 00102 //- Write next token to stream 00103 virtual Ostream& write(const token&); 00104 00105 //- Write character 00106 virtual Ostream& write(const char); 00107 00108 //- Write character string 00109 virtual Ostream& write(const char*); 00110 00111 //- Write word 00112 virtual Ostream& write(const word&); 00113 00114 //- Write string 00115 virtual Ostream& write(const string&); 00116 00117 //- Write std::string surrounded by quotes. 00118 // Optional write without quotes. 00119 virtual Ostream& writeQuoted 00120 ( 00121 const std::string&, 00122 const bool quoted=true 00123 ); 00124 00125 //- Write label 00126 virtual Ostream& write(const label); 00127 00128 //- Write floatScalar 00129 virtual Ostream& write(const floatScalar); 00130 00131 //- Write doubleScalar 00132 virtual Ostream& write(const doubleScalar); 00133 00134 //- Write binary block 00135 virtual Ostream& write(const char*, std::streamsize); 00136 00137 //- Add indentation characters 00138 virtual void indent(); 00139 00140 00141 // Print 00142 00143 //- Print description of IOstream to Ostream 00144 virtual void print(Ostream&) const; 00145 }; 00146 00147 00148 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 00149 00150 } // End namespace Foam 00151 00152 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 00153 00154 #endif 00155 00156 // ************************************************************************* // |