[ Web Proxy ]
URL:
Viewing: http://ru.cppreference.com/cpp/io/basic_streambuf [Back]  [Original]

std::basic_streambuf cppreference.com
cppreference.com

std::basic_streambuf

cppreference.com
< cpp | io

<metanoindex/>

 
C++
(C++20)
(C++20)
(C++11)
(C++20)
/
(C++11)
(C++11)
(C++11)
(C++17)
 
 
 
<tbody> </tbody>
template< class CharT, class Traits = std::char_traits<CharT>, class Allocator = std::allocator<CharT> > class basic_streambuf;
basic_streambuf . () , , (, / , TCP ..).
:
The class basic_streambuf controls input and output to a character sequence. It includes and provides access to the controlled character sequence (the buffer) and, optionally, the associated character sequence (file, I/O stream, TCP socket, etc).
Google.
. .
:
:
It supports the following constraints:
Google.
. .
  • :
    the controlled input sequence may not be readable.
    Google.
    . .
  • :
    the controlled output sequence may not be writeable.
    Google.
    . .
  • ( , std::codecvt)
    :
    the character representation and encoding in the controlled sequence may be different from the character representations in the associated sequence (a std::codecvt locale facet may be necessary to perform the conversion)
    Google.
    . .
  • :
    the controlled sequence may be able to access the associated sequence directly.
    Google.
    . .
  • , , .
    :
    the controlled sequence may impose arbitrary limitations on reading, writing, seeking, or ungetting characters.
    Google.
    . .
() CharT , , "" . :
:
The controlled character sequence (the buffer) is an array of CharT which, at all times, represents a subsequence, or a "window" into the associated character sequence. Its state is described by three pointers:
Google.
. .

1)

,
:
The beginning pointer, always points at the lowest element of the buffer
Google.
. .

2)

' , ,
:
The next pointer, points at the element that is the next candidate for reading or writing
Google.
. .

3)

, .
:
The end pointer, points one past the end of the buffer.
Google.
. .
, , ' . .
:
If the next pointer is less than the end pointer in an output sequence, a write position is available. The next pointer can be dereferenced and assigned to.
Google.
. .
, , . .
:
If the next pointer is less than the end pointer in an input sequence, a read position is available. The next pointer can be dereferenced and read from.
Google.
. .
, , ' Putback , , , , .
:
If the next pointer is greater than the beginning pointer in an input sequence, a putback position is available, and the next pointer may be decremented, dereferenced, and assigned to, in order to put a character back into the input sequence.
Google.
. .
basic_streambuf ( , , ' ), (' ), / . , , .
:
A basic_streambuf object may support an input sequence (in which case the buffer described by the beginning, next, and end pointers is called get area), an output sequence (put area), or an input/output sequence. In latter case, six pointers are tracked, which may all point to elements of the same character array or two individual arrays.
Google.
. .
std::basic_streambuf CharT* std::locale . , std::basic_filebuf std::basic_stringbuf.
:
Typical implementation of the std::basic_streambuf base class holds only these six CharT* pointers and a copy of std::locale as data members. The buffers themselves are implemented by the derived classes such as std::basic_filebuf or std::basic_stringbuf.
Google.
. .
:
Two convenience typedefs are provided by the standard library
Google.
. .
<streambuf>
Definition
streambuf basic_streambuf<char>
wstreambuf basic_streambuf<wchar_t>
I / O std::basic_istream, std::basic_ostream , std::basic_streambuf.
:
The I/O stream objects std::basic_istream, std::basic_ostream, and derived, are implemented entirely in terms of std::basic_streambuf.
Google.
. .

-

char_type CharT[]
traits_type Traits[]
int_type Traits::int_type[]
pos_type Traits::pos_type[]
off_type Traits::off_type[]

-

[virtual]
basic_streambuf
:
destructs the basic_streambuf object
Google.
. .

(virtual public -) []
:
Locales
Google.
. .
imbue()
:
invokes imbue()
Google.
. .

(public -) []
:
obtains a copy of the associated locale
Google.
. .

(public -) []
:
Positioning
Google.
. .
setbuf()
:
invokes setbuf()
Google.
. .

(public -) []
seekoff()
:
invokes seekoff()
Google.
. .

(public -) []
seekpos()
:
invokes seekpos()
Google.
. .

(public -) []
sync()
:
invokes sync()
Google.
. .

(public -) []
:
Get area
Google.
. .
Get
:
obtains the number of characters immediately available in the get area
Google.
. .

(public -) []
,
:
advances the input sequence, then reads one character without advancing again
Google.
. .

(public -) []
:
reads one character from the input sequence and advances the sequence
Google.
. .

(public -) []
stossc
()
, sbumpc()
:
advances the input sequence as if by calling sbumpc() and discarding the result
Google.
. .

(public -) []
:
reads one character from the input sequence without advancing the sequence
Google.
. .

(public -) []
xsgetn()
:
invokes xsgetn()
Google.
. .

(public -) []
:
Put area
Google.
. .
,
:
writes one character to the put area and advances the next pointer
Google.
. .

(public -) []
xsputn()
:
invokes xsputn()
Google.
. .

(public -) []
Putback
:
Putback
Google.
. .
:
puts one character back in the input sequence
Google.
. .

(public -) []
:
moves the next pointer in the input sequence back by one
Google.
. .

(public -) []

-
:
Protected member functions
Google.
. .

basic_streambuf
:
constructs a basic_streambuf object
Google.
. .

(protected -) []
(C++11)
basic_streambuf
:
replaces a basic_streambuf object
Google.
. .

(protected -) []
(C++11)
basic_streambuf
:
swaps two basic_streambuf objects
Google.
. .

(protected -) []
:
Locales
Google.
. .
[virtual]
:
changes the associated locale
Google.
. .

(virtual protected -) []
:
Positioning
Google.
. .
[virtual]
,
:
replaces the buffer with user-defined array, if permitted
Google.
. .

(virtual protected -) []
[virtual]
, ,
:
repositions the next pointer in the input sequence, output sequence, or both, using relative addressing
Google.
. .

(virtual protected -) []
[virtual]
, ,
:
repositions the next pointer in the input sequence, output sequence, or both using absolute addressing
Google.
. .

(virtual protected -) []
[virtual]
:
synchronizes the buffers with the associated character sequence
Google.
. .

(virtual protected -) []
:
Get area
Google.
. .
[virtual]
, ,
:
obtains the number of characters available for input in the associated input sequence, if known
Google.
. .

(virtual protected -) []
[virtual]
Get
:
reads characters from the associated input sequence to the get area
Google.
. .

(virtual protected -) []
[virtual]
Get
:
reads characters from the associated input sequence to the get area and advances the next pointer
Google.
. .

(virtual protected -) []
[virtual]
:
reads multiple characters from the input sequence
Google.
. .

(virtual protected -) []
Get
:
returns a pointer to the beginning, current character and the end of the get area
Google.
. .

(protected -) []
:
advances the next pointer in the input sequence
Google.
. .

(protected -) []
, ,
:
repositions the beginning, next, and end pointers of the input sequence
Google.
. .

(protected -) []
:
Put area
Google.
. .
[virtual]
writes multiple characters to the output sequence
(virtual protected -) []
[virtual]
:
writes characters to the associated output sequence from the put area
Google.
. .

(virtual protected -) []
:
returns a pointer to the beginning, current character and the end of the put area
Google.
. .

(protected -) []
:
advances the next pointer of the output sequence
Google.
. .

(protected -) []
, ,
:
repositions the beginning, next, and end pointers of the output sequence
Google.
. .

(protected -) []
Putback
:
Putback
Google.
. .
[virtual]
,
:
puts a character back into the input sequence, possibly modifying the input sequence
Google.
. .

(virtual protected -) []

Web Proxy Viewer  |  New URL  |  Original Page