Inheritance diagram for code::CompleteFileReader:
Public Member Functions | |
CompleteFileReader (const URL &url) | |
virtual bool | readNext (Buffer *dataBuf, size_t *bytes_read) |
Progressive readers, on successive calls to this method will read further and further into the file. | |
virtual | ~CompleteFileReader () |
Static Public Member Functions | |
static SmartPtr< ProgressiveReader > | getReader (const URL &url) |
return a ProgressiveReader that can handle this file. | |
Protected Attributes | |
URL | url |
code::CompleteFileReader::CompleteFileReader | ( | const URL & | url | ) |
virtual code::CompleteFileReader::~CompleteFileReader | ( | ) | [inline, virtual] |
static SmartPtr<ProgressiveReader> code::ProgressiveReader::getReader | ( | const URL & | url | ) | [static, inherited] |
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::CompleteFileReader::readNext | ( | Buffer * | dataBuf, | |
size_t * | bytes_read | |||
) | [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.
Implements code::ProgressiveReader.
URL code::ProgressiveReader::url [protected, inherited] |