Boost logo

Boost Users :

From: Ricardo Mayerhofer (maillistricardo_at_[hidden])
Date: 2007-10-30 14:45:51


Ops, sorry Michael, the example was inconsistent, the correct code is:
    copy( istream_iterator<string>(FileSource), istream_iterator<string>
(), back_inserter( m_StringVector ) )

Actually the class I use is not string, I just though it would make the
example simpler.
I use another streamable class which I save to a file and retrieve it
later. (I cannot use serialization in this case, because the format
matters, I mean, I have to save the class state in CSV format).

I tought something like this was possible reading the following topic
when the lib was being developed:

http://lists.boost.org/Archives/boost/2004/09/71455.php
> 2. Sources and sinks can be reused in cases where standard streams and
stream
> buffers are either unnecessary or are not the appropriate abstraction. For
> example, suppose you want to write the concatenation of three files to a
> string.
> You can do so like this:
>
> string s;
> boost::io::copy(
> concatenate(
> file_source("file1"),
> file_source("file2"),
> file_source("file3")
> ),
> back_insert_resource(s)
> );

Thanks.

Michael Linck escreveu:
> That copy writes from a Source to a Sink. Do you need a vector of
> Strings? Why not a StringStream. You might be able to use your copy on
> a FileSource and copy to a StringStream. Also your istream_iterator
> types look inconsistent.
>
> mike
>
> On Thu, 2007-10-25 at 09:11 -0700, Ricardo Mayerhofer wrote:
>
>> I mean copy of boost iostream:
>> http://www.boost.org/libs/iostreams/doc/index.html
>>
>> Ricardo
>>
>>
>
>
>>> If so, how do I?
>>>
>>> eg. with std copy:
>>> copy( istream_iterator<string>(FileSource),
>>> istream_iterator<FileSource> (),
>>> back_inserter( m_StringVector ) )
>>>
>>> Ricardo
>>>
>>> _______________________________________________
>>> Boost-users mailing list
>>> Boost-users_at_[hidden]
>>> http://lists.boost.org/mailman/listinfo.cgi/boost-users
>>>
>>>
>>> ____________________________________________________________________
>>>
>>> _______________________________________________
>>> Boost-users mailing list
>>> Boost-users_at_[hidden]
>>> http://lists.boost.org/mailman/listinfo.cgi/boost-users
>>>
>> _______________________________________________
>> Boost-users mailing list
>> Boost-users_at_[hidden]
>> http://lists.boost.org/mailman/listinfo.cgi/boost-users
>>
>
> _______________________________________________
> Boost-users mailing list
> Boost-users_at_[hidden]
> http://lists.boost.org/mailman/listinfo.cgi/boost-users
>
>


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net