From Jason Turner

[stream.buffers]

Diff to HTML by rtfpessoa

Files changed (1) hide show
  1. tmp/tmpynz5g2a5/{from.md → to.md} +37 -42
tmp/tmpynz5g2a5/{from.md → to.md} RENAMED
@@ -92,11 +92,11 @@ namespace std {
92
  pos_type pubseekpos(pos_type sp,
93
  ios_base::openmode which
94
  = ios_base::in | ios_base::out);
95
  int pubsync();
96
 
97
- // Get and put areas
98
  // [streambuf.pub.get], get area
99
  streamsize in_avail();
100
  int_type snextc();
101
  int_type sbumpc();
102
  int_type sgetc();
@@ -166,20 +166,19 @@ for deriving various *stream buffers* whose objects each control two
166
  *character sequences*:
167
 
168
  - a character *input sequence*;
169
  - a character *output sequence*.
170
 
171
- #### `basic_streambuf` constructors <a id="streambuf.cons">[[streambuf.cons]]</a>
172
 
173
  ``` cpp
174
  basic_streambuf();
175
  ```
176
 
177
- *Effects:* Constructs an object of class
178
- `basic_streambuf<charT, traits>` and initializes:[^13]
179
 
180
- - all its pointer member objects to null pointers,
181
  - the `getloc()` member to a copy the global locale, `locale()`, at the
182
  time of construction.
183
 
184
  *Remarks:* Once the `getloc()` member is initialized, results of calling
185
  locale member functions, and of members of facets so obtained, can
@@ -187,13 +186,11 @@ safely be cached until the next time the member `imbue` is called.
187
 
188
  ``` cpp
189
  basic_streambuf(const basic_streambuf& rhs);
190
  ```
191
 
192
- *Effects:* Constructs a copy of `rhs`.
193
-
194
- *Postconditions:*
195
 
196
  - `eback() == rhs.eback()`
197
  - `gptr() == rhs.gptr()`
198
  - `egptr() == rhs.egptr()`
199
  - `pbase() == rhs.pbase()`
@@ -205,22 +202,22 @@ basic_streambuf(const basic_streambuf& rhs);
205
  ~basic_streambuf();
206
  ```
207
 
208
  *Effects:* None.
209
 
210
- #### `basic_streambuf` public member functions <a id="streambuf.members">[[streambuf.members]]</a>
211
 
212
  ##### Locales <a id="streambuf.locales">[[streambuf.locales]]</a>
213
 
214
  ``` cpp
215
  locale pubimbue(const locale& loc);
216
  ```
217
 
218
- *Postconditions:* `loc == getloc()`.
219
-
220
  *Effects:* Calls `imbue(loc)`.
221
 
 
 
222
  *Returns:* Previous value of `getloc()`.
223
 
224
  ``` cpp
225
  locale getloc() const;
226
  ```
@@ -266,11 +263,11 @@ int pubsync();
266
  ``` cpp
267
  streamsize in_avail();
268
  ```
269
 
270
  *Returns:* If a read position is available, returns `egptr() - gptr()`.
271
- Otherwise returns `showmanyc()` ([[streambuf.virt.get]]).
272
 
273
  ``` cpp
274
  int_type snextc();
275
  ```
276
 
@@ -281,11 +278,11 @@ int_type snextc();
281
 
282
  ``` cpp
283
  int_type sbumpc();
284
  ```
285
 
286
- *Returns:* If the input sequence read position is not available, returns
287
  `uflow()`. Otherwise, returns `traits::to_int_type(*gptr())` and
288
  increments the next pointer for the input sequence.
289
 
290
  ``` cpp
291
  int_type sgetc();
@@ -304,52 +301,50 @@ streamsize sgetn(char_type* s, streamsize n);
304
 
305
  ``` cpp
306
  int_type sputbackc(char_type c);
307
  ```
308
 
309
- *Returns:* If the input sequence putback position is not available, or
310
  if `traits::eq(c, gptr()[-1])` is `false`, returns
311
  `pbackfail(traits::to_int_type(c))`. Otherwise, decrements the next
312
  pointer for the input sequence and returns
313
  `traits::to_int_type(*gptr())`.
314
 
315
  ``` cpp
316
  int_type sungetc();
317
  ```
318
 
319
- *Returns:* If the input sequence putback position is not available,
320
  returns `pbackfail()`. Otherwise, decrements the next pointer for the
321
  input sequence and returns `traits::to_int_type(*gptr())`.
322
 
323
  ##### Put area <a id="streambuf.pub.put">[[streambuf.pub.put]]</a>
324
 
325
  ``` cpp
326
  int_type sputc(char_type c);
327
  ```
328
 
329
- *Returns:* If the output sequence write position is not available,
330
  returns `overflow(traits::to_int_type(c))`. Otherwise, stores `c` at the
331
  next pointer for the output sequence, increments the pointer, and
332
  returns `traits::to_int_type(c)`.
333
 
334
  ``` cpp
335
  streamsize sputn(const char_type* s, streamsize n);
336
  ```
337
 
338
  *Returns:* `xsputn(s, n)`.
339
 
340
- #### `basic_streambuf` protected member functions <a id="streambuf.protected">[[streambuf.protected]]</a>
341
 
342
  ##### Assignment <a id="streambuf.assign">[[streambuf.assign]]</a>
343
 
344
  ``` cpp
345
  basic_streambuf& operator=(const basic_streambuf& rhs);
346
  ```
347
 
348
- *Effects:* Assigns the data members of `rhs` to `*this`.
349
-
350
- *Postconditions:*
351
 
352
  - `eback() == rhs.eback()`
353
  - `gptr() == rhs.gptr()`
354
  - `egptr() == rhs.egptr()`
355
  - `pbase() == rhs.pbase()`
@@ -393,12 +388,12 @@ void gbump(int n);
393
 
394
  ``` cpp
395
  void setg(char_type* gbeg, char_type* gnext, char_type* gend);
396
  ```
397
 
398
- *Postconditions:* `gbeg == eback()`, `gnext == gptr()`, and
399
- `gend == egptr()`.
400
 
401
  ##### Put area access <a id="streambuf.put.area">[[streambuf.put.area]]</a>
402
 
403
  ``` cpp
404
  char_type* pbase() const;
@@ -426,14 +421,14 @@ void pbump(int n);
426
 
427
  ``` cpp
428
  void setp(char_type* pbeg, char_type* pend);
429
  ```
430
 
431
- *Postconditions:* `pbeg == pbase()`, `pbeg == pptr()`, and
432
- `pend == epptr()`.
433
 
434
- #### `basic_streambuf` virtual functions <a id="streambuf.virtuals">[[streambuf.virtuals]]</a>
435
 
436
  ##### Locales <a id="streambuf.virt.locales">[[streambuf.virt.locales]]</a>
437
 
438
  ``` cpp
439
  void imbue(const locale&);
@@ -494,11 +489,11 @@ int sync();
494
  is, if `pbase()` is non-null the characters between `pbase()` and
495
  `pptr()` are written to the controlled sequence. The pointers may then
496
  be reset as appropriate.
497
 
498
  *Returns:* `-1` on failure. What constitutes failure is determined by
499
- each derived class ([[filebuf.virtuals]]).
500
 
501
  *Default behavior:* Returns zero.
502
 
503
  ##### Get area <a id="streambuf.virt.get">[[streambuf.virt.get]]</a>
504
 
@@ -535,11 +530,11 @@ to `sbumpc()` would return `traits::eof()`.
535
  ``` cpp
536
  int_type underflow();
537
  ```
538
 
539
  *Remarks:* The public members of `basic_streambuf` call this virtual
540
- function only if `gptr()` is null or `gptr() >= egptr()`
541
 
542
  *Returns:* `traits::to_int_type(c)`, where `c` is the first *character*
543
  of the *pending sequence*, without moving the input sequence position
544
  past it. If the pending sequence is null then the function returns
545
  `traits::eof()` to indicate failure.
@@ -577,13 +572,13 @@ that either
577
 
578
  ``` cpp
579
  int_type uflow();
580
  ```
581
 
582
- *Requires:* The constraints are the same as for `underflow()`, except
583
- that the result character shall be transferred from the pending sequence
584
- to the backup sequence, and the pending sequence shall not be empty
585
  before the transfer.
586
 
587
  *Default behavior:* Calls `underflow()`. If `underflow()` returns
588
  `traits::eof()`, returns `traits::eof()`. Otherwise, returns the value
589
  of `traits::to_int_type(*gptr())` and increment the value of the next
@@ -610,11 +605,11 @@ modifications that
610
  is determined.
611
  - If `traits::eq_int_type(c, traits::eof())` returns `false`, then `c`
612
  is prepended. Whether the input sequence is backed up or modified in
613
  any other way is unspecified.
614
 
615
- *Postconditions:* On return, the constraints of `gptr()`, `eback()`, and
616
  `pptr()` are the same as for `underflow()`.
617
 
618
  *Returns:* `traits::eof()` to indicate failure. Failure may occur
619
  because the input sequence could not be backed up, or if for some other
620
  reason the pointers could not be set consistent with the constraints.
@@ -646,32 +641,32 @@ int_type overflow(int_type c = traits::eof());
646
 
647
  *Effects:* Consumes some initial subsequence of the characters of the
648
  *pending sequence*. The pending sequence is defined as the concatenation
649
  of
650
 
651
- - the empty sequence if `pbase()` is not null, otherwise the
652
  `pptr() - pbase()` characters beginning at `pbase()`, followed by
653
  - the empty sequence if `traits::eq_int_type(c, traits::eof())` returns
654
  `true`, otherwise the sequence consisting of `c`.
655
 
656
  *Remarks:* The member functions `sputc()` and `sputn()` call this
657
  function in case that no room can be found in the put buffer enough to
658
  accommodate the argument character sequence.
659
 
660
- *Requires:* Every overriding definition of this virtual function shall
661
- obey the following constraints:
662
 
663
- 1. The effect of consuming a character on the associated output
664
- sequence is specified[^16]
665
- 2. Let `r` be the number of characters in the pending sequence not
666
- consumed. If `r` is nonzero then `pbase()` and `pptr()` shall be set
667
- so that: `pptr() - pbase() == r` and the `r` characters starting at
668
  `pbase()` are the associated output stream. In case `r` is zero (all
669
  characters of the pending sequence have been consumed) then either
670
- `pbase()` is set to `nullptr`, or `pbase()` and `pptr()` are both
671
- set to the same non-null value.
672
- 3. The function may fail if either appending some character to the
673
  associated output stream fails or if it is unable to establish
674
  `pbase()` and `pptr()` according to the above rules.
675
 
676
  *Returns:* `traits::eof()` or throws an exception if the function fails.
677
 
 
92
  pos_type pubseekpos(pos_type sp,
93
  ios_base::openmode which
94
  = ios_base::in | ios_base::out);
95
  int pubsync();
96
 
97
+ // get and put areas
98
  // [streambuf.pub.get], get area
99
  streamsize in_avail();
100
  int_type snextc();
101
  int_type sbumpc();
102
  int_type sgetc();
 
166
  *character sequences*:
167
 
168
  - a character *input sequence*;
169
  - a character *output sequence*.
170
 
171
+ #### Constructors <a id="streambuf.cons">[[streambuf.cons]]</a>
172
 
173
  ``` cpp
174
  basic_streambuf();
175
  ```
176
 
177
+ *Effects:* Initializes:[^13]
 
178
 
179
+ - all pointer member objects to null pointers,
180
  - the `getloc()` member to a copy the global locale, `locale()`, at the
181
  time of construction.
182
 
183
  *Remarks:* Once the `getloc()` member is initialized, results of calling
184
  locale member functions, and of members of facets so obtained, can
 
186
 
187
  ``` cpp
188
  basic_streambuf(const basic_streambuf& rhs);
189
  ```
190
 
191
+ *Ensures:*
 
 
192
 
193
  - `eback() == rhs.eback()`
194
  - `gptr() == rhs.gptr()`
195
  - `egptr() == rhs.egptr()`
196
  - `pbase() == rhs.pbase()`
 
202
  ~basic_streambuf();
203
  ```
204
 
205
  *Effects:* None.
206
 
207
+ #### Public member functions <a id="streambuf.members">[[streambuf.members]]</a>
208
 
209
  ##### Locales <a id="streambuf.locales">[[streambuf.locales]]</a>
210
 
211
  ``` cpp
212
  locale pubimbue(const locale& loc);
213
  ```
214
 
 
 
215
  *Effects:* Calls `imbue(loc)`.
216
 
217
+ *Ensures:* `loc == getloc()`.
218
+
219
  *Returns:* Previous value of `getloc()`.
220
 
221
  ``` cpp
222
  locale getloc() const;
223
  ```
 
263
  ``` cpp
264
  streamsize in_avail();
265
  ```
266
 
267
  *Returns:* If a read position is available, returns `egptr() - gptr()`.
268
+ Otherwise returns `showmanyc()` [[streambuf.virt.get]].
269
 
270
  ``` cpp
271
  int_type snextc();
272
  ```
273
 
 
278
 
279
  ``` cpp
280
  int_type sbumpc();
281
  ```
282
 
283
+ *Effects:* If the input sequence read position is not available, returns
284
  `uflow()`. Otherwise, returns `traits::to_int_type(*gptr())` and
285
  increments the next pointer for the input sequence.
286
 
287
  ``` cpp
288
  int_type sgetc();
 
301
 
302
  ``` cpp
303
  int_type sputbackc(char_type c);
304
  ```
305
 
306
+ *Effects:* If the input sequence putback position is not available, or
307
  if `traits::eq(c, gptr()[-1])` is `false`, returns
308
  `pbackfail(traits::to_int_type(c))`. Otherwise, decrements the next
309
  pointer for the input sequence and returns
310
  `traits::to_int_type(*gptr())`.
311
 
312
  ``` cpp
313
  int_type sungetc();
314
  ```
315
 
316
+ *Effects:* If the input sequence putback position is not available,
317
  returns `pbackfail()`. Otherwise, decrements the next pointer for the
318
  input sequence and returns `traits::to_int_type(*gptr())`.
319
 
320
  ##### Put area <a id="streambuf.pub.put">[[streambuf.pub.put]]</a>
321
 
322
  ``` cpp
323
  int_type sputc(char_type c);
324
  ```
325
 
326
+ *Effects:* If the output sequence write position is not available,
327
  returns `overflow(traits::to_int_type(c))`. Otherwise, stores `c` at the
328
  next pointer for the output sequence, increments the pointer, and
329
  returns `traits::to_int_type(c)`.
330
 
331
  ``` cpp
332
  streamsize sputn(const char_type* s, streamsize n);
333
  ```
334
 
335
  *Returns:* `xsputn(s, n)`.
336
 
337
+ #### Protected member functions <a id="streambuf.protected">[[streambuf.protected]]</a>
338
 
339
  ##### Assignment <a id="streambuf.assign">[[streambuf.assign]]</a>
340
 
341
  ``` cpp
342
  basic_streambuf& operator=(const basic_streambuf& rhs);
343
  ```
344
 
345
+ *Ensures:*
 
 
346
 
347
  - `eback() == rhs.eback()`
348
  - `gptr() == rhs.gptr()`
349
  - `egptr() == rhs.egptr()`
350
  - `pbase() == rhs.pbase()`
 
388
 
389
  ``` cpp
390
  void setg(char_type* gbeg, char_type* gnext, char_type* gend);
391
  ```
392
 
393
+ *Ensures:* `gbeg == eback()`, `gnext == gptr()`, and `gend == egptr()`
394
+ are all `true`.
395
 
396
  ##### Put area access <a id="streambuf.put.area">[[streambuf.put.area]]</a>
397
 
398
  ``` cpp
399
  char_type* pbase() const;
 
421
 
422
  ``` cpp
423
  void setp(char_type* pbeg, char_type* pend);
424
  ```
425
 
426
+ *Ensures:* `pbeg == pbase()`, `pbeg == pptr()`, and `pend == epptr()`
427
+ are all `true`.
428
 
429
+ #### Virtual functions <a id="streambuf.virtuals">[[streambuf.virtuals]]</a>
430
 
431
  ##### Locales <a id="streambuf.virt.locales">[[streambuf.virt.locales]]</a>
432
 
433
  ``` cpp
434
  void imbue(const locale&);
 
489
  is, if `pbase()` is non-null the characters between `pbase()` and
490
  `pptr()` are written to the controlled sequence. The pointers may then
491
  be reset as appropriate.
492
 
493
  *Returns:* `-1` on failure. What constitutes failure is determined by
494
+ each derived class [[filebuf.virtuals]].
495
 
496
  *Default behavior:* Returns zero.
497
 
498
  ##### Get area <a id="streambuf.virt.get">[[streambuf.virt.get]]</a>
499
 
 
530
  ``` cpp
531
  int_type underflow();
532
  ```
533
 
534
  *Remarks:* The public members of `basic_streambuf` call this virtual
535
+ function only if `gptr()` is null or `gptr() >= egptr()`.
536
 
537
  *Returns:* `traits::to_int_type(c)`, where `c` is the first *character*
538
  of the *pending sequence*, without moving the input sequence position
539
  past it. If the pending sequence is null then the function returns
540
  `traits::eof()` to indicate failure.
 
572
 
573
  ``` cpp
574
  int_type uflow();
575
  ```
576
 
577
+ *Preconditions:* The constraints are the same as for `underflow()`,
578
+ except that the result character is transferred from the pending
579
+ sequence to the backup sequence, and the pending sequence is not empty
580
  before the transfer.
581
 
582
  *Default behavior:* Calls `underflow()`. If `underflow()` returns
583
  `traits::eof()`, returns `traits::eof()`. Otherwise, returns the value
584
  of `traits::to_int_type(*gptr())` and increment the value of the next
 
605
  is determined.
606
  - If `traits::eq_int_type(c, traits::eof())` returns `false`, then `c`
607
  is prepended. Whether the input sequence is backed up or modified in
608
  any other way is unspecified.
609
 
610
+ *Ensures:* On return, the constraints of `gptr()`, `eback()`, and
611
  `pptr()` are the same as for `underflow()`.
612
 
613
  *Returns:* `traits::eof()` to indicate failure. Failure may occur
614
  because the input sequence could not be backed up, or if for some other
615
  reason the pointers could not be set consistent with the constraints.
 
641
 
642
  *Effects:* Consumes some initial subsequence of the characters of the
643
  *pending sequence*. The pending sequence is defined as the concatenation
644
  of
645
 
646
+ - the empty sequence if `pbase()` is null, otherwise the
647
  `pptr() - pbase()` characters beginning at `pbase()`, followed by
648
  - the empty sequence if `traits::eq_int_type(c, traits::eof())` returns
649
  `true`, otherwise the sequence consisting of `c`.
650
 
651
  *Remarks:* The member functions `sputc()` and `sputn()` call this
652
  function in case that no room can be found in the put buffer enough to
653
  accommodate the argument character sequence.
654
 
655
+ *Preconditions:* Every overriding definition of this virtual function
656
+ obeys the following constraints:
657
 
658
+ - The effect of consuming a character on the associated output sequence
659
+ is specified.[^16]
660
+ - Let `r` be the number of characters in the pending sequence not
661
+ consumed. If `r` is nonzero then `pbase()` and `pptr()` are set so
662
+ that: `pptr() - pbase() == r` and the `r` characters starting at
663
  `pbase()` are the associated output stream. In case `r` is zero (all
664
  characters of the pending sequence have been consumed) then either
665
+ `pbase()` is set to `nullptr`, or `pbase()` and `pptr()` are both set
666
+ to the same non-null value.
667
+ - The function may fail if either appending some character to the
668
  associated output stream fails or if it is unable to establish
669
  `pbase()` and `pptr()` according to the above rules.
670
 
671
  *Returns:* `traits::eof()` or throws an exception if the function fails.
672