tmp/tmpey4qpc0r/{from.md → to.md}
RENAMED
|
@@ -65,10 +65,12 @@ above:
|
|
| 65 |
shall have a defined value and is the next element to read (to get, or
|
| 66 |
to obtain a character value, from the sequence).
|
| 67 |
|
| 68 |
### Class template `basic_streambuf` <a id="streambuf">[[streambuf]]</a>
|
| 69 |
|
|
|
|
|
|
|
| 70 |
``` cpp
|
| 71 |
namespace std {
|
| 72 |
template<class charT, class traits = char_traits<charT>>
|
| 73 |
class basic_streambuf {
|
| 74 |
public:
|
|
@@ -172,15 +174,15 @@ for deriving various *stream buffers* whose objects each control two
|
|
| 172 |
|
| 173 |
``` cpp
|
| 174 |
basic_streambuf();
|
| 175 |
```
|
| 176 |
|
| 177 |
-
*Effects:* Initializes:[^
|
| 178 |
|
| 179 |
- all pointer member objects to null pointers,
|
| 180 |
-
- the `getloc()` member to a copy the global locale, `locale()`, at
|
| 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
|
| 185 |
safely be cached until the next time the member `imbue` is called.
|
| 186 |
|
|
@@ -449,11 +451,11 @@ functions and to members of facets so obtained.
|
|
| 449 |
basic_streambuf* setbuf(char_type* s, streamsize n);
|
| 450 |
```
|
| 451 |
|
| 452 |
*Effects:* Influences stream buffering in a way that is defined
|
| 453 |
separately for each class derived from `basic_streambuf` in this
|
| 454 |
-
Clause
|
| 455 |
|
| 456 |
*Default behavior:* Does nothing. Returns `this`.
|
| 457 |
|
| 458 |
``` cpp
|
| 459 |
pos_type seekoff(off_type off, ios_base::seekdir way,
|
|
@@ -461,12 +463,12 @@ pos_type seekoff(off_type off, ios_base::seekdir way,
|
|
| 461 |
= ios_base::in | ios_base::out);
|
| 462 |
```
|
| 463 |
|
| 464 |
*Effects:* Alters the stream positions within one or more of the
|
| 465 |
controlled sequences in a way that is defined separately for each class
|
| 466 |
-
derived from `basic_streambuf` in this
|
| 467 |
-
[[filebuf.virtuals]]
|
| 468 |
|
| 469 |
*Default behavior:* Returns `pos_type(off_type(-1))`.
|
| 470 |
|
| 471 |
``` cpp
|
| 472 |
pos_type seekpos(pos_type sp,
|
|
@@ -474,12 +476,12 @@ pos_type seekpos(pos_type sp,
|
|
| 474 |
= ios_base::in | ios_base::out);
|
| 475 |
```
|
| 476 |
|
| 477 |
*Effects:* Alters the stream positions within one or more of the
|
| 478 |
controlled sequences in a way that is defined separately for each class
|
| 479 |
-
derived from `basic_streambuf` in this
|
| 480 |
-
[[filebuf]]
|
| 481 |
|
| 482 |
*Default behavior:* Returns `pos_type(off_type(-1))`.
|
| 483 |
|
| 484 |
``` cpp
|
| 485 |
int sync();
|
|
@@ -496,14 +498,15 @@ each derived class [[filebuf.virtuals]].
|
|
| 496 |
*Default behavior:* Returns zero.
|
| 497 |
|
| 498 |
##### Get area <a id="streambuf.virt.get">[[streambuf.virt.get]]</a>
|
| 499 |
|
| 500 |
``` cpp
|
| 501 |
-
streamsize showmanyc();
|
| 502 |
-
are ``es-how-many-see'', not ``show-manic''.}
|
| 503 |
```
|
| 504 |
|
|
|
|
|
|
|
| 505 |
*Returns:* An estimate of the number of characters available in the
|
| 506 |
sequence, or -1. If it returns a positive value, then successive calls
|
| 507 |
to `underflow()` will not return `traits::eof()` until at least that
|
| 508 |
number of characters have been extracted from the stream. If
|
| 509 |
`showmanyc()` returns -1, then calls to `underflow()` or `uflow()` will
|
|
@@ -529,18 +532,10 @@ to `sbumpc()` would return `traits::eof()`.
|
|
| 529 |
|
| 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.
|
| 541 |
-
|
| 542 |
The *pending sequence* of characters is defined as the concatenation of
|
| 543 |
|
| 544 |
- the empty sequence if `gptr()` is null, otherwise the characters in
|
| 545 |
\[`gptr()`, `egptr()`), followed by
|
| 546 |
- some (possibly empty) sequence of characters read from the input
|
|
@@ -566,12 +561,20 @@ that either
|
|
| 566 |
in which case the characters in \[`eback()`, `gptr()`) agree with the
|
| 567 |
last `gptr() - eback()` characters of the backup sequence, or
|
| 568 |
- the characters in \[`gptr() - n`, `gptr()`) agree with the backup
|
| 569 |
sequence (where `n` is the length of the backup sequence).
|
| 570 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 571 |
*Default behavior:* Returns `traits::eof()`.
|
| 572 |
|
|
|
|
|
|
|
|
|
|
| 573 |
``` cpp
|
| 574 |
int_type uflow();
|
| 575 |
```
|
| 576 |
|
| 577 |
*Preconditions:* The constraints are the same as for `underflow()`,
|
|
@@ -579,26 +582,21 @@ 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
|
| 585 |
pointer for the input sequence.
|
| 586 |
|
| 587 |
*Returns:* `traits::eof()` to indicate failure.
|
| 588 |
|
| 589 |
##### Putback <a id="streambuf.virt.pback">[[streambuf.virt.pback]]</a>
|
| 590 |
|
| 591 |
``` cpp
|
| 592 |
int_type pbackfail(int_type c = traits::eof());
|
| 593 |
```
|
| 594 |
|
| 595 |
-
*Remarks:* The public functions of `basic_streambuf` call this virtual
|
| 596 |
-
function only when `gptr()` is null, `gptr() == eback()`, or
|
| 597 |
-
`traits::eq(traits::to_char_type(c), gptr()[-1])` returns `false`. Other
|
| 598 |
-
calls shall also satisfy that constraint.
|
| 599 |
-
|
| 600 |
The *pending sequence* is defined as for `underflow()`, with the
|
| 601 |
modifications that
|
| 602 |
|
| 603 |
- If `traits::eq_int_type(c, traits::eof())` returns `true`, then the
|
| 604 |
input sequence is backed up one character before the pending sequence
|
|
@@ -610,17 +608,22 @@ modifications that
|
|
| 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
|
| 616 |
`pbackfail()` is called only when put back has really failed.
|
| 617 |
|
| 618 |
Returns some value other than `traits::eof()` to indicate success.
|
| 619 |
|
| 620 |
*Default behavior:* Returns `traits::eof()`.
|
| 621 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 622 |
##### Put area <a id="streambuf.virt.put">[[streambuf.virt.put]]</a>
|
| 623 |
|
| 624 |
``` cpp
|
| 625 |
streamsize xsputn(const char_type* s, streamsize n);
|
| 626 |
```
|
|
@@ -646,14 +649,10 @@ of
|
|
| 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]
|
|
@@ -673,5 +672,9 @@ obeys the following constraints:
|
|
| 673 |
Otherwise, returns some value other than `traits::eof()` to indicate
|
| 674 |
success.[^17]
|
| 675 |
|
| 676 |
*Default behavior:* Returns `traits::eof()`.
|
| 677 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 65 |
shall have a defined value and is the next element to read (to get, or
|
| 66 |
to obtain a character value, from the sequence).
|
| 67 |
|
| 68 |
### Class template `basic_streambuf` <a id="streambuf">[[streambuf]]</a>
|
| 69 |
|
| 70 |
+
#### General <a id="streambuf.general">[[streambuf.general]]</a>
|
| 71 |
+
|
| 72 |
``` cpp
|
| 73 |
namespace std {
|
| 74 |
template<class charT, class traits = char_traits<charT>>
|
| 75 |
class basic_streambuf {
|
| 76 |
public:
|
|
|
|
| 174 |
|
| 175 |
``` cpp
|
| 176 |
basic_streambuf();
|
| 177 |
```
|
| 178 |
|
| 179 |
+
*Effects:* Initializes:[^12]
|
| 180 |
|
| 181 |
- all pointer member objects to null pointers,
|
| 182 |
+
- the `getloc()` member to a copy of the global locale, `locale()`, at
|
| 183 |
+
the time of construction.
|
| 184 |
|
| 185 |
*Remarks:* Once the `getloc()` member is initialized, results of calling
|
| 186 |
locale member functions, and of members of facets so obtained, can
|
| 187 |
safely be cached until the next time the member `imbue` is called.
|
| 188 |
|
|
|
|
| 451 |
basic_streambuf* setbuf(char_type* s, streamsize n);
|
| 452 |
```
|
| 453 |
|
| 454 |
*Effects:* Influences stream buffering in a way that is defined
|
| 455 |
separately for each class derived from `basic_streambuf` in this
|
| 456 |
+
Clause [[stringbuf.virtuals]], [[filebuf.virtuals]].
|
| 457 |
|
| 458 |
*Default behavior:* Does nothing. Returns `this`.
|
| 459 |
|
| 460 |
``` cpp
|
| 461 |
pos_type seekoff(off_type off, ios_base::seekdir way,
|
|
|
|
| 463 |
= ios_base::in | ios_base::out);
|
| 464 |
```
|
| 465 |
|
| 466 |
*Effects:* Alters the stream positions within one or more of the
|
| 467 |
controlled sequences in a way that is defined separately for each class
|
| 468 |
+
derived from `basic_streambuf` in this
|
| 469 |
+
Clause [[stringbuf.virtuals]], [[filebuf.virtuals]].
|
| 470 |
|
| 471 |
*Default behavior:* Returns `pos_type(off_type(-1))`.
|
| 472 |
|
| 473 |
``` cpp
|
| 474 |
pos_type seekpos(pos_type sp,
|
|
|
|
| 476 |
= ios_base::in | ios_base::out);
|
| 477 |
```
|
| 478 |
|
| 479 |
*Effects:* Alters the stream positions within one or more of the
|
| 480 |
controlled sequences in a way that is defined separately for each class
|
| 481 |
+
derived from `basic_streambuf` in this
|
| 482 |
+
Clause [[stringbuf]], [[filebuf]].
|
| 483 |
|
| 484 |
*Default behavior:* Returns `pos_type(off_type(-1))`.
|
| 485 |
|
| 486 |
``` cpp
|
| 487 |
int sync();
|
|
|
|
| 498 |
*Default behavior:* Returns zero.
|
| 499 |
|
| 500 |
##### Get area <a id="streambuf.virt.get">[[streambuf.virt.get]]</a>
|
| 501 |
|
| 502 |
``` cpp
|
| 503 |
+
streamsize showmanyc();
|
|
|
|
| 504 |
```
|
| 505 |
|
| 506 |
+
[^13]
|
| 507 |
+
|
| 508 |
*Returns:* An estimate of the number of characters available in the
|
| 509 |
sequence, or -1. If it returns a positive value, then successive calls
|
| 510 |
to `underflow()` will not return `traits::eof()` until at least that
|
| 511 |
number of characters have been extracted from the stream. If
|
| 512 |
`showmanyc()` returns -1, then calls to `underflow()` or `uflow()` will
|
|
|
|
| 532 |
|
| 533 |
``` cpp
|
| 534 |
int_type underflow();
|
| 535 |
```
|
| 536 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 537 |
The *pending sequence* of characters is defined as the concatenation of
|
| 538 |
|
| 539 |
- the empty sequence if `gptr()` is null, otherwise the characters in
|
| 540 |
\[`gptr()`, `egptr()`), followed by
|
| 541 |
- some (possibly empty) sequence of characters read from the input
|
|
|
|
| 561 |
in which case the characters in \[`eback()`, `gptr()`) agree with the
|
| 562 |
last `gptr() - eback()` characters of the backup sequence, or
|
| 563 |
- the characters in \[`gptr() - n`, `gptr()`) agree with the backup
|
| 564 |
sequence (where `n` is the length of the backup sequence).
|
| 565 |
|
| 566 |
+
*Returns:* `traits::to_int_type(c)`, where `c` is the first *character*
|
| 567 |
+
of the *pending sequence*, without moving the input sequence position
|
| 568 |
+
past it. If the pending sequence is null then the function returns
|
| 569 |
+
`traits::eof()` to indicate failure.
|
| 570 |
+
|
| 571 |
*Default behavior:* Returns `traits::eof()`.
|
| 572 |
|
| 573 |
+
*Remarks:* The public members of `basic_streambuf` call this virtual
|
| 574 |
+
function only if `gptr()` is null or `gptr() >= egptr()`.
|
| 575 |
+
|
| 576 |
``` cpp
|
| 577 |
int_type uflow();
|
| 578 |
```
|
| 579 |
|
| 580 |
*Preconditions:* The constraints are the same as for `underflow()`,
|
|
|
|
| 582 |
sequence to the backup sequence, and the pending sequence is not empty
|
| 583 |
before the transfer.
|
| 584 |
|
| 585 |
*Default behavior:* Calls `underflow()`. If `underflow()` returns
|
| 586 |
`traits::eof()`, returns `traits::eof()`. Otherwise, returns the value
|
| 587 |
+
of `traits::to_int_type(*gptr())` and increments the value of the next
|
| 588 |
pointer for the input sequence.
|
| 589 |
|
| 590 |
*Returns:* `traits::eof()` to indicate failure.
|
| 591 |
|
| 592 |
##### Putback <a id="streambuf.virt.pback">[[streambuf.virt.pback]]</a>
|
| 593 |
|
| 594 |
``` cpp
|
| 595 |
int_type pbackfail(int_type c = traits::eof());
|
| 596 |
```
|
| 597 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 598 |
The *pending sequence* is defined as for `underflow()`, with the
|
| 599 |
modifications that
|
| 600 |
|
| 601 |
- If `traits::eq_int_type(c, traits::eof())` returns `true`, then the
|
| 602 |
input sequence is backed up one character before the pending sequence
|
|
|
|
| 608 |
*Ensures:* On return, the constraints of `gptr()`, `eback()`, and
|
| 609 |
`pptr()` are the same as for `underflow()`.
|
| 610 |
|
| 611 |
*Returns:* `traits::eof()` to indicate failure. Failure may occur
|
| 612 |
because the input sequence could not be backed up, or if for some other
|
| 613 |
+
reason the pointers cannot be set consistent with the constraints.
|
| 614 |
`pbackfail()` is called only when put back has really failed.
|
| 615 |
|
| 616 |
Returns some value other than `traits::eof()` to indicate success.
|
| 617 |
|
| 618 |
*Default behavior:* Returns `traits::eof()`.
|
| 619 |
|
| 620 |
+
*Remarks:* The public functions of `basic_streambuf` call this virtual
|
| 621 |
+
function only when `gptr()` is null, `gptr() == eback()`, or
|
| 622 |
+
`traits::eq(traits::to_char_type(c), gptr()[-1])` returns `false`. Other
|
| 623 |
+
calls shall also satisfy that constraint.
|
| 624 |
+
|
| 625 |
##### Put area <a id="streambuf.virt.put">[[streambuf.virt.put]]</a>
|
| 626 |
|
| 627 |
``` cpp
|
| 628 |
streamsize xsputn(const char_type* s, streamsize n);
|
| 629 |
```
|
|
|
|
| 649 |
- the empty sequence if `pbase()` is null, otherwise the
|
| 650 |
`pptr() - pbase()` characters beginning at `pbase()`, followed by
|
| 651 |
- the empty sequence if `traits::eq_int_type(c, traits::eof())` returns
|
| 652 |
`true`, otherwise the sequence consisting of `c`.
|
| 653 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 654 |
*Preconditions:* Every overriding definition of this virtual function
|
| 655 |
obeys the following constraints:
|
| 656 |
|
| 657 |
- The effect of consuming a character on the associated output sequence
|
| 658 |
is specified.[^16]
|
|
|
|
| 672 |
Otherwise, returns some value other than `traits::eof()` to indicate
|
| 673 |
success.[^17]
|
| 674 |
|
| 675 |
*Default behavior:* Returns `traits::eof()`.
|
| 676 |
|
| 677 |
+
*Remarks:* The member functions `sputc()` and `sputn()` call this
|
| 678 |
+
function in case that no room can be found in the put buffer enough to
|
| 679 |
+
accommodate the argument character sequence.
|
| 680 |
+
|