Example #1
0
 protected function readHeader(MemStream $s)
 {
     // check header
     $s->serial_buffer($hskp, 4);
     if ($hskp !== self::HEADER) {
         throw new \RuntimeException('Wrong packed sheets header, expected "' . self::HEADER . '"');
     }
     $s->serial_uint32($header_version);
     if ($header_version != self::HEADER_VERSION) {
         throw new \RuntimeException('Wrong packed sheets version, expected "' . self::HEADER_VERSION . '", got "' . $header_version . '"');
     }
     $s->serial_byte($this->compat);
     $s->serial_uint32($dependBlockSize);
     if ($this->skipDependBlock) {
         // skip dependency block
         $pos = $s->getPos();
         $s->seek($pos + $dependBlockSize);
     } else {
         // read dictionary
         $s->serial_uint32($nb);
         $s->serial_int_string($this->dictionnary, $nb);
         // read dependency data
         $this->dependencies = array();
         $s->serial_uint32($depSize);
         for ($i = 0; $i < $depSize; $i++) {
             $s->serial_uint32($sheetId);
             $s->serial_uint32($nb);
             $s->serial_uint32($this->dependencies[$sheetId], $nb);
         }
     }
 }
Example #2
0
 /**
  * {@inheritdoc}
  */
 public function serial(MemStream $s)
 {
     // string with <uint32> length counter
     $s->serial_string($this->name);
     if ($s->isReading()) {
         // read all remaining bytes from buffer
         $length = $s->getSize() - $s->getPos();
     } else {
         $length = strlen($this->payload);
     }
     $s->serial_buffer($this->payload, $length);
 }