Пример #1
0
 /**
  * @ignore
  */
 private static function parseFieldFromStreamNoTag($input, $field, &$value)
 {
     switch ($field->getType()) {
         case GPBType::DOUBLE:
             if (!GPBWire::readDouble($input, $value)) {
                 return false;
             }
             break;
         case GPBType::FLOAT:
             if (!GPBWire::readFloat($input, $value)) {
                 return false;
             }
             break;
         case GPBType::INT64:
             if (!GPBWire::readInt64($input, $value)) {
                 return false;
             }
             break;
         case GPBType::UINT64:
             if (!GPBWire::readUint64($input, $value)) {
                 return false;
             }
             break;
         case GPBType::INT32:
             if (!GPBWire::readInt32($input, $value)) {
                 return false;
             }
             break;
         case GPBType::FIXED64:
             if (!GPBWire::readFixed64($input, $value)) {
                 return false;
             }
             break;
         case GPBType::FIXED32:
             if (!GPBWire::readFixed32($input, $value)) {
                 return false;
             }
             break;
         case GPBType::BOOL:
             if (!GPBWire::readBool($input, $value)) {
                 return false;
             }
             break;
         case GPBType::STRING:
             // TODO(teboring): Add utf-8 check.
             if (!GPBWire::readString($input, $value)) {
                 return false;
             }
             break;
         case GPBType::GROUP:
             echo "GROUP\n";
             trigger_error("Not implemented.", E_ERROR);
             break;
         case GPBType::MESSAGE:
             if ($field->isMap()) {
                 $value = new MapEntry($field->getMessageType());
             } else {
                 $klass = $field->getMessageType()->getClass();
                 $value = new $klass();
             }
             if (!GPBWire::readMessage($input, $value)) {
                 return false;
             }
             break;
         case GPBType::BYTES:
             if (!GPBWire::readString($input, $value)) {
                 return false;
             }
             break;
         case GPBType::UINT32:
             if (!GPBWire::readUint32($input, $value)) {
                 return false;
             }
             break;
         case GPBType::ENUM:
             // TODO(teboring): Check unknown enum value.
             if (!GPBWire::readInt32($input, $value)) {
                 return false;
             }
             break;
         case GPBType::SFIXED32:
             if (!GPBWire::readSfixed32($input, $value)) {
                 return false;
             }
             break;
         case GPBType::SFIXED64:
             if (!GPBWire::readSfixed64($input, $value)) {
                 return false;
             }
             break;
         case GPBType::SINT32:
             if (!GPBWire::readSint32($input, $value)) {
                 return false;
             }
             break;
         case GPBType::SINT64:
             if (!GPBWire::readSint64($input, $value)) {
                 return false;
             }
             break;
         default:
             user_error("Unsupported type.");
             return false;
     }
     return true;
 }