当前位置: 首页>>代码示例>>PHP>>正文


PHP Label::valueOf方法代码示例

本文整理汇总了PHP中google\protobuf\FieldDescriptorProto\Label::valueOf方法的典型用法代码示例。如果您正苦于以下问题:PHP Label::valueOf方法的具体用法?PHP Label::valueOf怎么用?PHP Label::valueOf使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在google\protobuf\FieldDescriptorProto\Label的用法示例。


在下文中一共展示了Label::valueOf方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: readFrom

 /**
  * {@inheritdoc}
  */
 public function readFrom(\Protobuf\ReadContext $context)
 {
     $reader = $context->getReader();
     $length = $context->getLength();
     $stream = $context->getStream();
     $limit = $length !== null ? $stream->tell() + $length : null;
     while ($limit === null || $stream->tell() < $limit) {
         if ($stream->eof()) {
             break;
         }
         $key = $reader->readVarint($stream);
         $wire = \Protobuf\WireFormat::getTagWireType($key);
         $tag = \Protobuf\WireFormat::getTagFieldNumber($key);
         if ($stream->eof()) {
             break;
         }
         if ($tag === 1) {
             \Protobuf\WireFormat::assertWireType($wire, 9);
             $this->name = $reader->readString($stream);
             continue;
         }
         if ($tag === 3) {
             \Protobuf\WireFormat::assertWireType($wire, 5);
             $this->number = $reader->readVarint($stream);
             continue;
         }
         if ($tag === 4) {
             \Protobuf\WireFormat::assertWireType($wire, 14);
             $this->label = \google\protobuf\FieldDescriptorProto\Label::valueOf($reader->readVarint($stream));
             continue;
         }
         if ($tag === 5) {
             \Protobuf\WireFormat::assertWireType($wire, 14);
             $this->type = \google\protobuf\FieldDescriptorProto\Type::valueOf($reader->readVarint($stream));
             continue;
         }
         if ($tag === 6) {
             \Protobuf\WireFormat::assertWireType($wire, 9);
             $this->type_name = $reader->readString($stream);
             continue;
         }
         if ($tag === 2) {
             \Protobuf\WireFormat::assertWireType($wire, 9);
             $this->extendee = $reader->readString($stream);
             continue;
         }
         if ($tag === 7) {
             \Protobuf\WireFormat::assertWireType($wire, 9);
             $this->default_value = $reader->readString($stream);
             continue;
         }
         if ($tag === 9) {
             \Protobuf\WireFormat::assertWireType($wire, 5);
             $this->oneof_index = $reader->readVarint($stream);
             continue;
         }
         if ($tag === 10) {
             \Protobuf\WireFormat::assertWireType($wire, 9);
             $this->json_name = $reader->readString($stream);
             continue;
         }
         if ($tag === 8) {
             \Protobuf\WireFormat::assertWireType($wire, 11);
             $innerSize = $reader->readVarint($stream);
             $innerMessage = new \google\protobuf\FieldOptions();
             $this->options = $innerMessage;
             $context->setLength($innerSize);
             $innerMessage->readFrom($context);
             $context->setLength($length);
             continue;
         }
         $extensions = $context->getExtensionRegistry();
         $extension = $extensions ? $extensions->findByNumber(__CLASS__, $tag) : null;
         if ($extension !== null) {
             $this->extensions()->add($extension, $extension->readFrom($context, $wire));
             continue;
         }
         if ($this->unknownFieldSet === null) {
             $this->unknownFieldSet = new \Protobuf\UnknownFieldSet();
         }
         $data = $reader->readUnknown($stream, $wire);
         $unknown = new \Protobuf\Unknown($tag, $wire, $data);
         $this->unknownFieldSet->add($unknown);
     }
 }
开发者ID:protobuf-php,项目名称:google-protobuf-proto,代码行数:88,代码来源:FieldDescriptorProto.php

示例2: createFieldDescriptorProto

 /**
  * @param integer $number
  * @param string  $name
  * @param integer $type
  * @param integer $label
  * @param string  $typeName
  * @param array   $values
  *
  * @return \google\protobuf\FieldDescriptorProto
  */
 protected function createFieldDescriptorProto($number, $name, $type, $label, $typeName = null, array $values = [])
 {
     $field = new FieldDescriptorProto();
     $options = isset($values['options']) ? $values['options'] : null;
     $field->setName($name);
     $field->setNumber($number);
     $field->setTypeName($typeName);
     $field->setType(FieldDescriptorProto\Type::valueOf($type));
     $field->setLabel(FieldDescriptorProto\Label::valueOf($label));
     if (isset($values['default'])) {
         $field->setDefaultValue($values['default']);
     }
     if ($options !== null) {
         $fieldOptions = new FieldOptions();
         if (isset($options['packed'])) {
             $fieldOptions->setPacked($options['packed']);
         }
         $field->setOptions($fieldOptions);
     }
     return $field;
 }
开发者ID:protobuf-php,项目名称:protobuf-plugin,代码行数:31,代码来源:TestCase.php


注:本文中的google\protobuf\FieldDescriptorProto\Label::valueOf方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。