我正在考虑将几个c ++ iostreams“链接”在一起以过滤输入两次。我正在使用 gzstreams 读取 zlib 压缩文件,并且正在考虑编写一个从流中读取并执行编码转换的流。也许通过将打开的流作为构造函数参数传递...您认为如何最好地完成?
问问题
2410 次
1 回答
6
我没有使用过这个,但是 boost 的过滤流可能会有所帮助。
作为一个例子,我发现了一个带有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
于 2009-05-04T06:36:48.650 回答