boost iostreams

This is a discussion on boost iostreams within the C++ Programming forums, part of the General Programming Boards category; Hello Is there any way to reuse filtering_istream object after it has been used.. For instance: Code: boost::iostreams::filtering_istream filter_stream; boost::iostreams::file_source ...

  1. #1
    l2u
    l2u is offline
    Registered User
    Join Date
    May 2006
    Posts
    630

    boost iostreams

    Hello

    Is there any way to reuse filtering_istream object after it has been used..

    For instance:

    Code:
    boost::iostreams::filtering_istream   filter_stream;
    boost::iostreams::file_source 	file_source("somefile");
    some_filter 				some_filter_object;
    
    filter_stream.push(boost::ref(some_filter_object));
    filter_stream.push(boost::ref(file_source));
    
    
    //do read and some stuff
    //..
    
    boost::iostreams::file_source 		file_source2("somefile2");
    
    filter_stream.empty();
    
    filter_stream.push(boost::ref(some_filter_object));
    filter_stream.push(boost::ref(file_source2));
    
    //read somefile2
    Is this possible? The code above doesnt work..

    I want just want to reuse filter_stream (filtering_istream) object so that I could read data from another file..

    Thanks a lot for help

  2. #2
    (?<!re)tired Mario F.'s Avatar
    Join Date
    May 2006
    Location
    Portugal
    Posts
    7,403
    I never used this one. However a quick check over the library documentation revealed:

    filtering_istream.reset() as a likely candidate and filter_stream.empty() not being what you think, but instead a member function that returns true if the filtering chain is empty.
    The programmer’s wife tells him: “Run to the store and pick up a loaf of bread. If they have eggs, get a dozen.”
    The programmer comes home with 12 loaves of bread.


    Originally Posted by brewbuck:
    Reimplementing a large system in another language to get a 25% performance boost is nonsense. It would be cheaper to just get a computer which is 25% faster.

  3. #3
    l2u
    l2u is offline
    Registered User
    Join Date
    May 2006
    Posts
    630
    Thanks Mario! .reset() does what I need!

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. boost iostreams is_open()
    By l2u in forum C++ Programming
    Replies: 0
    Last Post: 02-21-2008, 09:00 AM
  2. Boost Auto-Linking
    By Tonto in forum C++ Programming
    Replies: 5
    Last Post: 12-30-2007, 05:11 AM
  3. boost iostreams and compression
    By l2u in forum C++ Programming
    Replies: 2
    Last Post: 05-04-2007, 06:11 AM
  4. building boost iostreams
    By l2u in forum C++ Programming
    Replies: 3
    Last Post: 04-14-2007, 02:29 PM
  5. Integrating Boost with STLPort
    By Mario F. in forum Tech Board
    Replies: 1
    Last Post: 11-11-2006, 05:49 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21