Logo Search packages:      
Sourcecode: djvulibre version File versions

void DjVuFile::init ( const GURL url,
GP< DjVuPort port = 0 

Initializes a DjVuFile# object. As you can notice, the data is not directly passed to this function. The DjVuFile# will ask for it through the {DjVuPort} mechanism before the constructor finishes. If the data is stored locally on the hard disk then the pointer to {DjVuPort} may be set to ZERO#, which will make DjVuFile# read all data from the hard disk and report all errors to stderr#.

{ Note}. If the file includes (by means of INCL# chunks) other files then you should be ready to {enumerate} Reply to requests {DjVuPort::id_to_url}() issued to translate IDs (used in INCL# chunks) to absolute URLs. Usually, when the file is created by {DjVuDocument} this job is done by it. If you construct such a file manually, be prepared to do the ID to URL translation Provide data for all included files. {enumerate}

url The URL assigned to this file. It will be used when the DjVuFile# asks for data.
port All communication between DjVuFile::s and {DjVuDocument}s is done through the {DjVuPort} mechanism. If the {url} is not local or the data does not reside on the hard disk, the {port} parameter must not be ZERO#. If the {port} is ZERO# then DjVuFile# will create an internal instance of {DjVuSimplePort} for accessing local files and reporting errors. It can later be disabled by means of {disable_standard_port}() function.

Definition at line 224 of file DjVuFile.cpp.

References DjVuPortcaster::add_route(), DataPool::create(), file_size, GPEnabled::get_count(), DjVuPort::get_portcaster(), GURL::get_string(), GURL::is_empty(), and DjVuPortcaster::request_data().

  DEBUG_MSG("DjVuFile::init(): url='" << xurl << "'\n");
  if (initialized)
    G_THROW( ERR_MSG("DjVuFile.2nd_init") );
  if (!get_count())
    G_THROW( ERR_MSG("DjVuFile.not_secured") );
  if (xurl.is_empty())
    G_THROW( ERR_MSG("DjVuFile.empty_URL") );
  url = xurl;
  DEBUG_MSG("DjVuFile::DjVuFile(): url is "<<(const char *)url<<"\n");
  DjVuPortcaster * pcaster=get_portcaster();
  // We need it 'cause we're waiting for our own termination in stop_decode()
  pcaster->add_route(this, this);
  if (!port)
    port = simple_port = new DjVuSimplePort();
  pcaster->add_route(this, port);
  // Set it here because trigger will call other DjVuFile's functions
  if (!(data_pool=DataPool::create(pcaster->request_data(this, url))))
    G_THROW( ERR_MSG("DjVuFile.no_data") "\t"+url.get_string());
  data_pool->add_trigger(-1, static_trigger_cb, this);

Generated by  Doxygen 1.6.0   Back to index