|
Boost Users : |
Subject: Re: [Boost-users] return type of boost::iostreams::stream<T>::read()
From: Eric MALENFANT (Eric.Malenfant_at_[hidden])
Date: 2008-10-14 09:47:29
Struebing, Axel, le-tex [axel.struebing_at_[hidden]]:
> Reading the documentation about boost::iostreams library I could not
> find the information which return type the boost::iostreams::stream's
> class is giving me calling read().
>From the documentation, a boost::iostreams::stream derives from an std::basic_[i|o]stream, depending on the model of its underlying Device. In your example, the device is a Source, so I guess that the stream derives from std::basic_istream, whose read(char*, streamsize) method returns a basic_istream, not a streamsize.
The library offers the "streamsize read(stream, char*, streamsize)" function template. Using it in your example yould give something like (not tested):
#include <boost/iostreams/stream.hpp>
#include <boost/iostreams/device/file.hpp>
#include <boost/iostreams/operations.hpp>
int main(void){
namespace bio = boost::iostreams;
bio::stream<bio::file_source> istr(std::string("in.pdf"));
char buffer[10];
std::streamsize i = bio::read(istr,buffer,10);
return 0;
}
HTH,
Éric Malenfant
---------------------------------------------
Two wrongs don't make a right but three rights make a left.
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