题
我在考虑“链接”。几个c ++ iostreams可以过滤两次输入。我正在使用gzstreams来读取zlib压缩文件,我正在考虑编写从流中读取并执行编码转换的流。也许通过传递一个打开的流作为构造函数参数......你怎么认为这可以做得最好?
解决方案
我没有用过这个但是提升的 filtering_stream 可能有所帮助。
作为一个例子,我找到了邮件列表帖子使用 indent.hpp ,它实现了缩进的输出过滤器输出:
boost::iostreams::filtering_ostream out;
indent_filter::push(out,2);
out.push(std::cout);
并像这样使用它:
out << "Hello Filter!\n"
<< indent_in
<< "this is\n"
<< "indented\n"
<< indent_out
<< "until here\n"
;
这将导致输出:
Hello Filter!
this is
indented
until here
不隶属于 StackOverflow