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

Method _writeMap

lib/php/lib/Exception/TException.php:244–302  ·  view source on GitHub ↗
($var, $spec, $output)

Source from the content-addressed store, hash-verified

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