std::basic_streambuf
来自cppreference.com
该页由英文版wiki使用Google Translate机器翻译而来。
该翻译可能存在错误或用词不当。鼠标停留在文本上可以看到原版本。你可以帮助我们修正错误或改进翻译。参见说明请点击这里. |
在头文件 <streambuf> 中定义
|
||
template< class CharT, |
||
的类
basic_streambuf
控制输入和输出到一个字符序列。它包括,并提供访问控制字符序列(缓冲器)和,任选地,在相关联的字符序列(文件的I / O流,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). 它支持以下限制:1
原文:
It supports the following constraints:
- 控制输入序列可能无法读取.....原文:the controlled input sequence may not be readable.
- 不受控的输出序列可能是可写的.原文:the controlled output sequence may not be writeable.
- 控制序列中的字符表示和编码可能是不同于在相关的序列中的字符表示(一个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)
- 受控制的序列可以是能够直接访问相关联的序列.原文:the controlled sequence may be able to access the associated sequence directly.
- 控制序列可能强加的限制,读,写寻求,或ungetting字符的.原文:the controlled sequence may impose arbitrary limitations on reading, writing, seeking, or ungetting characters.
受控的字符序列(缓冲区)
1) 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:开始的“指针”,总是以最低的元素在缓冲区
2) 原文:
The beginning pointer, always points at the lowest element of the buffer
的“下一个指针”,点的元素,是用于读取或写入的下一个候选
3) 原文:
The next pointer, points at the element that is the next candidate for reading or writing
“结束指针”,指出过去的缓冲.
原文:
The end pointer, points one past the end of the buffer.
如果下一个指针是小于一个输出序列的结束指针,“写入位置”是可用的。接下来的指针被解除引用,并分配给.
原文:
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.
如果下一个指针是小于在输入序列中的结束指针,一个“读位置”是可用的。接下来的指针被解除引用和读取.
原文:
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.
如果下一个指针是大于在输入序列中的开始指针,一个“补篮位置”是可用的,并且下一个指针可以递减,废弃时,和分配到,为了使返回到输入序列中的一个字符.
原文:
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.
甲
basic_streambuf
对象可以支持的输入序列(在这种情况下,所述的缓冲液开始,接着,和结束指针被称为“取回区”),一个输出序列(“把区域”),或输入/输出序列。在后一种情况下,6个指针跟踪,这可能都指向相同的字符数组的元素或两个独立的阵列.原文:
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.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.本章尚未完成 原因:Consistent terminology across the pages. Probably input/output sequence, get/put area, etc. |
由标准库提供了两个方便的typedef
原文:
Two convenience typedefs are provided by the standard library
在头文件
<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.
[编辑] 会员类型
会员类型
|
Definition |
char_type
|
CharT |
traits_type
|
Traits |
int_type
|
Traits::int_type |
pos_type
|
Traits::pos_type |
off_type
|
Traits::off_type |
[编辑] 成员函数
[虚]</div></div>
|
解构的basic_streambuf的对象 原文: destructs the basic_streambuf object (公有虚成员函数) |
| |
调用imbue() (公共成员函数) | |
获得相关的区域设置的副本 原文: obtains a copy of the associated locale (公共成员函数) | |
| |
调用setbuf() (公共成员函数) | |
调用seekoff() (公共成员函数) | |
调用seekpos() (公共成员函数) | |
调用sync() (公共成员函数) | |
| |
立即可用的字符在get区域获得的数目 原文: obtains the number of characters immediately available in the get area (公共成员函数) | |
,然后输入序列读取一个字符,再没有前进 原文: advances the input sequence, then reads one character without advancing again (公共成员函数) | |
读取一个字符的输入序列和垫款序列 原文: reads one character from the input sequence and advances the sequence (公共成员函数) | |
stossc (已弃用) |
输入序列,如果通过调用sbumpc()和丢弃的结果 原文: advances the input sequence as if by calling sbumpc() and discarding the result (公共成员函数) |
读取从输入序列中的一个字符,而不推进序列 原文: reads one character from the input sequence without advancing the sequence (公共成员函数) | |
调用xsgetn() (公共成员函数) | |
| |
写入一个字符,把区域和进步的下一个指针 原文: writes one character to the put area and advances the next pointer (公共成员函数) | |
调用xsputn() (公共成员函数) | |
| |
把输入序列中的一个字符 原文: puts one character back in the input sequence (公共成员函数) | |
输入序列中的背面由一个移动的下一个指针 原文: moves the next pointer in the input sequence back by one (公共成员函数) | |
| |
构建了一个basic_streambuf的对象 (受保护的成员函数) | |
(C++11) |
替换一个basic_streambuf的对象 (受保护的成员函数) |
(C++11) |
掉期2 basic_streambuf的对象 (受保护的成员函数) |
| |
[虚]</div></div>
|
改变相关的语言环境 (虚拟保护成员函数) |
| |
[虚]</div></div>
|
取代缓冲区与用户定义的数组,如果允许的话 原文: replaces the buffer with user-defined array, if permitted (虚拟保护成员函数) |
[虚]</div></div>
|
重新定位在输入序列中的下一个指针,输出序列,或两者,使用相对寻址 原文: repositions the next pointer in the input sequence, output sequence, or both, using relative addressing (虚拟保护成员函数) |
[虚]</div></div>
|
重新定位在输入序列中的下一个指针,输出序列,或两者都使用绝对寻址 原文: repositions the next pointer in the input sequence, output sequence, or both using absolute addressing (虚拟保护成员函数) |
[虚]</div></div>
|
同步缓冲区关联的字符序列 原文: synchronizes the buffers with the associated character sequence (虚拟保护成员函数) |
| |
[虚]</div></div>
|
获得供在相关联的输入序列中输入的字符数,如果已知的话 原文: obtains the number of characters available for input in the associated input sequence, if known (虚拟保护成员函数) |
[虚]</div></div>
|
相关的输入序列读取字符的get区 原文: reads characters from the associated input sequence to the get area (虚拟保护成员函数) |
[虚]</div></div>
|
相关的输入序列读取字符的get区和进步的下一个指针 原文: reads characters from the associated input sequence to the get area and advances the next pointer (虚拟保护成员函数) |
[虚]</div></div>
|
读取从输入序列中的多个字符 原文: reads multiple characters from the input sequence (虚拟保护成员函数) |
返回一个指针,开始的时候,当前的字符和结束的get区 原文: returns a pointer to the beginning, current character and the end of the get area (受保护的成员函数) | |
在输入序列中的下一个指针前进 原文: advances the next pointer in the input sequence (受保护的成员函数) | |
重新定位的开始,接着,和结束指针的输入序列中 原文: repositions the beginning, next, and end pointers of the input sequence (受保护的成员函数) | |
| |
[虚]</div></div>
|
writes multiple characters to the output sequence (虚拟保护成员函数) |
[虚]</div></div>
|
相关的输出序列中写入字符认沽区域 原文: writes characters to the associated output sequence from the put area (虚拟保护成员函数) |
开始的时候,当前的字符和结束的认沽返回一个指针 原文: returns a pointer to the beginning, current character and the end of the put area (受保护的成员函数) | |
进步的输出序列中的下一个指针 原文: advances the next pointer of the output sequence (受保护的成员函数) | |
重新定位的开始,接着,和结束指针的输出序列 原文: repositions the beginning, next, and end pointers of the output sequence (受保护的成员函数) | |
| |
[虚]</div></div>
|
将一个字符返回到输入序列中,有可能修改的输入序列中 原文: puts a character back into the input sequence, possibly modifying the input sequence (虚拟保护成员函数) |