Logo Search packages:      
Sourcecode: sam2p version File versions

void Rule::writeTTM ( Filter::VerbatimE &  outve,
GenBuffer::Writable outpal,
GenBuffer::Writable outstream,
MiniPS::Array *  chunkArray,
Rule::OutputRule *  or_,
Image::SampledInfo *  sf,
stream_writer_t  stream_writer,
char const *const *  strings = (char**)NULLP 
) [static]

Doesn't invoke MiniPS::delete0(chunkArray);

by pts@fazekas.hu at Mon Apr 15 22:31:03 CEST 2002

Definition at line 995 of file rule.cpp.

References SimBuffer::Flat::getLength(), Error::sev(), GenBuffer::Writable::write_num(), and writeTTE().

Referenced by writeTTT().

                           {
  static const unsigned MAXLEN=64;
  /* Imp: use heap instead of stack space */
  slen_t offsets[MAXLEN+1]; /* 260 bytes stack */
  SimBuffer::B chunks[MAXLEN]; /* <=1024 bytes stack; default constructor */
  MiniPS::VALUE *chunk;
  param_assert(chunkArray!=NULLP);
  // param_assert(chunkArray->getLength()<=MAXLEN);
  if (chunkArray->getLength()>(int)MAXLEN) Error::sev(Error::EERROR) << "writeTTM: TTM too long" << (Error*)0;
  GenBuffer::Writable& out=outve.getOut();
  MiniPS::ii_t i, ii;
  for (chunkArray->getFirst(chunk), i=0; chunk!=NULLP; chunkArray->getNext(chunk), i++) {
    if (MiniPS::getType(*chunk)==MiniPS::T_ARRAY) {
      outve.setOut(chunks[i]);
      writeTTM(outve, outpal, outstream, MiniPS::RARRAY(*chunk), or_, sf, stream_writer, strings);
    }
  }
  for (chunkArray->getFirst(chunk), offsets[i=0]=0; chunk!=NULLP; chunkArray->getNext(chunk), i++) {
    switch (MiniPS::getType(*chunk)) {
     case MiniPS::T_ARRAY:
      break;
     case MiniPS::T_STRING: /* always null-terminated */
      outve.setOut(chunks[i]);
      writeTTE(outve, outpal, outstream, MiniPS::RSTRING(*chunk)->begin_(), or_, sf, stream_writer, strings);
      break;
     case MiniPS::T_INTEGER:
      if (0==(ii=MiniPS::int2ii(*chunk))) Error::sev(Error::EERROR) << "writeTTM: zero is an invalid chunk" << (Error*)0;
      if (ii>0) { /* an offset */
        if (ii>i) Error::sev(Error::EERROR) << "writeTTM: cannot predict chunk offset" << (Error*)0;
        if (MiniPS::T_ARRAY==MiniPS::getType(chunkArray->get(ii)))
               chunks[i].write_num(offsets[ii], 10); /* Dat: 10: 10 digits (for PDF xref table), not base 10 */
          else chunks[i] << offsets[ii];
      } else { /* a length */
        chunks[i] << chunks[-ii].getLength();
      }
      break;
     default:
      Error::sev(Error::EERROR) << "writeTTM: invalid chunk type: " << MiniPS::getTypeStr(MiniPS::getType(*chunk)) << (Error*)0;
    }
    offsets[i+1]=offsets[i]+chunks[i].getLength();
  } /* NEXT */
  outve.setOut(out);
  for (i=0; i<chunkArray->getLength(); i++) out << chunks[i];
  /* Imp: organize that chunks[.] gets freed earlier than this */
} /* Rule::writeTTM() */


Generated by  Doxygen 1.6.0   Back to index