Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026 #include "prefixOSstream.H"
00027 #include <OpenFOAM/Pstream.H>
00028 #include <OpenFOAM/token.H>
00029
00030
00031
00032 inline void Foam::prefixOSstream::checkWritePrefix()
00033 {
00034 if (printPrefix_ && prefix_.size())
00035 {
00036 OSstream::write(prefix_.c_str());
00037 printPrefix_ = false;
00038 }
00039 }
00040
00041
00042
00043
00044 Foam::prefixOSstream::prefixOSstream
00045 (
00046 ostream& os,
00047 const string& name,
00048 streamFormat format,
00049 versionNumber version,
00050 compressionType compression
00051 )
00052 :
00053 OSstream(os, name, format, version, compression),
00054 printPrefix_(true),
00055 prefix_("")
00056 {}
00057
00058
00059
00060
00061 void Foam::prefixOSstream::print(Ostream& os) const
00062 {
00063 os << "prefixOSstream ";
00064 OSstream::print(os);
00065 }
00066
00067
00068 Foam::Ostream& Foam::prefixOSstream::write(const token&)
00069 {
00070 return *this;
00071 }
00072
00073
00074 Foam::Ostream& Foam::prefixOSstream::write(const char c)
00075 {
00076 checkWritePrefix();
00077 OSstream::write(c);
00078
00079 if (c == token::NL)
00080 {
00081 printPrefix_ = true;
00082 }
00083
00084 return *this;
00085 }
00086
00087
00088 Foam::Ostream& Foam::prefixOSstream::write(const char* str)
00089 {
00090 checkWritePrefix();
00091 OSstream::write(str);
00092
00093 size_t len = strlen(str);
00094 if (len && str[len-1] == token::NL)
00095 {
00096 printPrefix_ = true;
00097 }
00098
00099 return *this;
00100 }
00101
00102
00103 Foam::Ostream& Foam::prefixOSstream::write(const word& val)
00104 {
00105 checkWritePrefix();
00106 return OSstream::write(val);
00107 }
00108
00109
00110 Foam::Ostream& Foam::prefixOSstream::write(const string& val)
00111 {
00112 checkWritePrefix();
00113 return OSstream::write(val);
00114 }
00115
00116
00117 Foam::Ostream& Foam::prefixOSstream::writeQuoted
00118 (
00119 const std::string& val,
00120 const bool quoted
00121 )
00122 {
00123 checkWritePrefix();
00124 return OSstream::writeQuoted(val, quoted);
00125 }
00126
00127
00128 Foam::Ostream& Foam::prefixOSstream::write(const label val)
00129 {
00130 checkWritePrefix();
00131 return OSstream::write(val);
00132 }
00133
00134
00135 Foam::Ostream& Foam::prefixOSstream::write(const floatScalar val)
00136 {
00137 checkWritePrefix();
00138 return OSstream::write(val);
00139 }
00140
00141
00142 Foam::Ostream& Foam::prefixOSstream::write(const doubleScalar val)
00143 {
00144 checkWritePrefix();
00145 return OSstream::write(val);
00146 }
00147
00148
00149 Foam::Ostream& Foam::prefixOSstream::write
00150 (
00151 const char* buf,
00152 std::streamsize count
00153 )
00154 {
00155 checkWritePrefix();
00156 return OSstream::write(buf, count);
00157 }
00158
00159
00160 void Foam::prefixOSstream::indent()
00161 {
00162 checkWritePrefix();
00163 OSstream::indent();
00164 }
00165
00166