Logo Search packages:      
Sourcecode: djvulibre version File versions  Download package

size_t ByteStream::Static::read ( void *  buffer,
size_t  size 
) [virtual]

Reads data from a ByteStream. This function {must} be implemented by each subclass of ByteStream#. At most size# bytes are read from the ByteStream and stored in the memory area pointed to by buffer#. Function read# returns immediately if size# is zero. The actual number of bytes read is returned. Function read# returns a number of bytes smaller than size# if the end-of-file mark is reached before filling the buffer. Subsequent invocations will always return value #0#. Function read# may also return a value greater than zero but smaller than size# for internal reasons. Programs must be ready to handle these cases or use function {readall}. Exception {GException} is thrown with a plain text error message whenever an error occurs.

Reimplemented from ByteStream.

Definition at line 953 of file ByteStream.cpp.

  int nsz = (int)sz;
  if (nsz > bsize - where)
    nsz = bsize - where;
  if (nsz <= 0)
    return 0;
  memcpy(buffer, data+where, nsz);
  where += nsz;
  return nsz;

Generated by  Doxygen 1.6.0   Back to index