std:: basic_ostringstream
|
定义于头文件
<sstream>
|
||
|
template
<
class
CharT,
|
||
类模板
std::basic_ostringstream
实现了基于字符串流的输出操作。它有效地存储了一个
std::basic_string
实例并对其执行输出操作。
在底层,该类本质上将 std::basic_stringbuf 的原始字符串设备实现封装到 std::basic_ostream 的高级接口中。同时提供了访问 std::basic_stringbuf 独有成员函数的完整接口。
继承关系图
提供了多种常见字符类型的类型定义:
|
定义于头文件
<sstream>
|
|
| 类型 | 定义 |
std::ostringstream
|
std :: basic_ostringstream < char > |
std::wostringstream
|
std :: basic_ostringstream < wchar_t > |
目录 |
成员类型
| 成员类型 | 定义 |
char_type
|
CharT
|
traits_type
|
Traits
;若
Traits::char_type
不是
CharT
则程序非良构。
|
int_type
|
Traits::int_type
|
pos_type
|
Traits::pos_type
|
off_type
|
Traits::off_type
|
allocator_type
|
Allocator
|
仅用于阐述的成员
| 名称 | 定义 |
sb
|
用作底层缓冲区的
std::
basic_stringbuf
<
CharT, Traits, Allocator
>
( 仅用于说明的成员对象* ) |
成员函数
|
构造字符串流
(公开成员函数) |
|
|
(C++11)
|
移动字符串流
(公开成员函数) |
|
(C++11)
|
交换两个字符串流
(公开成员函数) |
|
返回底层原始字符串设备对象
(公开成员函数) |
|
字符串操作 |
|
|
获取或设置底层字符串设备对象的内容
(公开成员函数) |
|
|
(C++20)
|
获取底层字符串设备对象内容的视图
(公开成员函数) |
非成员函数
|
特化
std::swap
算法
(函数模板) |
继承自 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
的公开成员类)
|
|
成员类型与常量 |
|||||||||||||||
| 类型 | 说明 | ||||||||||||||
|
流打开模式类型
同时定义以下常量:
|
|||||||||||||||