Example #1
0
 /**
  * Read message from reader
  *
  * @param IO_Reader_Interface $reader
  */
 public function read(PhpBuf_IO_Reader_Interface $reader)
 {
     try {
         while ($reader->getPosition() < $reader->getLength()) {
             $fieldClass = $this->readFieldFromHeader($reader);
             $fieldClass->read($reader);
         }
     } catch (PhpBuf_IO_Exception $e) {
         return;
     }
 }
Example #2
0
 /**
  * Decode varint encoded string from PhpBuf_IO_Writer_Interface
  *
  * @param PhpBuf_IO_Reader_Interface $value
  * @return integer
  */
 public static function decodeFromReader(PhpBuf_IO_Reader_Interface $reader)
 {
     $continue = true;
     $result = '';
     while ($continue) {
         $byte = unpack('C', $reader->getByte());
         $bin = sprintf('%b', $byte[1]);
         if (strlen($bin) < 8) {
             $continue = false;
         }
         $bin = str_pad($bin, 8, '0', STR_PAD_LEFT);
         $bin7bit = substr($bin, 1, 7);
         $result = $bin7bit . $result;
     }
     return bindec($result);
 }
Example #3
0
 /**
  * Read the message in disregard of unknown fields
  *
  * @param IO_Reader_Interface $reader
  */
 protected function laxRead(PhpBuf_IO_Reader_Interface $reader)
 {
     while ($reader->getPosition() < $reader->getLength()) {
         try {
             $fieldClass = $this->readFieldFromHeader($reader);
             $fieldClass->read($reader);
         } catch (PhpBuf_Field_NotFoundException $e) {
         }
     }
 }