Inheritance diagram for code::ProgressiveReader:
CompressedFileReader
Public Member Functions | |
ProgressiveReader (const URL &url) | |
virtual | ~ProgressiveReader () |
virtual bool | readNext (Buffer *dataBuf, size_t *bytes_read)=0 |
Progressive readers, on successive calls to this method will read further and further into the file. | |
Static Public Member Functions | |
static SmartPtr< ProgressiveReader > | getReader (const URL &url) |
return a ProgressiveReader that can handle this file. | |
Protected Attributes | |
URL | url |
code::ProgressiveReader::ProgressiveReader | ( | const URL & | url | ) |
virtual code::ProgressiveReader::~ProgressiveReader | ( | ) | [inline, virtual] |
static SmartPtr<ProgressiveReader> code::ProgressiveReader::getReader | ( | const URL & | url | ) | [static] |
return a ProgressiveReader that can handle this file.
Currently, the implementation assumes that if a file is compressed, it should be read using the CompleteFileReader else using the ProgressiveFileReader.
virtual bool code::ProgressiveReader::readNext | ( | Buffer * | dataBuf, | |
size_t * | bytes_read | |||
) | [pure virtual] |
Progressive readers, on successive calls to this method will read further and further into the file.
dataBuf | the Buffer to be modified with this method call dataBuf should be initialized to a reasonable size e.g: 1MB | |
bytes_read | will be filled in with the number of bytes of dataBuf that have been filled in. |
size_t tot_bytes = 0;
read the file ... bool complete = false; do { read bytes size_t bytes_read = 0; complete = reader->readNext( &dataBuf , &bytes_read );
notify handlers if ( bytes_read > 0 ){ do something with the data }
update running total tot_bytes += bytes_read; } while ( !complete ); } do something with tot_bytes
Note that if the file is being filled in (in real-time), even if the readNext returns complete on one call, a subsequent call may return valid data (more data may have arrived in the intermediate time). Knowledge of when the file is complete is external, such as through knowing the file format.
Implemented in code::ProgressiveFileReader, and code::CompleteFileReader.
URL code::ProgressiveReader::url [protected] |