Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
receiver.php
1<?
2
4
15class Receiver extends \Protobuf\AbstractMessage
16{
17
21 protected $unknownFieldSet = null;
22
26 protected $extensions = null;
27
33 protected $id = null;
34
40 protected $isPrivate = null;
41
47 protected $signature = null;
48
54 public function hasId()
55 {
56 return $this->id !== null;
57 }
58
64 public function getId()
65 {
66 return $this->id;
67 }
68
74 public function setId($value = null)
75 {
76 if ($value !== null && ! $value instanceof \Protobuf\Stream) {
77 $value = \Protobuf\Stream::wrap($value);
78 }
79
80 $this->id = $value;
81 }
82
88 public function hasIsPrivate()
89 {
90 return $this->isPrivate !== null;
91 }
92
98 public function getIsPrivate()
99 {
100 return $this->isPrivate;
101 }
102
108 public function setIsPrivate($value = null)
109 {
110 $this->isPrivate = $value;
111 }
112
118 public function hasSignature()
119 {
120 return $this->signature !== null;
121 }
122
128 public function getSignature()
129 {
130 return $this->signature;
131 }
132
138 public function setSignature($value = null)
139 {
140 if ($value !== null && ! $value instanceof \Protobuf\Stream) {
141 $value = \Protobuf\Stream::wrap($value);
142 }
143
144 $this->signature = $value;
145 }
146
150 public function extensions()
151 {
152 if ( $this->extensions !== null) {
153 return $this->extensions;
154 }
155
156 return $this->extensions = new \Protobuf\Extension\ExtensionFieldMap(__CLASS__);
157 }
158
162 public function unknownFieldSet()
163 {
165 }
166
170 public static function fromStream($stream, \Protobuf\Configuration $configuration = null)
171 {
172 return new self($stream, $configuration);
173 }
174
178 public static function fromArray(array $values)
179 {
180 $message = new self();
181 $values = array_merge([
182 'id' => null,
183 'isPrivate' => null,
184 'signature' => null
185 ], $values);
186
187 $message->setId($values['id']);
188 $message->setIsPrivate($values['isPrivate']);
189 $message->setSignature($values['signature']);
190
191 return $message;
192 }
193
197 public static function descriptor()
198 {
199 return \google\protobuf\DescriptorProto::fromArray([
200 'name' => 'Receiver',
201 'field' => [
202 \google\protobuf\FieldDescriptorProto::fromArray([
203 'number' => 1,
204 'name' => 'id',
205 'type' => \google\protobuf\FieldDescriptorProto\Type::TYPE_BYTES(),
206 'label' => \google\protobuf\FieldDescriptorProto\Label::LABEL_OPTIONAL()
207 ]),
208 \google\protobuf\FieldDescriptorProto::fromArray([
209 'number' => 2,
210 'name' => 'isPrivate',
211 'type' => \google\protobuf\FieldDescriptorProto\Type::TYPE_BOOL(),
212 'label' => \google\protobuf\FieldDescriptorProto\Label::LABEL_OPTIONAL()
213 ]),
214 \google\protobuf\FieldDescriptorProto::fromArray([
215 'number' => 3,
216 'name' => 'signature',
217 'type' => \google\protobuf\FieldDescriptorProto\Type::TYPE_BYTES(),
218 'label' => \google\protobuf\FieldDescriptorProto\Label::LABEL_OPTIONAL()
219 ]),
220 ],
221 ]);
222 }
223
227 public function toStream(\Protobuf\Configuration $configuration = null)
228 {
229 $config = $configuration ?: \Protobuf\Configuration::getInstance();
230 $context = $config->createWriteContext();
231 $stream = $context->getStream();
232
233 $this->writeTo($context);
234 $stream->seek(0);
235
236 return $stream;
237 }
238
242 public function writeTo(\Protobuf\WriteContext $context)
243 {
244 $stream = $context->getStream();
245 $writer = $context->getWriter();
246 $sizeContext = $context->getComputeSizeContext();
247
248 if ($this->id !== null) {
249 $writer->writeVarint($stream, 10);
250 $writer->writeByteStream($stream, $this->id);
251 }
252
253 if ($this->isPrivate !== null) {
254 $writer->writeVarint($stream, 16);
255 $writer->writeBool($stream, $this->isPrivate);
256 }
257
258 if ($this->signature !== null) {
259 $writer->writeVarint($stream, 26);
260 $writer->writeByteStream($stream, $this->signature);
261 }
262
263 if ($this->extensions !== null) {
264 $this->extensions->writeTo($context);
265 }
266
267 return $stream;
268 }
269
273 public function readFrom(\Protobuf\ReadContext $context)
274 {
275 $reader = $context->getReader();
276 $length = $context->getLength();
277 $stream = $context->getStream();
278
279 $limit = ($length !== null)
280 ? ($stream->tell() + $length)
281 : null;
282
283 while ($limit === null || $stream->tell() < $limit) {
284
285 if ($stream->eof()) {
286 break;
287 }
288
289 $key = $reader->readVarint($stream);
290 $wire = \Protobuf\WireFormat::getTagWireType($key);
291 $tag = \Protobuf\WireFormat::getTagFieldNumber($key);
292
293 if ($stream->eof()) {
294 break;
295 }
296
297 if ($tag === 1) {
298 \Protobuf\WireFormat::assertWireType($wire, 12);
299
300 $this->id = $reader->readByteStream($stream);
301
302 continue;
303 }
304
305 if ($tag === 2) {
306 \Protobuf\WireFormat::assertWireType($wire, 8);
307
308 $this->isPrivate = $reader->readBool($stream);
309
310 continue;
311 }
312
313 if ($tag === 3) {
314 \Protobuf\WireFormat::assertWireType($wire, 12);
315
316 $this->signature = $reader->readByteStream($stream);
317
318 continue;
319 }
320
321 $extensions = $context->getExtensionRegistry();
322 $extension = $extensions ? $extensions->findByNumber(__CLASS__, $tag) : null;
323
324 if ($extension !== null) {
325 $this->extensions()->add($extension, $extension->readFrom($context, $wire));
326
327 continue;
328 }
329
330 if ($this->unknownFieldSet === null) {
331 $this->unknownFieldSet = new \Protobuf\UnknownFieldSet();
332 }
333
334 $data = $reader->readUnknown($stream, $wire);
335 $unknown = new \Protobuf\Unknown($tag, $wire, $data);
336
337 $this->unknownFieldSet->add($unknown);
338
339 }
340 }
341
345 public function serializedSize(\Protobuf\ComputeSizeContext $context)
346 {
347 $calculator = $context->getSizeCalculator();
348 $size = 0;
349
350 if ($this->id !== null) {
351 $size += 1;
352 $size += $calculator->computeByteStreamSize($this->id);
353 }
354
355 if ($this->isPrivate !== null) {
356 $size += 1;
357 $size += 1;
358 }
359
360 if ($this->signature !== null) {
361 $size += 1;
362 $size += $calculator->computeByteStreamSize($this->signature);
363 }
364
365 if ($this->extensions !== null) {
366 $size += $this->extensions->serializedSize($context);
367 }
368
369 return $size;
370 }
371
375 public function clear()
376 {
377 $this->id = null;
378 $this->isPrivate = null;
379 $this->signature = null;
380 }
381
385 public function merge(\Protobuf\Message $message)
386 {
387 if ( ! $message instanceof \Bitrix\Pull\Protobuf\Receiver) {
388 throw new \InvalidArgumentException(sprintf('Argument 1 passed to %s must be a %s, %s given', __METHOD__, __CLASS__, get_class($message)));
389 }
390
391 $this->id = ($message->id !== null) ? $message->id : $this->id;
392 $this->isPrivate = ($message->isPrivate !== null) ? $message->isPrivate : $this->isPrivate;
393 $this->signature = ($message->signature !== null) ? $message->signature : $this->signature;
394 }
395
396
397}
398
writeTo(\Protobuf\WriteContext $context)
Definition receiver.php:242
toStream(\Protobuf\Configuration $configuration=null)
Definition receiver.php:227
serializedSize(\Protobuf\ComputeSizeContext $context)
Definition receiver.php:345
merge(\Protobuf\Message $message)
Definition receiver.php:385
static fromStream($stream, \Protobuf\Configuration $configuration=null)
Definition receiver.php:170
static fromArray(array $values)
Definition receiver.php:178
readFrom(\Protobuf\ReadContext $context)
Definition receiver.php:273