◐ Shell
clean mode source ↗

std::strstream - cppreference.com

来自cppreference.com

class strstream : public std::iostream
(C++98 弃用)
(C++26 移除)

strstream 实现基于数组的流上的输入和输出操作。它实际上将原生数组输入/输出设备的实现(std::strstreambuf)包装到 std::basic_iostream 的高层接口中。

strstream 的典型实现仅保有一个非派生的数据成员:std::strstreambuf 类型的对象。

注解

在任何对 str() 的调用后,要求调用 freeze() 以允许析构函数在必要时解分配缓冲区。

在任何将结果用作 C 字符串的对 str() 调用前,缓冲区必须是空终止的,典型地由 std::ends 达成。

strstream 从 C++98 起被弃用并从 C++26 起被移除,推荐用 std::stringstreamstd::spanstream(C++23 起)boost::iostreams::array 替代。

成员函数

构造 strstream 对象,部分情况下会分配缓冲区
(公开成员函数) [编辑]
析构 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

成员函数

状态函数
检查是否没有发生错误,即是否可执行输入/输出操作
(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> 的公开成员函数) [编辑]
检查是否没有发生错误(!std::basic_ios::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> 的公开成员函数) [编辑]