From Jason Turner

[streambuf]

Diff to HTML by rtfpessoa

Files changed (1) hide show
  1. tmp/tmpfg1posck/{from.md → to.md} +37 -42
tmp/tmpfg1posck/{from.md → to.md} RENAMED
@@ -25,11 +25,11 @@ namespace std {
25
  pos_type pubseekpos(pos_type sp,
26
  ios_base::openmode which
27
  = ios_base::in | ios_base::out);
28
  int pubsync();
29
 
30
- // Get and put areas
31
  // [streambuf.pub.get], get area
32
  streamsize in_avail();
33
  int_type snextc();
34
  int_type sbumpc();
35
  int_type sgetc();
@@ -99,20 +99,19 @@ for deriving various *stream buffers* whose objects each control two
99
  *character sequences*:
100
 
101
  - a character *input sequence*;
102
  - a character *output sequence*.
103
 
104
- #### `basic_streambuf` constructors <a id="streambuf.cons">[[streambuf.cons]]</a>
105
 
106
  ``` cpp
107
  basic_streambuf();
108
  ```
109
 
110
- *Effects:* Constructs an object of class
111
- `basic_streambuf<charT, traits>` and initializes:[^13]
112
 
113
- - all its pointer member objects to null pointers,
114
  - the `getloc()` member to a copy the global locale, `locale()`, at the
115
  time of construction.
116
 
117
  *Remarks:* Once the `getloc()` member is initialized, results of calling
118
  locale member functions, and of members of facets so obtained, can
@@ -120,13 +119,11 @@ safely be cached until the next time the member `imbue` is called.
120
 
121
  ``` cpp
122
  basic_streambuf(const basic_streambuf& rhs);
123
  ```
124
 
125
- *Effects:* Constructs a copy of `rhs`.
126
-
127
- *Postconditions:*
128
 
129
  - `eback() == rhs.eback()`
130
  - `gptr() == rhs.gptr()`
131
  - `egptr() == rhs.egptr()`
132
  - `pbase() == rhs.pbase()`
@@ -138,22 +135,22 @@ basic_streambuf(const basic_streambuf& rhs);
138
  ~basic_streambuf();
139
  ```
140
 
141
  *Effects:* None.
142
 
143
- #### `basic_streambuf` public member functions <a id="streambuf.members">[[streambuf.members]]</a>
144
 
145
  ##### Locales <a id="streambuf.locales">[[streambuf.locales]]</a>
146
 
147
  ``` cpp
148
  locale pubimbue(const locale& loc);
149
  ```
150
 
151
- *Postconditions:* `loc == getloc()`.
152
-
153
  *Effects:* Calls `imbue(loc)`.
154
 
 
 
155
  *Returns:* Previous value of `getloc()`.
156
 
157
  ``` cpp
158
  locale getloc() const;
159
  ```
@@ -199,11 +196,11 @@ int pubsync();
199
  ``` cpp
200
  streamsize in_avail();
201
  ```
202
 
203
  *Returns:* If a read position is available, returns `egptr() - gptr()`.
204
- Otherwise returns `showmanyc()` ([[streambuf.virt.get]]).
205
 
206
  ``` cpp
207
  int_type snextc();
208
  ```
209
 
@@ -214,11 +211,11 @@ int_type snextc();
214
 
215
  ``` cpp
216
  int_type sbumpc();
217
  ```
218
 
219
- *Returns:* If the input sequence read position is not available, returns
220
  `uflow()`. Otherwise, returns `traits::to_int_type(*gptr())` and
221
  increments the next pointer for the input sequence.
222
 
223
  ``` cpp
224
  int_type sgetc();
@@ -237,52 +234,50 @@ streamsize sgetn(char_type* s, streamsize n);
237
 
238
  ``` cpp
239
  int_type sputbackc(char_type c);
240
  ```
241
 
242
- *Returns:* If the input sequence putback position is not available, or
243
  if `traits::eq(c, gptr()[-1])` is `false`, returns
244
  `pbackfail(traits::to_int_type(c))`. Otherwise, decrements the next
245
  pointer for the input sequence and returns
246
  `traits::to_int_type(*gptr())`.
247
 
248
  ``` cpp
249
  int_type sungetc();
250
  ```
251
 
252
- *Returns:* If the input sequence putback position is not available,
253
  returns `pbackfail()`. Otherwise, decrements the next pointer for the
254
  input sequence and returns `traits::to_int_type(*gptr())`.
255
 
256
  ##### Put area <a id="streambuf.pub.put">[[streambuf.pub.put]]</a>
257
 
258
  ``` cpp
259
  int_type sputc(char_type c);
260
  ```
261
 
262
- *Returns:* If the output sequence write position is not available,
263
  returns `overflow(traits::to_int_type(c))`. Otherwise, stores `c` at the
264
  next pointer for the output sequence, increments the pointer, and
265
  returns `traits::to_int_type(c)`.
266
 
267
  ``` cpp
268
  streamsize sputn(const char_type* s, streamsize n);
269
  ```
270
 
271
  *Returns:* `xsputn(s, n)`.
272
 
273
- #### `basic_streambuf` protected member functions <a id="streambuf.protected">[[streambuf.protected]]</a>
274
 
275
  ##### Assignment <a id="streambuf.assign">[[streambuf.assign]]</a>
276
 
277
  ``` cpp
278
  basic_streambuf& operator=(const basic_streambuf& rhs);
279
  ```
280
 
281
- *Effects:* Assigns the data members of `rhs` to `*this`.
282
-
283
- *Postconditions:*
284
 
285
  - `eback() == rhs.eback()`
286
  - `gptr() == rhs.gptr()`
287
  - `egptr() == rhs.egptr()`
288
  - `pbase() == rhs.pbase()`
@@ -326,12 +321,12 @@ void gbump(int n);
326
 
327
  ``` cpp
328
  void setg(char_type* gbeg, char_type* gnext, char_type* gend);
329
  ```
330
 
331
- *Postconditions:* `gbeg == eback()`, `gnext == gptr()`, and
332
- `gend == egptr()`.
333
 
334
  ##### Put area access <a id="streambuf.put.area">[[streambuf.put.area]]</a>
335
 
336
  ``` cpp
337
  char_type* pbase() const;
@@ -359,14 +354,14 @@ void pbump(int n);
359
 
360
  ``` cpp
361
  void setp(char_type* pbeg, char_type* pend);
362
  ```
363
 
364
- *Postconditions:* `pbeg == pbase()`, `pbeg == pptr()`, and
365
- `pend == epptr()`.
366
 
367
- #### `basic_streambuf` virtual functions <a id="streambuf.virtuals">[[streambuf.virtuals]]</a>
368
 
369
  ##### Locales <a id="streambuf.virt.locales">[[streambuf.virt.locales]]</a>
370
 
371
  ``` cpp
372
  void imbue(const locale&);
@@ -427,11 +422,11 @@ int sync();
427
  is, if `pbase()` is non-null the characters between `pbase()` and
428
  `pptr()` are written to the controlled sequence. The pointers may then
429
  be reset as appropriate.
430
 
431
  *Returns:* `-1` on failure. What constitutes failure is determined by
432
- each derived class ([[filebuf.virtuals]]).
433
 
434
  *Default behavior:* Returns zero.
435
 
436
  ##### Get area <a id="streambuf.virt.get">[[streambuf.virt.get]]</a>
437
 
@@ -468,11 +463,11 @@ to `sbumpc()` would return `traits::eof()`.
468
  ``` cpp
469
  int_type underflow();
470
  ```
471
 
472
  *Remarks:* The public members of `basic_streambuf` call this virtual
473
- function only if `gptr()` is null or `gptr() >= egptr()`
474
 
475
  *Returns:* `traits::to_int_type(c)`, where `c` is the first *character*
476
  of the *pending sequence*, without moving the input sequence position
477
  past it. If the pending sequence is null then the function returns
478
  `traits::eof()` to indicate failure.
@@ -510,13 +505,13 @@ that either
510
 
511
  ``` cpp
512
  int_type uflow();
513
  ```
514
 
515
- *Requires:* The constraints are the same as for `underflow()`, except
516
- that the result character shall be transferred from the pending sequence
517
- to the backup sequence, and the pending sequence shall not be empty
518
  before the transfer.
519
 
520
  *Default behavior:* Calls `underflow()`. If `underflow()` returns
521
  `traits::eof()`, returns `traits::eof()`. Otherwise, returns the value
522
  of `traits::to_int_type(*gptr())` and increment the value of the next
@@ -543,11 +538,11 @@ modifications that
543
  is determined.
544
  - If `traits::eq_int_type(c, traits::eof())` returns `false`, then `c`
545
  is prepended. Whether the input sequence is backed up or modified in
546
  any other way is unspecified.
547
 
548
- *Postconditions:* On return, the constraints of `gptr()`, `eback()`, and
549
  `pptr()` are the same as for `underflow()`.
550
 
551
  *Returns:* `traits::eof()` to indicate failure. Failure may occur
552
  because the input sequence could not be backed up, or if for some other
553
  reason the pointers could not be set consistent with the constraints.
@@ -579,32 +574,32 @@ int_type overflow(int_type c = traits::eof());
579
 
580
  *Effects:* Consumes some initial subsequence of the characters of the
581
  *pending sequence*. The pending sequence is defined as the concatenation
582
  of
583
 
584
- - the empty sequence if `pbase()` is not null, otherwise the
585
  `pptr() - pbase()` characters beginning at `pbase()`, followed by
586
  - the empty sequence if `traits::eq_int_type(c, traits::eof())` returns
587
  `true`, otherwise the sequence consisting of `c`.
588
 
589
  *Remarks:* The member functions `sputc()` and `sputn()` call this
590
  function in case that no room can be found in the put buffer enough to
591
  accommodate the argument character sequence.
592
 
593
- *Requires:* Every overriding definition of this virtual function shall
594
- obey the following constraints:
595
 
596
- 1. The effect of consuming a character on the associated output
597
- sequence is specified[^16]
598
- 2. Let `r` be the number of characters in the pending sequence not
599
- consumed. If `r` is nonzero then `pbase()` and `pptr()` shall be set
600
- so that: `pptr() - pbase() == r` and the `r` characters starting at
601
  `pbase()` are the associated output stream. In case `r` is zero (all
602
  characters of the pending sequence have been consumed) then either
603
- `pbase()` is set to `nullptr`, or `pbase()` and `pptr()` are both
604
- set to the same non-null value.
605
- 3. The function may fail if either appending some character to the
606
  associated output stream fails or if it is unable to establish
607
  `pbase()` and `pptr()` according to the above rules.
608
 
609
  *Returns:* `traits::eof()` or throws an exception if the function fails.
610
 
 
25
  pos_type pubseekpos(pos_type sp,
26
  ios_base::openmode which
27
  = ios_base::in | ios_base::out);
28
  int pubsync();
29
 
30
+ // get and put areas
31
  // [streambuf.pub.get], get area
32
  streamsize in_avail();
33
  int_type snextc();
34
  int_type sbumpc();
35
  int_type sgetc();
 
99
  *character sequences*:
100
 
101
  - a character *input sequence*;
102
  - a character *output sequence*.
103
 
104
+ #### Constructors <a id="streambuf.cons">[[streambuf.cons]]</a>
105
 
106
  ``` cpp
107
  basic_streambuf();
108
  ```
109
 
110
+ *Effects:* Initializes:[^13]
 
111
 
112
+ - all pointer member objects to null pointers,
113
  - the `getloc()` member to a copy the global locale, `locale()`, at the
114
  time of construction.
115
 
116
  *Remarks:* Once the `getloc()` member is initialized, results of calling
117
  locale member functions, and of members of facets so obtained, can
 
119
 
120
  ``` cpp
121
  basic_streambuf(const basic_streambuf& rhs);
122
  ```
123
 
124
+ *Ensures:*
 
 
125
 
126
  - `eback() == rhs.eback()`
127
  - `gptr() == rhs.gptr()`
128
  - `egptr() == rhs.egptr()`
129
  - `pbase() == rhs.pbase()`
 
135
  ~basic_streambuf();
136
  ```
137
 
138
  *Effects:* None.
139
 
140
+ #### Public member functions <a id="streambuf.members">[[streambuf.members]]</a>
141
 
142
  ##### Locales <a id="streambuf.locales">[[streambuf.locales]]</a>
143
 
144
  ``` cpp
145
  locale pubimbue(const locale& loc);
146
  ```
147
 
 
 
148
  *Effects:* Calls `imbue(loc)`.
149
 
150
+ *Ensures:* `loc == getloc()`.
151
+
152
  *Returns:* Previous value of `getloc()`.
153
 
154
  ``` cpp
155
  locale getloc() const;
156
  ```
 
196
  ``` cpp
197
  streamsize in_avail();
198
  ```
199
 
200
  *Returns:* If a read position is available, returns `egptr() - gptr()`.
201
+ Otherwise returns `showmanyc()` [[streambuf.virt.get]].
202
 
203
  ``` cpp
204
  int_type snextc();
205
  ```
206
 
 
211
 
212
  ``` cpp
213
  int_type sbumpc();
214
  ```
215
 
216
+ *Effects:* If the input sequence read position is not available, returns
217
  `uflow()`. Otherwise, returns `traits::to_int_type(*gptr())` and
218
  increments the next pointer for the input sequence.
219
 
220
  ``` cpp
221
  int_type sgetc();
 
234
 
235
  ``` cpp
236
  int_type sputbackc(char_type c);
237
  ```
238
 
239
+ *Effects:* If the input sequence putback position is not available, or
240
  if `traits::eq(c, gptr()[-1])` is `false`, returns
241
  `pbackfail(traits::to_int_type(c))`. Otherwise, decrements the next
242
  pointer for the input sequence and returns
243
  `traits::to_int_type(*gptr())`.
244
 
245
  ``` cpp
246
  int_type sungetc();
247
  ```
248
 
249
+ *Effects:* If the input sequence putback position is not available,
250
  returns `pbackfail()`. Otherwise, decrements the next pointer for the
251
  input sequence and returns `traits::to_int_type(*gptr())`.
252
 
253
  ##### Put area <a id="streambuf.pub.put">[[streambuf.pub.put]]</a>
254
 
255
  ``` cpp
256
  int_type sputc(char_type c);
257
  ```
258
 
259
+ *Effects:* If the output sequence write position is not available,
260
  returns `overflow(traits::to_int_type(c))`. Otherwise, stores `c` at the
261
  next pointer for the output sequence, increments the pointer, and
262
  returns `traits::to_int_type(c)`.
263
 
264
  ``` cpp
265
  streamsize sputn(const char_type* s, streamsize n);
266
  ```
267
 
268
  *Returns:* `xsputn(s, n)`.
269
 
270
+ #### Protected member functions <a id="streambuf.protected">[[streambuf.protected]]</a>
271
 
272
  ##### Assignment <a id="streambuf.assign">[[streambuf.assign]]</a>
273
 
274
  ``` cpp
275
  basic_streambuf& operator=(const basic_streambuf& rhs);
276
  ```
277
 
278
+ *Ensures:*
 
 
279
 
280
  - `eback() == rhs.eback()`
281
  - `gptr() == rhs.gptr()`
282
  - `egptr() == rhs.egptr()`
283
  - `pbase() == rhs.pbase()`
 
321
 
322
  ``` cpp
323
  void setg(char_type* gbeg, char_type* gnext, char_type* gend);
324
  ```
325
 
326
+ *Ensures:* `gbeg == eback()`, `gnext == gptr()`, and `gend == egptr()`
327
+ are all `true`.
328
 
329
  ##### Put area access <a id="streambuf.put.area">[[streambuf.put.area]]</a>
330
 
331
  ``` cpp
332
  char_type* pbase() const;
 
354
 
355
  ``` cpp
356
  void setp(char_type* pbeg, char_type* pend);
357
  ```
358
 
359
+ *Ensures:* `pbeg == pbase()`, `pbeg == pptr()`, and `pend == epptr()`
360
+ are all `true`.
361
 
362
+ #### Virtual functions <a id="streambuf.virtuals">[[streambuf.virtuals]]</a>
363
 
364
  ##### Locales <a id="streambuf.virt.locales">[[streambuf.virt.locales]]</a>
365
 
366
  ``` cpp
367
  void imbue(const locale&);
 
422
  is, if `pbase()` is non-null the characters between `pbase()` and
423
  `pptr()` are written to the controlled sequence. The pointers may then
424
  be reset as appropriate.
425
 
426
  *Returns:* `-1` on failure. What constitutes failure is determined by
427
+ each derived class [[filebuf.virtuals]].
428
 
429
  *Default behavior:* Returns zero.
430
 
431
  ##### Get area <a id="streambuf.virt.get">[[streambuf.virt.get]]</a>
432
 
 
463
  ``` cpp
464
  int_type underflow();
465
  ```
466
 
467
  *Remarks:* The public members of `basic_streambuf` call this virtual
468
+ function only if `gptr()` is null or `gptr() >= egptr()`.
469
 
470
  *Returns:* `traits::to_int_type(c)`, where `c` is the first *character*
471
  of the *pending sequence*, without moving the input sequence position
472
  past it. If the pending sequence is null then the function returns
473
  `traits::eof()` to indicate failure.
 
505
 
506
  ``` cpp
507
  int_type uflow();
508
  ```
509
 
510
+ *Preconditions:* The constraints are the same as for `underflow()`,
511
+ except that the result character is transferred from the pending
512
+ sequence to the backup sequence, and the pending sequence is not empty
513
  before the transfer.
514
 
515
  *Default behavior:* Calls `underflow()`. If `underflow()` returns
516
  `traits::eof()`, returns `traits::eof()`. Otherwise, returns the value
517
  of `traits::to_int_type(*gptr())` and increment the value of the next
 
538
  is determined.
539
  - If `traits::eq_int_type(c, traits::eof())` returns `false`, then `c`
540
  is prepended. Whether the input sequence is backed up or modified in
541
  any other way is unspecified.
542
 
543
+ *Ensures:* On return, the constraints of `gptr()`, `eback()`, and
544
  `pptr()` are the same as for `underflow()`.
545
 
546
  *Returns:* `traits::eof()` to indicate failure. Failure may occur
547
  because the input sequence could not be backed up, or if for some other
548
  reason the pointers could not be set consistent with the constraints.
 
574
 
575
  *Effects:* Consumes some initial subsequence of the characters of the
576
  *pending sequence*. The pending sequence is defined as the concatenation
577
  of
578
 
579
+ - the empty sequence if `pbase()` is null, otherwise the
580
  `pptr() - pbase()` characters beginning at `pbase()`, followed by
581
  - the empty sequence if `traits::eq_int_type(c, traits::eof())` returns
582
  `true`, otherwise the sequence consisting of `c`.
583
 
584
  *Remarks:* The member functions `sputc()` and `sputn()` call this
585
  function in case that no room can be found in the put buffer enough to
586
  accommodate the argument character sequence.
587
 
588
+ *Preconditions:* Every overriding definition of this virtual function
589
+ obeys the following constraints:
590
 
591
+ - The effect of consuming a character on the associated output sequence
592
+ is specified.[^16]
593
+ - Let `r` be the number of characters in the pending sequence not
594
+ consumed. If `r` is nonzero then `pbase()` and `pptr()` are set so
595
+ that: `pptr() - pbase() == r` and the `r` characters starting at
596
  `pbase()` are the associated output stream. In case `r` is zero (all
597
  characters of the pending sequence have been consumed) then either
598
+ `pbase()` is set to `nullptr`, or `pbase()` and `pptr()` are both set
599
+ to the same non-null value.
600
+ - The function may fail if either appending some character to the
601
  associated output stream fails or if it is unable to establish
602
  `pbase()` and `pptr()` according to the above rules.
603
 
604
  *Returns:* `traits::eof()` or throws an exception if the function fails.
605