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

void GIFFManager::add_chunk ( GUTF8String  name,
const TArray< char > &  data 

If {name}={name1}.{name2} where {name2} doesn't contain dots, then addChunk()# will create plain chunk with name {name2} with data {buffer} of size {length} and will add it to chunk {name1} in the same way as addChunk(name, chunk, pos)# function would do it. The pos# in this case is either #-1# (append) or is extracted from between brackets if the {name} ends with them.

{ Examples:} {verbatim} ;; To insert INCL chunk at position 2 (make it 3rd) m.addChunk("INCL[2]", data, length); ;; To append chunk BG44 to 2nd DjVu file inside DjVm archive: m.addChunk(".DJVM.DJVU[1].BG44", data, length); {verbatim}

Definition at line 416 of file GIFFManager.cpp.

References add_chunk(), GIFFChunk::create(), GBaseString::length(), GBaseString::rsearch(), GBaseString::search(), GUTF8String::substr(), and GBaseString::toInt().

  DEBUG_MSG("GIFFManager::add_chunk(): adding plain chunk with name='" << name << "'\n");

  GUTF8String chunk_name;
  const int lastdot=name.rsearch('.');
  if(lastdot < 0)
    chunk_name=name.substr(lastdot+1,(unsigned int)-1);

  int pos=-1;
  const int obracket=chunk_name.search('[');
  if (obracket >= 0)
    const int cbracket=chunk_name.search(']',obracket+1);
    if (cbracket < 0)
      G_THROW( ERR_MSG("GIFFManager.unmatched") );
    if (name.length() > (unsigned int)(cbracket+1))
      G_THROW( ERR_MSG("GIFFManager.garbage") );
//    pos=atoi((const char *)chunk_name.substr(obracket+1,cbracket-obracket-1));
    pos = chunk_name.substr(obracket+1,cbracket-obracket-1).toInt();
  DEBUG_MSG("Creating new chunk with name " << chunk_name << "\n");
  GP<GIFFChunk> chunk;
  chunk=GIFFChunk::create(chunk_name, data);
  add_chunk(name, chunk, pos);

Generated by  Doxygen 1.6.0   Back to index