std::basic_streambuf<CharT,Traits>:: sgetn, std::basic_streambuf<CharT,Traits>:: xsgetn
From cppreference.net
<
cpp
|
io
|
basic streambuf
C++
Input/output library
| I/O manipulators | ||||
| Print functions (C++23) | ||||
| C-style I/O | ||||
| Buffers | ||||
|
(C++23)
|
||||
|
(
C++98/26*
)
|
||||
|
(C++20)
|
||||
| Streams | ||||
| Abstractions | ||||
| File I/O | ||||
| String I/O | ||||
| Array I/O | ||||
|
(C++23)
|
||||
|
(C++23)
|
||||
|
(C++23)
|
||||
|
(
C++98/26*
)
|
||||
|
(
C++98/26*
)
|
||||
|
(
C++98/26*
)
|
||||
| Synchronized Output | ||||
|
(C++20)
|
||||
| Types | ||||
| Error category interface | ||||
|
(C++11)
|
||||
|
(C++11)
|
std::basic_streambuf
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
std::
streamsize
sgetn
(
char_type
*
s,
std::
streamsize
count
)
;
|
(1) | |
|
protected
:
virtual std:: streamsize xsgetn ( char_type * s, std:: streamsize count ) ; |
(2) | |
1)
调用最终派生类的
xsgetn(s, count)
。
2)
从输入序列读取
count
个字符并将其存储到
s
指向的字符数组中。字符读取方式类似于重复调用
sbumpc()
。也就是说,如果立即可用的字符少于
count
个,该函数将调用
uflow()
来提供更多字符,直到返回
Traits
::
eof
(
)
。
从
std::basic_streambuf
派生的类允许为此函数提供更高效的实现。
目录 |
参数
| s | - | 指向 char_type 数组起始位置的指针 |
| count | - | 要读取的最大字符数 |
返回值
成功读取的字符数。如果该数值小于
count
,说明输入序列已到达末尾。
注释
关于“更高效实现”的规则允许进行无中间缓冲的批量I/O:这正是某些iostream实现中
std::ifstream::read
直接将指针传递给POSIX
read()
系统调用的实现方式
示例
|
本节内容不完整
原因:缺少示例 |
参见
|
调用
xsputn
(
)
(公开成员函数) |