Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
responsebatch.php
1<?
2
4
15class ResponseBatch extends \Protobuf\AbstractMessage
16{
17
21 protected $unknownFieldSet = null;
22
26 protected $extensions = null;
27
33 protected $responses = null;
34
40 public function hasResponsesList()
41 {
42 return $this->responses !== null;
43 }
44
50 public function getResponsesList()
51 {
52 return $this->responses;
53 }
54
60 public function setResponsesList(\Protobuf\Collection $value = null)
61 {
62 $this->responses = $value;
63 }
64
70 public function addResponses(\Bitrix\Pull\Protobuf\Response $value)
71 {
72 if ($this->responses === null) {
73 $this->responses = new \Protobuf\MessageCollection();
74 }
75
76 $this->responses->add($value);
77 }
78
82 public function extensions()
83 {
84 if ( $this->extensions !== null) {
85 return $this->extensions;
86 }
87
88 return $this->extensions = new \Protobuf\Extension\ExtensionFieldMap(__CLASS__);
89 }
90
94 public function unknownFieldSet()
95 {
97 }
98
102 public static function fromStream($stream, \Protobuf\Configuration $configuration = null)
103 {
104 return new self($stream, $configuration);
105 }
106
110 public static function fromArray(array $values)
111 {
112 $message = new self();
113 $values = array_merge([
114 'responses' => []
115 ], $values);
116
117 foreach ($values['responses'] as $item) {
118 $message->addResponses($item);
119 }
120
121 return $message;
122 }
123
127 public static function descriptor()
128 {
129 return \google\protobuf\DescriptorProto::fromArray([
130 'name' => 'ResponseBatch',
131 'field' => [
132 \google\protobuf\FieldDescriptorProto::fromArray([
133 'number' => 1,
134 'name' => 'responses',
135 'type' => \google\protobuf\FieldDescriptorProto\Type::TYPE_MESSAGE(),
136 'label' => \google\protobuf\FieldDescriptorProto\Label::LABEL_REPEATED(),
137 'type_name' => '.Response'
138 ]),
139 ],
140 ]);
141 }
142
146 public function toStream(\Protobuf\Configuration $configuration = null)
147 {
148 $config = $configuration ?: \Protobuf\Configuration::getInstance();
149 $context = $config->createWriteContext();
150 $stream = $context->getStream();
151
152 $this->writeTo($context);
153 $stream->seek(0);
154
155 return $stream;
156 }
157
161 public function writeTo(\Protobuf\WriteContext $context)
162 {
163 $stream = $context->getStream();
164 $writer = $context->getWriter();
165 $sizeContext = $context->getComputeSizeContext();
166
167 if ($this->responses !== null) {
168 foreach ($this->responses as $val) {
169 $writer->writeVarint($stream, 10);
170 $writer->writeVarint($stream, $val->serializedSize($sizeContext));
171 $val->writeTo($context);
172 }
173 }
174
175 if ($this->extensions !== null) {
176 $this->extensions->writeTo($context);
177 }
178
179 return $stream;
180 }
181
185 public function readFrom(\Protobuf\ReadContext $context)
186 {
187 $reader = $context->getReader();
188 $length = $context->getLength();
189 $stream = $context->getStream();
190
191 $limit = ($length !== null)
192 ? ($stream->tell() + $length)
193 : null;
194
195 while ($limit === null || $stream->tell() < $limit) {
196
197 if ($stream->eof()) {
198 break;
199 }
200
201 $key = $reader->readVarint($stream);
202 $wire = \Protobuf\WireFormat::getTagWireType($key);
203 $tag = \Protobuf\WireFormat::getTagFieldNumber($key);
204
205 if ($stream->eof()) {
206 break;
207 }
208
209 if ($tag === 1) {
210 \Protobuf\WireFormat::assertWireType($wire, 11);
211
212 $innerSize = $reader->readVarint($stream);
213 $innerMessage = new \Bitrix\Pull\Protobuf\Response();
214
215 if ($this->responses === null) {
216 $this->responses = new \Protobuf\MessageCollection();
217 }
218
219 $this->responses->add($innerMessage);
220
221 $context->setLength($innerSize);
222 $innerMessage->readFrom($context);
223 $context->setLength($length);
224
225 continue;
226 }
227
228 $extensions = $context->getExtensionRegistry();
229 $extension = $extensions ? $extensions->findByNumber(__CLASS__, $tag) : null;
230
231 if ($extension !== null) {
232 $this->extensions()->add($extension, $extension->readFrom($context, $wire));
233
234 continue;
235 }
236
237 if ($this->unknownFieldSet === null) {
238 $this->unknownFieldSet = new \Protobuf\UnknownFieldSet();
239 }
240
241 $data = $reader->readUnknown($stream, $wire);
242 $unknown = new \Protobuf\Unknown($tag, $wire, $data);
243
244 $this->unknownFieldSet->add($unknown);
245
246 }
247 }
248
252 public function serializedSize(\Protobuf\ComputeSizeContext $context)
253 {
254 $calculator = $context->getSizeCalculator();
255 $size = 0;
256
257 if ($this->responses !== null) {
258 foreach ($this->responses as $val) {
259 $innerSize = $val->serializedSize($context);
260
261 $size += 1;
262 $size += $innerSize;
263 $size += $calculator->computeVarintSize($innerSize);
264 }
265 }
266
267 if ($this->extensions !== null) {
268 $size += $this->extensions->serializedSize($context);
269 }
270
271 return $size;
272 }
273
277 public function clear()
278 {
279 $this->responses = null;
280 }
281
285 public function merge(\Protobuf\Message $message)
286 {
287 if ( ! $message instanceof \Bitrix\Pull\Protobuf\ResponseBatch) {
288 throw new \InvalidArgumentException(sprintf('Argument 1 passed to %s must be a %s, %s given', __METHOD__, __CLASS__, get_class($message)));
289 }
290
291 $this->responses = ($message->responses !== null) ? $message->responses : $this->responses;
292 }
293
294
295}
296
writeTo(\Protobuf\WriteContext $context)
addResponses(\Bitrix\Pull\Protobuf\Response $value)
toStream(\Protobuf\Configuration $configuration=null)
serializedSize(\Protobuf\ComputeSizeContext $context)
merge(\Protobuf\Message $message)
static fromStream($stream, \Protobuf\Configuration $configuration=null)
readFrom(\Protobuf\ReadContext $context)
setResponsesList(\Protobuf\Collection $value=null)