MCPcopy Create free account
hub / github.com/apache/thrift / _writeMap

Method _writeMap

lib/php/lib/Base/TBase.php:243–301  ·  view source on GitHub ↗
($var, $spec, $output)

Source from the content-addressed store, hash-verified

241 }
242
243 private function _writeMap($var, $spec, $output)
244 {
245 $xfer = 0;
246 $ktype = $spec['ktype'];
247 $vtype = $spec['vtype'];
248 $kwrite = $vwrite = null;
249 if (isset(TBase::$tmethod[$ktype])) {
250 $kwrite = 'write' . TBase::$tmethod[$ktype];
251 } else {
252 $kspec = $spec['key'];
253 }
254 if (isset(TBase::$tmethod[$vtype])) {
255 $vwrite = 'write' . TBase::$tmethod[$vtype];
256 } else {
257 $vspec = $spec['val'];
258 }
259 $xfer += $output->writeMapBegin($ktype, $vtype, count($var));
260 foreach ($var as $key => $val) {
261 if (isset($kwrite)) {
262 $xfer += $output->$kwrite($key);
263 } else {
264 switch ($ktype) {
265 case TType::STRUCT:
266 $xfer += $key->write($output);
267 break;
268 case TType::MAP:
269 $xfer += $this->_writeMap($key, $kspec, $output);
270 break;
271 case TType::LST:
272 $xfer += $this->_writeList($key, $kspec, $output, false);
273 break;
274 case TType::SET:
275 $xfer += $this->_writeList($key, $kspec, $output, true);
276 break;
277 }
278 }
279 if (isset($vwrite)) {
280 $xfer += $output->$vwrite($val);
281 } else {
282 switch ($vtype) {
283 case TType::STRUCT:
284 $xfer += $val->write($output);
285 break;
286 case TType::MAP:
287 $xfer += $this->_writeMap($val, $vspec, $output);
288 break;
289 case TType::LST:
290 $xfer += $this->_writeList($val, $vspec, $output, false);
291 break;
292 case TType::SET:
293 $xfer += $this->_writeList($val, $vspec, $output, true);
294 break;
295 }
296 }
297 }
298 $xfer += $output->writeMapEnd();
299
300 return $xfer;

Callers 2

_writeListMethod · 0.95
_writeMethod · 0.95

Calls 4

_writeListMethod · 0.95
writeMapBeginMethod · 0.65
writeMethod · 0.65
writeMapEndMethod · 0.65

Tested by

no test coverage detected