C ++ threadchain

I was thinking of โ€œchainingโ€ a C ++ iostreams pair to filter the input twice. I use gzstreams to read zlib compressed files, and I was thinking of encoding a stream that reads from the stream and performs encoding conversions. Perhaps by passing an open thread as a constructor parameter ... What do you think this could best be done?

+2
source share
1 answer

I have not used this, but boost filtering_stream may help.

As an example, I found a mailing list with indent.hpp that implements an output filter that outputs indentation:

boost::iostreams::filtering_ostream out; 
indent_filter::push(out,2); 
out.push(std::cout); 

And use it like this:

out << "Hello Filter!\n" 
    << indent_in 
    << "this is\n" 
    << "indented\n" 
    << indent_out 
    << "until here\n" 
    ; 

:

Hello Filter! 
  this is 
  indented 
until here 
+6

Source: https://habr.com/ru/post/1721180/


All Articles