protected function writeClass($alias, $fields) { $len = ustrlen($alias); $this->stream->write(HproseTags::TagClass . $len . HproseTags::TagQuote . $alias . HproseTags::TagQuote); $count = count($fields); if ($count > 0) { $this->stream->write((string) $count); } $this->stream->write(HproseTags::TagOpenbrace); for ($i = 0; $i < $count; ++$i) { $field = $fields[$i]; if ($field[0] === "") { $field = substr($field, strpos($field, "", 1) + 1); } $this->writeString($field); } $this->stream->write(HproseTags::TagClosebrace); $index = count($this->fieldsref); $this->classref[$alias] = $index; $this->fieldsref[$index] = $fields; return $index; }
public function writeString($str, $checkRef = false) { $len = ustrlen($str); $this->stream->write(HproseTags::TagString); if ($len > 0) { $this->stream->write((string) $len); } $this->stream->write(HproseTags::TagQuote . $str . HproseTags::TagQuote); }
private function writeClass(&$class) { list($classname, $fields) = $class; $count = count($fields); $len = ustrlen($classname); $this->stream->write(HproseTags::TagClass . $len . HproseTags::TagQuote . $classname . HproseTags::TagQuote); if ($count > 0) { $this->stream->write($count); } $this->stream->write(HproseTags::TagOpenbrace); for ($i = 0; $i < $count; $i++) { $field = $fields[$i]; if ($field[0] == "") { $field = substr($field, strpos($field, "", 1) + 1); } $this->writeString($field); } $this->stream->write(HproseTags::TagClosebrace); $classref = count($this->classref); $this->classref[] =& $class; return $classref; }
function hprose_serialize_string($s) { return 's' . ustrlen($s) . '"' . $s . '"'; }