コード例 #1
0
ファイル: Reader.php プロジェクト: swk/bluebox
 /**
  * Read an AMQP table, and return as a PHP array. keys are strings,
  * values are (type,value) tuples.
  */
 public function read_table()
 {
     $this->bitcount = $this->bits = 0;
     $tlen = $this->read_php_int();
     if ($tlen < 0) {
         throw new Exception("Table is longer than supported");
     }
     $table_data = new AMQP_Reader($this->rawread($tlen));
     $result = array();
     while ($table_data->tell() < $tlen) {
         $name = $table_data->read_shortstr();
         $ftype = $table_data->rawread(1);
         if ($ftype == 'S') {
             $val = $table_data->read_longstr();
         } else {
             if (ftype == 'I') {
                 $val = $table_data->read_signed_long();
             } else {
                 if ($ftype == 'D') {
                     $e = $table_data->read_octet();
                     $n = $table_data->read_signed_long();
                     $val = new AMQP_Wire_Decimal($n, $e);
                 } else {
                     if ($ftype == 'T') {
                         $val = $table_data->read_timestamp();
                     } else {
                         if ($ftype == 'F') {
                             $val = $table_data->read_table();
                             // recursion
                         } else {
                             error_log("Usupported table field type {$ftype}");
                             $val = NULL;
                         }
                     }
                 }
             }
         }
         $result[$name] = array($ftype, $val);
     }
     return $result;
 }