Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
sender.php
1<?
2
4
15class Sender extends \Protobuf\AbstractMessage
16{
17
21 protected $unknownFieldSet = null;
22
26 protected $extensions = null;
27
33 protected $type = null;
34
40 protected $id = null;
41
47 public function hasType()
48 {
49 return $this->type !== null;
50 }
51
57 public function getType()
58 {
59 return $this->type;
60 }
61
67 public function setType(\Bitrix\Pull\Protobuf\SenderType $value = null)
68 {
69 $this->type = $value;
70 }
71
77 public function hasId()
78 {
79 return $this->id !== null;
80 }
81
87 public function getId()
88 {
89 return $this->id;
90 }
91
97 public function setId($value = null)
98 {
99 if ($value !== null && ! $value instanceof \Protobuf\Stream) {
100 $value = \Protobuf\Stream::wrap($value);
101 }
102
103 $this->id = $value;
104 }
105
109 public function extensions()
110 {
111 if ( $this->extensions !== null) {
112 return $this->extensions;
113 }
114
115 return $this->extensions = new \Protobuf\Extension\ExtensionFieldMap(__CLASS__);
116 }
117
121 public function unknownFieldSet()
122 {
124 }
125
129 public static function fromStream($stream, \Protobuf\Configuration $configuration = null)
130 {
131 return new self($stream, $configuration);
132 }
133
137 public static function fromArray(array $values)
138 {
139 $message = new self();
140 $values = array_merge([
141 'type' => null,
142 'id' => null
143 ], $values);
144
145 $message->setType($values['type']);
146 $message->setId($values['id']);
147
148 return $message;
149 }
150
154 public static function descriptor()
155 {
156 return \google\protobuf\DescriptorProto::fromArray([
157 'name' => 'Sender',
158 'field' => [
159 \google\protobuf\FieldDescriptorProto::fromArray([
160 'number' => 1,
161 'name' => 'type',
162 'type' => \google\protobuf\FieldDescriptorProto\Type::TYPE_ENUM(),
163 'label' => \google\protobuf\FieldDescriptorProto\Label::LABEL_OPTIONAL(),
164 'type_name' => '.SenderType'
165 ]),
166 \google\protobuf\FieldDescriptorProto::fromArray([
167 'number' => 2,
168 'name' => 'id',
169 'type' => \google\protobuf\FieldDescriptorProto\Type::TYPE_BYTES(),
170 'label' => \google\protobuf\FieldDescriptorProto\Label::LABEL_OPTIONAL()
171 ]),
172 ],
173 ]);
174 }
175
179 public function toStream(\Protobuf\Configuration $configuration = null)
180 {
181 $config = $configuration ?: \Protobuf\Configuration::getInstance();
182 $context = $config->createWriteContext();
183 $stream = $context->getStream();
184
185 $this->writeTo($context);
186 $stream->seek(0);
187
188 return $stream;
189 }
190
194 public function writeTo(\Protobuf\WriteContext $context)
195 {
196 $stream = $context->getStream();
197 $writer = $context->getWriter();
198 $sizeContext = $context->getComputeSizeContext();
199
200 if ($this->type !== null) {
201 $writer->writeVarint($stream, 8);
202 $writer->writeVarint($stream, $this->type->value());
203 }
204
205 if ($this->id !== null) {
206 $writer->writeVarint($stream, 18);
207 $writer->writeByteStream($stream, $this->id);
208 }
209
210 if ($this->extensions !== null) {
211 $this->extensions->writeTo($context);
212 }
213
214 return $stream;
215 }
216
220 public function readFrom(\Protobuf\ReadContext $context)
221 {
222 $reader = $context->getReader();
223 $length = $context->getLength();
224 $stream = $context->getStream();
225
226 $limit = ($length !== null)
227 ? ($stream->tell() + $length)
228 : null;
229
230 while ($limit === null || $stream->tell() < $limit) {
231
232 if ($stream->eof()) {
233 break;
234 }
235
236 $key = $reader->readVarint($stream);
237 $wire = \Protobuf\WireFormat::getTagWireType($key);
238 $tag = \Protobuf\WireFormat::getTagFieldNumber($key);
239
240 if ($stream->eof()) {
241 break;
242 }
243
244 if ($tag === 1) {
245 \Protobuf\WireFormat::assertWireType($wire, 14);
246
247 $this->type = \Bitrix\Pull\Protobuf\SenderType::valueOf($reader->readVarint($stream));
248
249 continue;
250 }
251
252 if ($tag === 2) {
253 \Protobuf\WireFormat::assertWireType($wire, 12);
254
255 $this->id = $reader->readByteStream($stream);
256
257 continue;
258 }
259
260 $extensions = $context->getExtensionRegistry();
261 $extension = $extensions ? $extensions->findByNumber(__CLASS__, $tag) : null;
262
263 if ($extension !== null) {
264 $this->extensions()->add($extension, $extension->readFrom($context, $wire));
265
266 continue;
267 }
268
269 if ($this->unknownFieldSet === null) {
270 $this->unknownFieldSet = new \Protobuf\UnknownFieldSet();
271 }
272
273 $data = $reader->readUnknown($stream, $wire);
274 $unknown = new \Protobuf\Unknown($tag, $wire, $data);
275
276 $this->unknownFieldSet->add($unknown);
277
278 }
279 }
280
284 public function serializedSize(\Protobuf\ComputeSizeContext $context)
285 {
286 $calculator = $context->getSizeCalculator();
287 $size = 0;
288
289 if ($this->type !== null) {
290 $size += 1;
291 $size += $calculator->computeVarintSize($this->type->value());
292 }
293
294 if ($this->id !== null) {
295 $size += 1;
296 $size += $calculator->computeByteStreamSize($this->id);
297 }
298
299 if ($this->extensions !== null) {
300 $size += $this->extensions->serializedSize($context);
301 }
302
303 return $size;
304 }
305
309 public function clear()
310 {
311 $this->type = null;
312 $this->id = null;
313 }
314
318 public function merge(\Protobuf\Message $message)
319 {
320 if ( ! $message instanceof \Bitrix\Pull\Protobuf\Sender) {
321 throw new \InvalidArgumentException(sprintf('Argument 1 passed to %s must be a %s, %s given', __METHOD__, __CLASS__, get_class($message)));
322 }
323
324 $this->type = ($message->type !== null) ? $message->type : $this->type;
325 $this->id = ($message->id !== null) ? $message->id : $this->id;
326 }
327
328
329}
330
writeTo(\Protobuf\WriteContext $context)
Definition sender.php:194
toStream(\Protobuf\Configuration $configuration=null)
Definition sender.php:179
serializedSize(\Protobuf\ComputeSizeContext $context)
Definition sender.php:284
merge(\Protobuf\Message $message)
Definition sender.php:318
static fromStream($stream, \Protobuf\Configuration $configuration=null)
Definition sender.php:129
static fromArray(array $values)
Definition sender.php:137
readFrom(\Protobuf\ReadContext $context)
Definition sender.php:220
setType(\Bitrix\Pull\Protobuf\SenderType $value=null)
Definition sender.php:67