7.3 KiB
[streambuf.virt.get]
31 Input/output library [input.output]
31.6 Stream buffers [stream.buffers]
31.6.3 Class template basic_streambuf [streambuf]
31.6.3.5 Virtual functions [streambuf.virtuals]
31.6.3.5.3 Get area [streambuf.virt.get]
streamsize showmanyc();[267](#footnote-267 "The morphemes of showmanyc are âes-how-many-seeâ, not âshow-manicâ.")
Returns: An estimate of the number of characters available in the sequence, or â1.
If it returns a positive value, then successive calls tounderflow() will not returntraits::eof() until at least that number of characters have been extracted from the stream.
Ifshowmanyc() returns â1, then calls tounderflow() oruflow() will fail.268
Default behavior: Returns zero.
Remarks: Usestraits::eof().
streamsize xsgetn(char_type* s, streamsize n);
Effects: Assigns up to n characters to successive elements of the array whose first element is designated by s.
The characters assigned are read from the input sequence as if by repeated calls tosbumpc().
Assigning stops when either n characters have been assigned or a call tosbumpc() would returntraits::eof().
Returns: The number of characters assigned.269
Remarks: Usestraits::eof().
int_type underflow();
Thepending sequence of characters is defined as the concatenation of
the empty sequence if gptr() is null, otherwise the characters in [gptr(), egptr()), followed by
some (possibly empty) sequence of characters read from the input sequence.
Theresult character is the first character of the pending sequence if it is non-empty, otherwise the next character that would be read from the input sequence.
Thebackup sequence is the empty sequence if eback() is null, otherwise the characters in [eback(), gptr()).
Effects: The function sets up thegptr() andegptr() such that if the pending sequence is non-empty, thenegptr() is non-null and the characters in [gptr(), egptr()) are the characters in the pending sequence, otherwise either gptr() is null orgptr() == egptr().
Ifeback() andgptr() are non-null then the function is not constrained as to their contents, but the âusual backup conditionâ is that either
the backup sequence contains at leastgptr() - eback() characters, in which case the characters in [eback(), gptr()) agree with the lastgptr() - eback() characters of the backup sequence, or
the characters in [gptr() - n, gptr()) agree with the backup sequence (where n is the length of the backup sequence).
Returns: traits::to_int_type(c), where c is the firstcharacter of thepending sequence, without moving the input sequence position past it.
If the pending sequence is null then the function returnstraits::eof() to indicate failure.
Default behavior: Returnstraits::eof().
Remarks: The public members ofbasic_streambuf call this virtual function only ifgptr() is null orgptr() >= egptr().
int_type uflow();
Preconditions: The constraints are the same as forunderflow(), except that the result character is transferred from the pending sequence to the backup sequence, and the pending sequence is not empty before the transfer.
Default behavior: Callsunderflow().
Ifunderflow() returnstraits::eof(), returnstraits::eof().
Otherwise, returns the value oftraits::to_int_type(*gptr()) and increments the value of the next pointer for the input sequence.
Returns: traits::eof() to indicate failure.
The morphemes of showmanyc are âes-how-many-seeâ, not âshow-manicâ.
underflow oruflow can fail by throwing an exception prematurely.
The intention is not only that the calls will not returneof() but that they will return âimmediatelyâ.
Classes derived frombasic_streambuf can provide more efficient ways to implementxsgetn() andxsputn() by overriding these definitions from the base class.