file descriptor imitation - boost iostreams

Hi Boosters, I have a function with following interface: int gvRender (GVC_t *gvc, graph_t *g, char *format, FILE *out) but I don't want to store the output in temporary file but to compute everything in memory... (but to store the output to same malloced string and pass it to a display function). Boost is so powerful - so can I solve this problem somehow using boost (C++ doesn't doesn't provide tools to simulate file descriptors )? I know very little about boost iostream would it be helpful? -- Cheers, Michał Nowotka

Michał Nowotka wrote:
Hi Boosters,
I have a function with following interface:
int gvRender (GVC_t *gvc, graph_t *g, char *format, FILE *out)
but I don't want to store the output in temporary file but to compute everything in memory... (but to store the output to same malloced string and pass it to a display function). Boost is so powerful - so can I solve this problem somehow using boost (C++ doesn't doesn't provide tools to simulate file descriptors )? I know very little about boost iostream would it be helpful?
Not sure if it is what you want, but you could look at container_device_example.cpp in libs\iostreams\example For example we could do something like this to write a zipped and encrypted stream of data into a std::string ... io::filtering_ostream out; out.push( io::gzip_compressor() ); out.push( CryptFilter(key) ); std::string memString; out.push ( container_sink<std::string> (memString)); WriteStuff(out); // this writes stuff to the stream out.reset(); // flush it At this point the stuff is in the memString.

Hello, container_device_example.cpp in libs\iostreams\example uses <boost/iostreams/stream_facade.hpp> header but i can't find it anywhere in boost libs. How can I istall it? Cheers, Michał Nowotka

Michał Nowotka wrote:
Hello, container_device_example.cpp in libs\iostreams\example uses <boost/iostreams/stream_facade.hpp> header but i can't find it anywhere in boost libs. How can I istall it?
its just a header, but not an official part of the library as it is an example. So, just include the file in your project.

Unfortunately this didn't solved a problem... When I include <boost/iostreams/stream_facade.hpp> the output I get looks like this: /usr/include/boost/iostreams/detail/call_traits.hpp:20: error: redefinition of 'struct boost::iostreams::detail::param_type<T>' /usr/include/boost/iostreams/detail/param_type.hpp:20: error: previous definition of 'struct boost::iostreams::detail::param_type<T>' /usr/include/boost/iostreams/streambuf_facade.hpp:36: error: wrong number of template arguments (1, should be 2) /usr/include/boost/type_traits/is_convertible.hpp:409: error: provided for 'template<class From, class To> struct boost::is_convertible' /usr/include/boost/iostreams/streambuf_facade.hpp:38: error: template argument 1 is invalid /usr/include/boost/iostreams/streambuf_facade.hpp:38: error: expected unqualified-id before ',' token /usr/include/boost/iostreams/streambuf_facade.hpp:54: error: template argument 1 is invalid /usr/include/boost/iostreams/streambuf_facade.hpp:54: error: expected `>' before '::' token /usr/include/boost/iostreams/streambuf_facade.hpp:54: error: expected unqualified-id before ',' token /usr/include/boost/iostreams/stream_facade.hpp:28: error: expected nested-name-specifier before 'io_char' /usr/include/boost/iostreams/stream_facade.hpp:28: error: expected ';' before '<' token /usr/include/boost/iostreams/stream_facade.hpp:30: error: expected nested-name-specifier before 'io_category' /usr/include/boost/iostreams/stream_facade.hpp:30: error: expected ';' before '<' token /usr/include/boost/iostreams/stream_facade.hpp:34: error: 'mode' was not declared in this scope /usr/include/boost/iostreams/stream_facade.hpp:34: error: template argument 1 is invalid /usr/include/boost/iostreams/stream_facade.hpp:35: error: 'mode' was not declared in this scope /usr/include/boost/iostreams/stream_facade.hpp:35: error: template argument 1 is invalid /usr/include/boost/iostreams/stream_facade.hpp:36: error: template argument 1 is invalid /usr/include/boost/iostreams/stream_facade.hpp:36: error: template argument 2 is invalid /usr/include/boost/iostreams/stream_facade.hpp:37: error: 'char_type' was not declared in this scope /usr/include/boost/iostreams/stream_facade.hpp:37: error: template argument 1 is invalid /usr/include/boost/iostreams/stream_facade.hpp:38: error: 'mode' was not declared in this scope /usr/include/boost/iostreams/stream_facade.hpp:38: error: template argument 1 is invalid /usr/include/boost/iostreams/stream_facade.hpp:39: error: 'char_type' was not declared in this scope /usr/include/boost/iostreams/stream_facade.hpp:39: error: template argument 1 is invalid /usr/include/boost/iostreams/stream_facade.hpp:41: error: 'char_type' was not declared in this scope /usr/include/boost/iostreams/stream_facade.hpp:41: error: template argument 1 is invalid /usr/include/boost/iostreams/stream_facade.hpp:42: error: template argument 1 is invalid /usr/include/boost/iostreams/stream_facade.hpp:42: error: template argument 2 is invalid /usr/include/boost/iostreams/stream_facade.hpp:42: error: template argument 3 is invalid /usr/include/boost/iostreams/stream_facade.hpp:42: error: template argument 4 is invalid /usr/include/boost/iostreams/stream_facade.hpp:42: error: template argument 6 is invalid /usr/include/boost/iostreams/stream_facade.hpp:50: error: template argument 1 is invalid /usr/include/boost/iostreams/stream_facade.hpp:50: error: expected `>' before '::' token /usr/include/boost/iostreams/stream_facade.hpp:50: error: expected unqualified-id before ',' token /usr/include/boost/iostreams/stream_facade.hpp:91: error: template argument 1 is invalid /usr/include/boost/iostreams/stream_facade.hpp:91: error: expected `>' before '::' token /usr/include/boost/iostreams/stream_facade.hpp:91: error: expected unqualified-id before ',' token /usr/include/boost/iostreams/detail/call_traits.hpp:20: error: redefinition of 'struct boost::iostreams::detail::param_type<T>' /usr/include/boost/iostreams/detail/param_type.hpp:20: error: previous definition of 'struct boost::iostreams::detail::param_type<T>' /usr/include/boost/iostreams/streambuf_facade.hpp:36: error: wrong number of template arguments (1, should be 2) /usr/include/boost/type_traits/is_convertible.hpp:409: error: provided for 'template<class From, class To> struct boost::is_convertible' /usr/include/boost/iostreams/streambuf_facade.hpp:38: error: template argument 1 is invalid /usr/include/boost/iostreams/streambuf_facade.hpp:38: error: expected unqualified-id before ',' token /usr/include/boost/iostreams/streambuf_facade.hpp:54: error: template argument 1 is invalid /usr/include/boost/iostreams/streambuf_facade.hpp:54: error: expected `>' before '::' token /usr/include/boost/iostreams/streambuf_facade.hpp:54: error: expected unqualified-id before ',' token /usr/include/boost/iostreams/stream_facade.hpp:28: error: expected nested-name-specifier before 'io_char' /usr/include/boost/iostreams/stream_facade.hpp:28: error: expected ';' before '<' token /usr/include/boost/iostreams/stream_facade.hpp:30: error: expected nested-name-specifier before 'io_category' /usr/include/boost/iostreams/stream_facade.hpp:30: error: expected ';' before '<' token /usr/include/boost/iostreams/stream_facade.hpp:34: error: 'mode' was not declared in this scope /usr/include/boost/iostreams/stream_facade.hpp:34: error: template argument 1 is invalid /usr/include/boost/iostreams/stream_facade.hpp:35: error: 'mode' was not declared in this scope /usr/include/boost/iostreams/stream_facade.hpp:35: error: template argument 1 is invalid /usr/include/boost/iostreams/stream_facade.hpp:36: error: template argument 1 is invalid /usr/include/boost/iostreams/stream_facade.hpp:36: error: template argument 2 is invalid /usr/include/boost/iostreams/stream_facade.hpp:37: error: 'char_type' was not declared in this scope /usr/include/boost/iostreams/stream_facade.hpp:37: error: template argument 1 is invalid /usr/include/boost/iostreams/stream_facade.hpp:38: error: 'mode' was not declared in this scope /usr/include/boost/iostreams/stream_facade.hpp:38: error: template argument 1 is invalid /usr/include/boost/iostreams/stream_facade.hpp:39: error: 'char_type' was not declared in this scope /usr/include/boost/iostreams/stream_facade.hpp:39: error: template argument 1 is invalid /usr/include/boost/iostreams/stream_facade.hpp:41: error: 'char_type' was not declared in this scope /usr/include/boost/iostreams/stream_facade.hpp:41: error: template argument 1 is invalid /usr/include/boost/iostreams/stream_facade.hpp:42: error: template argument 1 is invalid /usr/include/boost/iostreams/stream_facade.hpp:42: error: template argument 2 is invalid /usr/include/boost/iostreams/stream_facade.hpp:42: error: template argument 3 is invalid /usr/include/boost/iostreams/stream_facade.hpp:42: error: template argument 4 is invalid /usr/include/boost/iostreams/stream_facade.hpp:42: error: template argument 6 is invalid /usr/include/boost/iostreams/stream_facade.hpp:50: error: template argument 1 is invalid /usr/include/boost/iostreams/stream_facade.hpp:50: error: expected `>' before '::' token /usr/include/boost/iostreams/stream_facade.hpp:50: error: expected unqualified-id before ',' token /usr/include/boost/iostreams/stream_facade.hpp:91: error: template argument 1 is invalid /usr/include/boost/iostreams/stream_facade.hpp:91: error: expected `>' before '::' token /usr/include/boost/iostreams/stream_facade.hpp:91: error: expected unqualified-id before ',' token And when I try something different and type: #include <boost/iostreams/filtering_stream.hpp> //... std::string result; boost::iostreams::filtering_ostream out(back_inserter(result)); //... gvRender(gvc,g,"png",out); then i get: ain_window.cpp:73: error: invalid conversion from 'void*' to 'FILE*' main_window.cpp:73: error: initializing argument 4 of 'int gvRender(GVC_t*, graph_t*, char*, FILE*)' Also trying this: #include <boost/iostreams/filtering_stream.hpp> //... std::string result; boost::iostreams::filtering_ostream out(back_inserter(result)); //... gvRender(gvc,g,"png",(FILE*) (out)); fails: main_window.cpp:73: error: invalid cast from type 'boost::iostreams::filtering_ostream' to type 'FILE*'

Micha? Nowotka wrote:
Unfortunately this didn't solved a problem... When I include <boost/iostreams/stream_facade.hpp> the output I get looks like this:
Sorry, I misread your original posting. I don't know what stream_facade.hpp is. but we are not alone, see: http://article.gmane.org/gmane.comp.lib.boost.user/29291

Ok, I've hound this library (by google code search :) ) but as i said in my previous message this is not what i'm looking for because it seems to work similar to filtering_ostream and generates many compilation errors.
participants (2)
-
eg
-
Michał Nowotka