std::ostrstream
来自 cppreference.cn
定义于头文件 <strstream> |
||
class ostrstream : public std::ostream |
(在 C++98 中已弃用) (在 C++26 中已移除) |
|
类 ostrstream
实现了对数组支持的流的输出操作。它本质上将原始数组 I/O 设备实现 (std::strstreambuf) 封装到 std::basic_ostream 的更高级接口中。
ostrstream
的典型实现仅包含一个非派生数据成员:类型为 std::strstreambuf 的对象。
目录 |
[编辑] 注释
在任何调用 str() 之后,需要调用 freeze(false) 以允许析构函数在必要时释放缓冲区。
在任何调用 str() 之前,该调用将结果用作 C 字符串,缓冲区必须以 null 结尾,通常使用 std::ends。
ostrstream
自 C++98 以来已被弃用,自 C++26 以来已被移除。std::ostringstream, std::ospanstream(自 C++23 起) 和 boost::iostreams::array_sink
是推荐的替代品。
[编辑] 成员函数
构造一个 ostrstream 对象,可以选择性地分配缓冲区(公共成员函数) | |
[虚拟] |
析构一个 ostrstream 对象,可以选择性地释放缓冲区(虚拟公共成员函数) |
获取指向关联的 strstreambuf 的指针(公共成员函数) | |
访问输出缓冲区 (公共成员函数) | |
禁用/启用自动重新分配 (公共成员函数) | |
获取已写入的字符数 (公共成员函数) |
继承自 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> 的公共成员函数) | |
rdbuf 管理关联的流缓冲区 | |
管理绑定的流 ( 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 的公共成员函数) | |
区域设置 | |
imbue 设置区域设置 | |
返回当前区域设置 ( std::ios_base 的公共成员函数) | |
内部可扩展数组 | |
[静态] |
返回一个程序范围内的唯一整数,该整数可以安全地用作 pword() 和 iword() 的索引 ( std::ios_base 的公共静态成员函数) |
如果需要,调整私有存储的大小,并访问给定索引处的 long 元素 ( std::ios_base 的公共成员函数) | |
如果需要,调整私有存储的大小,并访问给定索引处的 void* 元素 ( std::ios_base 的公共成员函数) | |
杂项 | |
注册事件回调函数 ( std::ios_base 的公共成员函数) | |
[静态] |
设置 C++ 和 C I/O 库是否可互操作 ( std::ios_base 的公共静态成员函数) |
成员类 | |
流异常 ( std::ios_base 的公共成员类) | |
初始化标准流对象 ( std::ios_base 的公共成员类) |
成员类型和常量 | |||||||||||||||||||||||||||||||||||||||
类型 | 解释 | ||||||||||||||||||||||||||||||||||||||
流打开模式类型 还定义了以下常量
(typedef) | |||||||||||||||||||||||||||||||||||||||
格式化标志类型 还定义了以下常量
(typedef) | |||||||||||||||||||||||||||||||||||||||
流状态类型 还定义了以下常量
(typedef) | |||||||||||||||||||||||||||||||||||||||
查找方向类型 还定义了以下常量
(typedef) | |||||||||||||||||||||||||||||||||||||||
指定事件类型 (enum) | |||||||||||||||||||||||||||||||||||||||
回调函数类型 (typedef) |