Logo Search packages:      
Sourcecode: djvulibre version File versions

void DataPool::add_data ( const void *  buffer,
int  offset,
int  size 
)

Stores the specified block of data at the specified offset. Like the function above this one can also unblock readers waiting for data and engage trigger callbacks. The difference is that { this} function can store data anywhere.

{ Note:} After all the data has been added, it's necessary to call {set_eof}() to tell the DataPool# that nothing else is expected.

{ Note:} This function may not be called if the DataPool# has been connected to something.

Parameters:
buffer data to store
offset where to store the data
size length of the {buffer}

Definition at line 1026 of file DataPool.cpp.

References GURL::is_local_file_url().

{
   DEBUG_MSG("DataPool::add_data(): adding " << size << " bytes at pos=" <<
           offset << "...\n");
   DEBUG_MAKE_INDENT(3);

   if (furl.is_local_file_url() || pool)
      G_THROW( ERR_MSG("DataPool.add_data") );
   
      // Add data to the data storage
   {
      GCriticalSectionLock lock(&data_lock);
      if (offset>data->size())
      {
       char ch=0;
       data->seek(0, SEEK_END);
       for(int i=data->size();i<offset;i++)
          data->write(&ch, 1);
      } else
      {
       data->seek(offset, SEEK_SET);
       data->writall(buffer, size);
      }
   }

   added_data(offset, size);
}


Generated by  Doxygen 1.6.0   Back to index