std:: strstream
|
定义于头文件
<strstream>
|
||
|
class
strstream
:
public
std::
iostream
|
(C++98 中弃用)
(C++26 中移除) |
|
类
strstream
实现了基于数组的流输入输出操作。它本质上将原始数组I/O设备实现(
std::strstreambuf
)封装到更高层次的
std::basic_iostream
接口中。
strstream
的典型实现仅包含一个非派生数据成员:一个类型为
std::strstreambuf
的对象。
目录 |
注释
在调用 str() 后,必须调用 freeze(false) 以允许析构函数在必要时释放缓冲区。
在使用 str() 的结果作为C字符串之前,缓冲区必须以空字符终止,通常使用 std::ends 实现。
strstream
自 C++98 起已被弃用,并自 C++26 起移除。
std::stringstream
、
std::spanstream
(自 C++23 起)
以及
boost::iostreams::array
是推荐的替代方案。
成员函数
构造
strstream
对象,可选择性地分配缓冲区
(公开成员函数) |
|
|
[virtual]
|
析构
strstream
对象,可选择性地释放缓冲区
(虚公开成员函数) |
获取指向关联
strstreambuf
的指针
(公开成员函数) |
|
|
访问输出缓冲区
(公开成员函数) |
|
|
禁用/启用自动重新分配
(公开成员函数) |
|
|
获取已写入字符的数量
(公开成员函数) |
继承自 std:: basic_istream
成员函数
格式化输入 |
|
|
提取格式化数据
(
std::basic_istream<CharT,Traits>
的公开成员函数)
|
|
非格式化输入 |
|
|
提取字符
(
std::basic_istream<CharT,Traits>
的公开成员函数)
|
|
|
读取下一个字符但不提取它
(
std::basic_istream<CharT,Traits>
的公开成员函数)
|
|
|
取消提取字符
(
std::basic_istream<CharT,Traits>
的公开成员函数)
|
|
|
将字符放回输入流
(
std::basic_istream<CharT,Traits>
的公开成员函数)
|
|
|
提取字符直到找到指定字符
(
std::basic_istream<CharT,Traits>
的公开成员函数)
|
|
|
提取并丢弃字符直到找到指定字符
(
std::basic_istream<CharT,Traits>
的公开成员函数)
|
|
|
提取字符块
(
std::basic_istream<CharT,Traits>
的公开成员函数)
|
|
|
提取已可用的字符块
(
std::basic_istream<CharT,Traits>
的公开成员函数)
|
|
|
返回上次非格式化输入操作提取的字符数
(
std::basic_istream<CharT,Traits>
的公开成员函数)
|
|
定位 |
|
|
返回输入位置指示器
(
std::basic_istream<CharT,Traits>
的公开成员函数)
|
|
|
设置输入位置指示器
(
std::basic_istream<CharT,Traits>
的公开成员函数)
|
|
杂项 |
|
|
与底层存储设备同步
(
std::basic_istream<CharT,Traits>
的公开成员函数)
|
|
成员类
|
实现为流输入操作准备的基本逻辑
(
std::basic_istream<CharT,Traits>
的公开成员类)
|
继承自 std:: basic_ostream
成员函数
格式化输出 |
|
|
插入格式化数据
(
std::basic_ostream<CharT,Traits>
的公开成员函数)
|
|
无格式输出 |
|
|
插入单个字符
(
std::basic_ostream<CharT,Traits>
的公开成员函数)
|
|
|
插入字符块
(
std::basic_ostream<CharT,Traits>
的公开成员函数)
|
|
定位操作 |
|
|
返回输出位置指示器
(
std::basic_ostream<CharT,Traits>
的公开成员函数)
|
|
|
设置输出位置指示器
(
std::basic_ostream<CharT,Traits>
的公开成员函数)
|
|
杂项操作 |
|
|
与底层存储设备同步
(
std::basic_ostream<CharT,Traits>
的公开成员函数)
|
|
成员类
|
实现为流输出操作做准备的基础逻辑
(
std::basic_ostream<CharT,Traits>
的公开成员类)
|
继承自 std:: basic_ios
成员类型
| 成员类型 | 定义 |
char_type
|
CharT
|
traits_type
|
Traits
|
int_type
|
Traits::int_type
|
pos_type
|
Traits::pos_type
|
off_type
|
Traits::off_type
|
成员函数
状态函数 |
|
|
检查是否未发生错误(即 I/O 操作可用)
(
std::basic_ios<CharT,Traits>
的公开成员函数)
|
|
|
检查是否已到达文件末尾
(
std::basic_ios<CharT,Traits>
的公开成员函数)
|
|
|
检查是否已发生错误
(
std::basic_ios<CharT,Traits>
的公开成员函数)
|
|
|
检查是否已发生不可恢复的错误
(
std::basic_ios<CharT,Traits>
的公开成员函数)
|
|
|
检查是否已发生错误(
fail()
的同义词)
(
std::basic_ios<CharT,Traits>
的公开成员函数)
|
|
检查是否未发生错误(
!
fail()
的同义词)
(
std::basic_ios<CharT,Traits>
的公开成员函数)
|
|
|
返回状态标志
(
std::basic_ios<CharT,Traits>
的公开成员函数)
|
|
|
设置状态标志
(
std::basic_ios<CharT,Traits>
的公开成员函数)
|
|
|
修改状态标志
(
std::basic_ios<CharT,Traits>
的公开成员函数)
|
|
格式化 |
|
|
复制格式化信息
(
std::basic_ios<CharT,Traits>
的公开成员函数)
|
|
|
管理填充字符
(
std::basic_ios<CharT,Traits>
的公开成员函数)
|
|
杂项 |
|
|
管理异常掩码
(
std::basic_ios<CharT,Traits>
的公开成员函数)
|
|
|
设置本地化环境
(
std::basic_ios<CharT,Traits>
的公开成员函数)
|
|
|
管理关联的流缓冲区
(
std::basic_ios<CharT,Traits>
的公开成员函数)
|
|
|
管理绑定的流
(
std::basic_ios<CharT,Traits>
的公开成员函数)
|
|
|
窄化字符
(
std::basic_ios<CharT,Traits>
的公开成员函数)
|
|
|
宽化字符
(
std::basic_ios<CharT,Traits>
的公开成员函数)
|
|
继承自 std:: ios_base
成员函数
格式化 |
|
|
管理格式标志
(
std::ios_base
的公开成员函数)
|
|
|
设置特定格式标志
(
std::ios_base
的公开成员函数)
|
|
|
清除特定格式标志
(
std::ios_base
的公开成员函数)
|
|
|
管理浮点运算的十进制精度
(
std::ios_base
的公开成员函数)
|
|
|
管理字段宽度
(
std::ios_base
的公开成员函数)
|
|
本地化 |
|
|
设置本地化环境
(
std::ios_base
的公开成员函数)
|
|
|
返回当前本地化环境
(
std::ios_base
的公开成员函数)
|
|
内部可扩展数组 |
|
|
[static]
|
返回一个程序范围内唯一的整数,可安全用作
pword()
和
iword()
的索引
(
std::ios_base
的公开静态成员函数)
|
|
必要时调整私有存储大小并访问指定索引处的
long
元素
(
std::ios_base
的公开成员函数)
|
|
|
必要时调整私有存储大小并访问指定索引处的
void
*
元素
(
std::ios_base
的公开成员函数)
|
|
杂项 |
|
|
注册事件回调函数
(
std::ios_base
的公开成员函数)
|
|
|
[static]
|
设置 C++ 与 C I/O 库是否可互操作
(
std::ios_base
的公开静态成员函数)
|
成员类 |
|
|
流异常
(
std::ios_base
的公开成员类)
|
|
|
初始化标准流对象
(
std::ios_base
的公开成员类)
|
|
成员类型与常量 |
|||||||||||||||
| 类型 | 说明 | ||||||||||||||
|
流打开模式类型
同时定义以下常量:
|
|||||||||||||||