Home
Downloads
Documentation
Installation
User Guide
man-pages
API Documentation
README
Release Notes
Changes
License
Support
SourceForge Project
Main Page
Related Pages
Namespaces
Classes
Files
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Pages
src
OpenFOAM
db
IOstreams
Sstreams
prefixOSstream.C
Go to the documentation of this file.
1
/*---------------------------------------------------------------------------*\
2
========= |
3
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4
\\ / O peration |
5
\\ / A nd | Copyright (C) 1991-2010 OpenCFD Ltd.
6
\\/ M anipulation |
7
-------------------------------------------------------------------------------
8
License
9
This file is part of OpenFOAM.
10
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
13
the Free Software Foundation, either version 3 of the License, or
14
(at your option) any later version.
15
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.
20
21
You should have received a copy of the GNU General Public License
22
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
23
24
\*---------------------------------------------------------------------------*/
25
26
#include "
prefixOSstream.H
"
27
#include <
OpenFOAM/Pstream.H
>
28
#include <
OpenFOAM/token.H
>
29
30
// * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * * //
31
32
inline
void
Foam::prefixOSstream::checkWritePrefix()
33
{
34
if
(printPrefix_ && prefix_.size())
35
{
36
OSstream::write
(prefix_.c_str());
37
printPrefix_ =
false
;
38
}
39
}
40
41
42
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
43
44
Foam::prefixOSstream::prefixOSstream
45
(
46
ostream& os,
47
const
string
&
name
,
48
streamFormat
format
,
49
versionNumber
version,
50
compressionType
compression
51
)
52
:
53
OSstream
(os, name, format, version, compression),
54
printPrefix_(
true
),
55
prefix_(
""
)
56
{}
57
58
59
// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
60
61
void
Foam::prefixOSstream::print
(
Ostream
& os)
const
62
{
63
os <<
"prefixOSstream "
;
64
OSstream::print
(os);
65
}
66
67
68
Foam::Ostream
&
Foam::prefixOSstream::write
(
const
token
&)
69
{
70
return
*
this
;
71
}
72
73
74
Foam::Ostream
&
Foam::prefixOSstream::write
(
const
char
c)
75
{
76
checkWritePrefix();
77
OSstream::write
(c);
78
79
if
(c ==
token::NL
)
80
{
81
printPrefix_ =
true
;
82
}
83
84
return
*
this
;
85
}
86
87
88
Foam::Ostream
&
Foam::prefixOSstream::write
(
const
char
* str)
89
{
90
checkWritePrefix();
91
OSstream::write
(str);
92
93
size_t
len = strlen(str);
94
if
(len && str[len-1] ==
token::NL
)
95
{
96
printPrefix_ =
true
;
97
}
98
99
return
*
this
;
100
}
101
102
103
Foam::Ostream
&
Foam::prefixOSstream::write
(
const
word
& val)
104
{
105
checkWritePrefix();
106
return
OSstream::write
(val);
107
}
108
109
110
Foam::Ostream
&
Foam::prefixOSstream::write
(
const
string
& val)
111
{
112
checkWritePrefix();
113
return
OSstream::write
(val);
114
}
115
116
117
Foam::Ostream
&
Foam::prefixOSstream::writeQuoted
118
(
119
const
std::string& val,
120
const
bool
quoted
121
)
122
{
123
checkWritePrefix();
124
return
OSstream::writeQuoted
(val, quoted);
125
}
126
127
128
Foam::Ostream
&
Foam::prefixOSstream::write
(
const
label val)
129
{
130
checkWritePrefix();
131
return
OSstream::write
(val);
132
}
133
134
135
Foam::Ostream
&
Foam::prefixOSstream::write
(
const
floatScalar
val)
136
{
137
checkWritePrefix();
138
return
OSstream::write
(val);
139
}
140
141
142
Foam::Ostream
&
Foam::prefixOSstream::write
(
const
doubleScalar
val)
143
{
144
checkWritePrefix();
145
return
OSstream::write
(val);
146
}
147
148
149
Foam::Ostream
&
Foam::prefixOSstream::write
150
(
151
const
char
* buf,
152
std::streamsize count
153
)
154
{
155
checkWritePrefix();
156
return
OSstream::write
(buf, count);
157
}
158
159
160
void
Foam::prefixOSstream::indent
()
161
{
162
checkWritePrefix();
163
OSstream::indent
();
164
}
165
166
// ************************ vim: set sw=4 sts=4 et: ************************ //