Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
jsonresponse.php
1<?
2
4
15class JsonResponse extends \Protobuf\AbstractMessage
16{
17
21 protected $unknownFieldSet = null;
22
26 protected $extensions = null;
27
33 protected $json = null;
34
40 public function hasJson()
41 {
42 return $this->json !== null;
43 }
44
50 public function getJson()
51 {
52 return $this->json;
53 }
54
60 public function setJson($value = null)
61 {
62 $this->json = $value;
63 }
64
68 public function extensions()
69 {
70 if ( $this->extensions !== null) {
71 return $this->extensions;
72 }
73
74 return $this->extensions = new \Protobuf\Extension\ExtensionFieldMap(__CLASS__);
75 }
76
80 public function unknownFieldSet()
81 {
83 }
84
88 public static function fromStream($stream, \Protobuf\Configuration $configuration = null)
89 {
90 return new self($stream, $configuration);
91 }
92
96 public static function fromArray(array $values)
97 {
98 $message = new self();
99 $values = array_merge([
100 'json' => null
101 ], $values);
102
103 $message->setJson($values['json']);
104
105 return $message;
106 }
107
111 public static function descriptor()
112 {
113 return \google\protobuf\DescriptorProto::fromArray([
114 'name' => 'JsonResponse',
115 'field' => [
116 \google\protobuf\FieldDescriptorProto::fromArray([
117 'number' => 1,
118 'name' => 'json',
119 'type' => \google\protobuf\FieldDescriptorProto\Type::TYPE_STRING(),
120 'label' => \google\protobuf\FieldDescriptorProto\Label::LABEL_OPTIONAL()
121 ]),
122 ],
123 ]);
124 }
125
129 public function toStream(\Protobuf\Configuration $configuration = null)
130 {
131 $config = $configuration ?: \Protobuf\Configuration::getInstance();
132 $context = $config->createWriteContext();
133 $stream = $context->getStream();
134
135 $this->writeTo($context);
136 $stream->seek(0);
137
138 return $stream;
139 }
140
144 public function writeTo(\Protobuf\WriteContext $context)
145 {
146 $stream = $context->getStream();
147 $writer = $context->getWriter();
148 $sizeContext = $context->getComputeSizeContext();
149
150 if ($this->json !== null) {
151 $writer->writeVarint($stream, 10);
152 $writer->writeString($stream, $this->json);
153 }
154
155 if ($this->extensions !== null) {
156 $this->extensions->writeTo($context);
157 }
158
159 return $stream;
160 }
161
165 public function readFrom(\Protobuf\ReadContext $context)
166 {
167 $reader = $context->getReader();
168 $length = $context->getLength();
169 $stream = $context->getStream();
170
171 $limit = ($length !== null)
172 ? ($stream->tell() + $length)
173 : null;
174
175 while ($limit === null || $stream->tell() < $limit) {
176
177 if ($stream->eof()) {
178 break;
179 }
180
181 $key = $reader->readVarint($stream);
182 $wire = \Protobuf\WireFormat::getTagWireType($key);
183 $tag = \Protobuf\WireFormat::getTagFieldNumber($key);
184
185 if ($stream->eof()) {
186 break;
187 }
188
189 if ($tag === 1) {
190 \Protobuf\WireFormat::assertWireType($wire, 9);
191
192 $this->json = $reader->readString($stream);
193
194 continue;
195 }
196
197 $extensions = $context->getExtensionRegistry();
198 $extension = $extensions ? $extensions->findByNumber(__CLASS__, $tag) : null;
199
200 if ($extension !== null) {
201 $this->extensions()->add($extension, $extension->readFrom($context, $wire));
202
203 continue;
204 }
205
206 if ($this->unknownFieldSet === null) {
207 $this->unknownFieldSet = new \Protobuf\UnknownFieldSet();
208 }
209
210 $data = $reader->readUnknown($stream, $wire);
211 $unknown = new \Protobuf\Unknown($tag, $wire, $data);
212
213 $this->unknownFieldSet->add($unknown);
214
215 }
216 }
217
221 public function serializedSize(\Protobuf\ComputeSizeContext $context)
222 {
223 $calculator = $context->getSizeCalculator();
224 $size = 0;
225
226 if ($this->json !== null) {
227 $size += 1;
228 $size += $calculator->computeStringSize($this->json);
229 }
230
231 if ($this->extensions !== null) {
232 $size += $this->extensions->serializedSize($context);
233 }
234
235 return $size;
236 }
237
241 public function clear()
242 {
243 $this->json = null;
244 }
245
249 public function merge(\Protobuf\Message $message)
250 {
251 if ( ! $message instanceof \Bitrix\Pull\Protobuf\JsonResponse) {
252 throw new \InvalidArgumentException(sprintf('Argument 1 passed to %s must be a %s, %s given', __METHOD__, __CLASS__, get_class($message)));
253 }
254
255 $this->json = ($message->json !== null) ? $message->json : $this->json;
256 }
257
258
259}
260
writeTo(\Protobuf\WriteContext $context)
toStream(\Protobuf\Configuration $configuration=null)
serializedSize(\Protobuf\ComputeSizeContext $context)
merge(\Protobuf\Message $message)
static fromStream($stream, \Protobuf\Configuration $configuration=null)
static fromArray(array $values)
readFrom(\Protobuf\ReadContext $context)