Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
outgoingmessage.php
1<?
2
4
15class OutgoingMessage extends \Protobuf\AbstractMessage
16{
17
21 protected $unknownFieldSet = null;
22
26 protected $extensions = null;
27
33 protected $id = null;
34
40 protected $body = null;
41
47 protected $expiry = null;
48
54 protected $created = null;
55
61 protected $sender = null;
62
68 public function hasId()
69 {
70 return $this->id !== null;
71 }
72
78 public function getId()
79 {
80 return $this->id;
81 }
82
88 public function setId($value = null)
89 {
90 if ($value !== null && ! $value instanceof \Protobuf\Stream) {
91 $value = \Protobuf\Stream::wrap($value);
92 }
93
94 $this->id = $value;
95 }
96
102 public function hasBody()
103 {
104 return $this->body !== null;
105 }
106
112 public function getBody()
113 {
114 return $this->body;
115 }
116
122 public function setBody($value = null)
123 {
124 $this->body = $value;
125 }
126
132 public function hasExpiry()
133 {
134 return $this->expiry !== null;
135 }
136
142 public function getExpiry()
143 {
144 return $this->expiry;
145 }
146
152 public function setExpiry($value = null)
153 {
154 $this->expiry = $value;
155 }
156
162 public function hasCreated()
163 {
164 return $this->created !== null;
165 }
166
172 public function getCreated()
173 {
174 return $this->created;
175 }
176
182 public function setCreated($value = null)
183 {
184 $this->created = $value;
185 }
186
192 public function hasSender()
193 {
194 return $this->sender !== null;
195 }
196
202 public function getSender()
203 {
204 return $this->sender;
205 }
206
212 public function setSender(\Bitrix\Pull\Protobuf\Sender $value = null)
213 {
214 $this->sender = $value;
215 }
216
220 public function extensions()
221 {
222 if ( $this->extensions !== null) {
223 return $this->extensions;
224 }
225
226 return $this->extensions = new \Protobuf\Extension\ExtensionFieldMap(__CLASS__);
227 }
228
232 public function unknownFieldSet()
233 {
235 }
236
240 public static function fromStream($stream, \Protobuf\Configuration $configuration = null)
241 {
242 return new self($stream, $configuration);
243 }
244
248 public static function fromArray(array $values)
249 {
250 $message = new self();
251 $values = array_merge([
252 'id' => null,
253 'body' => null,
254 'expiry' => null,
255 'created' => null,
256 'sender' => null
257 ], $values);
258
259 $message->setId($values['id']);
260 $message->setBody($values['body']);
261 $message->setExpiry($values['expiry']);
262 $message->setCreated($values['created']);
263 $message->setSender($values['sender']);
264
265 return $message;
266 }
267
271 public static function descriptor()
272 {
273 return \google\protobuf\DescriptorProto::fromArray([
274 'name' => 'OutgoingMessage',
275 'field' => [
276 \google\protobuf\FieldDescriptorProto::fromArray([
277 'number' => 1,
278 'name' => 'id',
279 'type' => \google\protobuf\FieldDescriptorProto\Type::TYPE_BYTES(),
280 'label' => \google\protobuf\FieldDescriptorProto\Label::LABEL_OPTIONAL()
281 ]),
282 \google\protobuf\FieldDescriptorProto::fromArray([
283 'number' => 2,
284 'name' => 'body',
285 'type' => \google\protobuf\FieldDescriptorProto\Type::TYPE_STRING(),
286 'label' => \google\protobuf\FieldDescriptorProto\Label::LABEL_OPTIONAL()
287 ]),
288 \google\protobuf\FieldDescriptorProto::fromArray([
289 'number' => 3,
290 'name' => 'expiry',
291 'type' => \google\protobuf\FieldDescriptorProto\Type::TYPE_UINT32(),
292 'label' => \google\protobuf\FieldDescriptorProto\Label::LABEL_OPTIONAL()
293 ]),
294 \google\protobuf\FieldDescriptorProto::fromArray([
295 'number' => 4,
296 'name' => 'created',
297 'type' => \google\protobuf\FieldDescriptorProto\Type::TYPE_FIXED32(),
298 'label' => \google\protobuf\FieldDescriptorProto\Label::LABEL_OPTIONAL()
299 ]),
300 \google\protobuf\FieldDescriptorProto::fromArray([
301 'number' => 5,
302 'name' => 'sender',
303 'type' => \google\protobuf\FieldDescriptorProto\Type::TYPE_MESSAGE(),
304 'label' => \google\protobuf\FieldDescriptorProto\Label::LABEL_OPTIONAL(),
305 'type_name' => '.Sender'
306 ]),
307 ],
308 ]);
309 }
310
314 public function toStream(\Protobuf\Configuration $configuration = null)
315 {
316 $config = $configuration ?: \Protobuf\Configuration::getInstance();
317 $context = $config->createWriteContext();
318 $stream = $context->getStream();
319
320 $this->writeTo($context);
321 $stream->seek(0);
322
323 return $stream;
324 }
325
329 public function writeTo(\Protobuf\WriteContext $context)
330 {
331 $stream = $context->getStream();
332 $writer = $context->getWriter();
333 $sizeContext = $context->getComputeSizeContext();
334
335 if ($this->id !== null) {
336 $writer->writeVarint($stream, 10);
337 $writer->writeByteStream($stream, $this->id);
338 }
339
340 if ($this->body !== null) {
341 $writer->writeVarint($stream, 18);
342 $writer->writeString($stream, $this->body);
343 }
344
345 if ($this->expiry !== null) {
346 $writer->writeVarint($stream, 24);
347 $writer->writeVarint($stream, $this->expiry);
348 }
349
350 if ($this->created !== null) {
351 $writer->writeVarint($stream, 37);
352 $writer->writeFixed32($stream, $this->created);
353 }
354
355 if ($this->sender !== null) {
356 $writer->writeVarint($stream, 42);
357 $writer->writeVarint($stream, $this->sender->serializedSize($sizeContext));
358 $this->sender->writeTo($context);
359 }
360
361 if ($this->extensions !== null) {
362 $this->extensions->writeTo($context);
363 }
364
365 return $stream;
366 }
367
371 public function readFrom(\Protobuf\ReadContext $context)
372 {
373 $reader = $context->getReader();
374 $length = $context->getLength();
375 $stream = $context->getStream();
376
377 $limit = ($length !== null)
378 ? ($stream->tell() + $length)
379 : null;
380
381 while ($limit === null || $stream->tell() < $limit) {
382
383 if ($stream->eof()) {
384 break;
385 }
386
387 $key = $reader->readVarint($stream);
388 $wire = \Protobuf\WireFormat::getTagWireType($key);
389 $tag = \Protobuf\WireFormat::getTagFieldNumber($key);
390
391 if ($stream->eof()) {
392 break;
393 }
394
395 if ($tag === 1) {
396 \Protobuf\WireFormat::assertWireType($wire, 12);
397
398 $this->id = $reader->readByteStream($stream);
399
400 continue;
401 }
402
403 if ($tag === 2) {
404 \Protobuf\WireFormat::assertWireType($wire, 9);
405
406 $this->body = $reader->readString($stream);
407
408 continue;
409 }
410
411 if ($tag === 3) {
412 \Protobuf\WireFormat::assertWireType($wire, 13);
413
414 $this->expiry = $reader->readVarint($stream);
415
416 continue;
417 }
418
419 if ($tag === 4) {
420 \Protobuf\WireFormat::assertWireType($wire, 7);
421
422 $this->created = $reader->readFixed32($stream);
423
424 continue;
425 }
426
427 if ($tag === 5) {
428 \Protobuf\WireFormat::assertWireType($wire, 11);
429
430 $innerSize = $reader->readVarint($stream);
431 $innerMessage = new \Bitrix\Pull\Protobuf\Sender();
432
433 $this->sender = $innerMessage;
434
435 $context->setLength($innerSize);
436 $innerMessage->readFrom($context);
437 $context->setLength($length);
438
439 continue;
440 }
441
442 $extensions = $context->getExtensionRegistry();
443 $extension = $extensions ? $extensions->findByNumber(__CLASS__, $tag) : null;
444
445 if ($extension !== null) {
446 $this->extensions()->add($extension, $extension->readFrom($context, $wire));
447
448 continue;
449 }
450
451 if ($this->unknownFieldSet === null) {
452 $this->unknownFieldSet = new \Protobuf\UnknownFieldSet();
453 }
454
455 $data = $reader->readUnknown($stream, $wire);
456 $unknown = new \Protobuf\Unknown($tag, $wire, $data);
457
458 $this->unknownFieldSet->add($unknown);
459
460 }
461 }
462
466 public function serializedSize(\Protobuf\ComputeSizeContext $context)
467 {
468 $calculator = $context->getSizeCalculator();
469 $size = 0;
470
471 if ($this->id !== null) {
472 $size += 1;
473 $size += $calculator->computeByteStreamSize($this->id);
474 }
475
476 if ($this->body !== null) {
477 $size += 1;
478 $size += $calculator->computeStringSize($this->body);
479 }
480
481 if ($this->expiry !== null) {
482 $size += 1;
483 $size += $calculator->computeVarintSize($this->expiry);
484 }
485
486 if ($this->created !== null) {
487 $size += 1;
488 $size += 4;
489 }
490
491 if ($this->sender !== null) {
492 $innerSize = $this->sender->serializedSize($context);
493
494 $size += 1;
495 $size += $innerSize;
496 $size += $calculator->computeVarintSize($innerSize);
497 }
498
499 if ($this->extensions !== null) {
500 $size += $this->extensions->serializedSize($context);
501 }
502
503 return $size;
504 }
505
509 public function clear()
510 {
511 $this->id = null;
512 $this->body = null;
513 $this->expiry = null;
514 $this->created = null;
515 $this->sender = null;
516 }
517
521 public function merge(\Protobuf\Message $message)
522 {
523 if ( ! $message instanceof \Bitrix\Pull\Protobuf\OutgoingMessage) {
524 throw new \InvalidArgumentException(sprintf('Argument 1 passed to %s must be a %s, %s given', __METHOD__, __CLASS__, get_class($message)));
525 }
526
527 $this->id = ($message->id !== null) ? $message->id : $this->id;
528 $this->body = ($message->body !== null) ? $message->body : $this->body;
529 $this->expiry = ($message->expiry !== null) ? $message->expiry : $this->expiry;
530 $this->created = ($message->created !== null) ? $message->created : $this->created;
531 $this->sender = ($message->sender !== null) ? $message->sender : $this->sender;
532 }
533
534
535}
536
writeTo(\Protobuf\WriteContext $context)
setSender(\Bitrix\Pull\Protobuf\Sender $value=null)
toStream(\Protobuf\Configuration $configuration=null)
serializedSize(\Protobuf\ComputeSizeContext $context)
merge(\Protobuf\Message $message)
static fromStream($stream, \Protobuf\Configuration $configuration=null)
readFrom(\Protobuf\ReadContext $context)