On Sunday, November 16, 2014 5:34:28 PM UTC-5, Öö Tiib wrote:
> > I'd like to determine the size of the istream object before extraction with
> > rdbuf(). How can I achieve this.
>
> You can't. There can be 'istream' whose size is not constant. For example
> it can be some fifo or pipe that other application is writing into from
> other side. So if the size matters then you have to read block by block.
> At positive side '.read()' (or '.readsome()') and '.write()' cycles are
> usually better performing than those copies.
Thanks a lot. I switched over to usignt the read method
unsigned int const MAX_SIZE_SUPPORTED ( 10485760 );
typedef boost::shared_array < char > BOOST_SHARED_CHAR_ARRAY ;
BOOST_SHARED_CHAR_ARRAY ptrBase64Data ;
ptrBase64Data.reset ( new char [ MAX_SIZE_SUPPORTED ] ) ;
std::istream &stream = readerObj.stream () ;
unsigned int offset ( 0 );
unsigned int const payload ( 1048576 );
do {
std::streamsize const xxx = stream.read
( &ptrBase64Data [ offset ], payload ).gcount() ;
offset += xxx ;
//to offset against MAX_SIZE_SUPPORTED so we don't crash
} while ( !stream.good() ) ;
Mark