/**
  * Reads whole (including chunk type) string block from stream.
  * Stream must be at the chunk type.
  */
 public static function read(IntReader $reader)
 {
     ReadUtil::readCheckType($reader, self::CHUNK_TYPE);
     $chunkSize = $reader->readInt();
     $stringCount = $reader->readInt();
     $styleOffsetCount = $reader->readInt();
     $reader->readInt();
     $stringsOffset = $reader->readInt();
     $stylesOffset = $reader->readInt();
     $block = new StringBlock();
     $block->m_stringOffsets = $reader->readIntArray($stringCount);
     if ($styleOffsetCount != 0) {
         $block->m_styleOffsets = $reader->readIntArray($styleOffsetCount);
     }
     $size = ($stylesOffset == 0 ? $chunkSize : $stylesOffset) - $stringsOffset;
     if ($size % 4 != 0) {
         throw new IOException("String data size is not multiple of 4 (" + size + ").");
     }
     $block->m_strings = $reader->readIntArray($size / 4);
     if ($stylesOffset != 0) {
         $size = $chunkSize - $stylesOffset;
         if ($size % 4 != 0) {
             throw new IOException("Style data size is not multiple of 4 (" + size + ").");
         }
         $block->m_styles = $reader->readIntArray($size / 4);
     }
     $block->s = array();
     for ($i = 0; $i != $block->getCount(); ++$i) {
         $block->s[$i] = $block->getRaw($i);
     }
     return block;
 }
 private function doStart()
 {
     ReadUtil::readCheckType($this->m_stream, self::AXML_CHUNK_TYPE);
     /*chunk size*/
     ReadUtil::readInt($this->m_stream);
     $this->m_strings = StringBlock::read(new IntReader($this->m_stream, true));
     ReadUtil::readCheckType($this->m_stream, self::RESOURCEIDS_CHUNK_TYPE);
     $chunkSize = ReadUtil::readInt($this->m_stream);
     if ($chunkSize < 8 || $chunkSize % 4 != 0) {
         throw new IOException("Invalid resource ids size (" + $chunkSize + ").");
     }
     $this->m_resourceIDs = ReadUtil::readIntArray($this->m_stream, $chunkSize / 4 - 2);
     $this->resetState();
 }