我没有使用过这个,但是boost的filtering_stream可能有所帮助.
作为一个例子,我发现了一个带有indent.hpp 的邮件列表帖子,它实现了一个缩进输出的输出过滤器:
boost::iostreams::filtering_ostream out;
indent_filter::push(out,2);
out.push(std::cout);
Run Code Online (Sandbox Code Playgroud)
并像这样使用它:
out << "Hello Filter!\n"
<< indent_in
<< "this is\n"
<< "indented\n"
<< indent_out
<< "until here\n"
;
Run Code Online (Sandbox Code Playgroud)
这将导致输出:
Hello Filter!
this is
indented
until here
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2172 次 |
| 最近记录: |