代码之家  ›  专栏  ›  技术社区  ›  piotr

链接C++流

  •  2
  • piotr  · 技术社区  · 17 年前

    我正在考虑“链接”两个C++ iOnFi串流,以过滤输入两次。我正在使用gzstreams读取zlib压缩文件,我正在考虑编写一个从流读取并执行编码转换的流。也许通过传递一个打开的流作为构造函数参数。。。你认为如何才能最好地实现这一点?

    1 回复  |  直到 17 年前
        1
  •  6
  •   Eugene Yokota    17 年前

    我没用过这个,但是boost的 filtering_stream 也许会有帮助。

    a mailing list post 具有 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