($class, $spec, $input)
| 191 | } |
| 192 | |
| 193 | protected function _read($class, $spec, $input) |
| 194 | { |
| 195 | $xfer = 0; |
| 196 | $fname = null; |
| 197 | $ftype = 0; |
| 198 | $fid = 0; |
| 199 | $xfer += $input->readStructBegin($fname); |
| 200 | while (true) { |
| 201 | $xfer += $input->readFieldBegin($fname, $ftype, $fid); |
| 202 | if ($ftype == TType::STOP) { |
| 203 | break; |
| 204 | } |
| 205 | if (isset($spec[$fid])) { |
| 206 | $fspec = $spec[$fid]; |
| 207 | $var = $fspec['var']; |
| 208 | if ($ftype == $fspec['type']) { |
| 209 | $xfer = 0; |
| 210 | if (isset(TBase::$tmethod[$ftype])) { |
| 211 | $func = 'read' . TBase::$tmethod[$ftype]; |
| 212 | $xfer += $input->$func($this->$var); |
| 213 | } else { |
| 214 | switch ($ftype) { |
| 215 | case TType::STRUCT: |
| 216 | $class = $fspec['class']; |
| 217 | $this->$var = new $class(); |
| 218 | $xfer += $this->$var->read($input); |
| 219 | break; |
| 220 | case TType::MAP: |
| 221 | $xfer += $this->_readMap($this->$var, $fspec, $input); |
| 222 | break; |
| 223 | case TType::LST: |
| 224 | $xfer += $this->_readList($this->$var, $fspec, $input, false); |
| 225 | break; |
| 226 | case TType::SET: |
| 227 | $xfer += $this->_readList($this->$var, $fspec, $input, true); |
| 228 | break; |
| 229 | } |
| 230 | } |
| 231 | } else { |
| 232 | $xfer += $input->skip($ftype); |
| 233 | } |
| 234 | } else { |
| 235 | $xfer += $input->skip($ftype); |
| 236 | } |
| 237 | $xfer += $input->readFieldEnd(); |
| 238 | } |
| 239 | $xfer += $input->readStructEnd(); |
| 240 | |
| 241 | return $xfer; |
| 242 | } |
| 243 | |
| 244 | private function _writeMap($var, $spec, $output) |
| 245 | { |
no test coverage detected