21
21
* Routines for abstract base class
22
22
******************************************************************************/
23
23
24
- tm_ostream_rep::tm_ostream_rep () : ref_count ( 0 ) {}
24
+ tm_ostream_rep::tm_ostream_rep () {}
25
25
tm_ostream_rep::~tm_ostream_rep () {}
26
26
void
27
27
tm_ostream_rep::flush () {}
@@ -116,21 +116,21 @@ std_ostream_rep::flush () {
116
116
117
117
class buffered_ostream_rep : public tm_ostream_rep {
118
118
public:
119
- tm_ostream_rep* master;
120
- string buf;
119
+ tm_ostream master;
120
+ string buf;
121
121
122
122
public:
123
- buffered_ostream_rep (tm_ostream_rep* master);
123
+ buffered_ostream_rep (tm_ostream master);
124
124
~buffered_ostream_rep ();
125
125
126
126
bool is_writable () const ;
127
127
void write (const char *);
128
128
};
129
129
130
- buffered_ostream_rep::buffered_ostream_rep (tm_ostream_rep* master2)
130
+ buffered_ostream_rep::buffered_ostream_rep (tm_ostream master2)
131
131
: master (master2) {}
132
132
133
- buffered_ostream_rep::~buffered_ostream_rep () { DEC_COUNT (master); }
133
+ buffered_ostream_rep::~buffered_ostream_rep () {}
134
134
135
135
bool
136
136
buffered_ostream_rep::is_writable () const {
@@ -146,33 +146,9 @@ buffered_ostream_rep::write (const char* s) {
146
146
* Abstract user interface
147
147
******************************************************************************/
148
148
149
- tm_ostream::tm_ostream () : rep (tm_new<std_ostream_rep> ()) {
150
- INC_COUNT (this ->rep );
151
- }
152
- tm_ostream::tm_ostream (char * s) : rep (tm_new<std_ostream_rep> (s)) {
153
- INC_COUNT (this ->rep );
154
- }
155
- tm_ostream::tm_ostream (FILE* f) : rep (tm_new<std_ostream_rep> (f)) {
156
- INC_COUNT (this ->rep );
157
- }
158
- tm_ostream::tm_ostream (const tm_ostream& x) : rep (x.rep) {
159
- INC_COUNT (this ->rep );
160
- }
161
- tm_ostream::tm_ostream (tm_ostream_rep* rep2) : rep (rep2) {
162
- INC_COUNT (this ->rep );
163
- }
164
- tm_ostream::~tm_ostream () { DEC_COUNT (this ->rep ); }
165
- tm_ostream_rep*
166
- tm_ostream::operator ->() {
167
- return rep;
168
- }
169
- tm_ostream&
170
- tm_ostream::operator = (tm_ostream x) {
171
- INC_COUNT (x.rep );
172
- DEC_COUNT (this ->rep );
173
- this ->rep = x.rep ;
174
- return *this ;
175
- }
149
+ tm_ostream::tm_ostream () : base (make<std_ostream_rep> ()) {}
150
+ tm_ostream::tm_ostream (char * s) : base (make<std_ostream_rep> (s)) {}
151
+ tm_ostream::tm_ostream (FILE* f) : base (make<std_ostream_rep> (f)) {}
176
152
bool
177
153
tm_ostream::operator == (tm_ostream& out) {
178
154
return (&out == this );
@@ -190,25 +166,20 @@ tm_ostream::flush () {
190
166
191
167
void
192
168
tm_ostream::buffer () {
193
- rep= tm_new<buffered_ostream_rep> (rep);
194
- INC_COUNT (rep);
169
+ *this = tm_ostream (make<buffered_ostream_rep> (*this ));
195
170
}
196
171
197
172
string
198
173
tm_ostream::unbuffer () {
199
174
buffered_ostream_rep* ptr= (buffered_ostream_rep*) rep;
200
- rep = ptr->master ;
201
- string r = ptr->buf ;
202
- INC_COUNT (rep);
203
- DEC_COUNT (ptr);
175
+ string r = ptr->buf ;
176
+ *this = ptr->master ;
204
177
return r;
205
178
}
206
179
207
180
void
208
181
tm_ostream::redirect (tm_ostream x) {
209
- INC_COUNT (x.rep );
210
- DEC_COUNT (this ->rep );
211
- this ->rep = x.rep ;
182
+ *this = x;
212
183
}
213
184
214
185
/* *****************************************************************************
0 commit comments