Open GoogleCodeExporter opened 8 years ago
Thank you dude ... do you have the same kind of things for : floats, uint32,
uint64, fixed 32, fixed64, sfixed32, sfixed64 ? :D
Original comment by vjoig...@gmail.com
on 15 Apr 2013 at 1:22
[deleted comment]
use function unpack will return a array,so i use function array_shift bug it.
the same to the File "pb_double.php" i suggest.
Original comment by fort...@gmail.com
on 20 Jun 2013 at 6:20
[deleted comment]
File "pb_float.php":
-------------------------
<?php
/**
* @author forthxu (http://forthxu.com)
*/
class PBFloat extends PBScalar
{
var $wired_type = PBMessage::WIRED_64BIT;
public function ParseFromArray()
{
$this->value = '';
// just extract the string
$pointer = $this->reader->get_pointer();
$this->reader->add_pointer(4);
$www_forthxu_com = unpack('f', $this->reader->get_message_from($pointer));
$this->value = array_shift($www_forthxu_com);
}
/**
* Serializes type
*/
public function SerializeToString($rec=-1)
{
$string = '';
if ($rec > -1)
{
$string .= $this->base128->set_value($rec << 3 |
$this->wired_type);
}
$string .= pack("f", (double)$this->value);
return $string;
}
}
-------------------------
Don't forget to include this file in pb_message.php:
-------------------------
require_once(dirname(__FILE__). '/' . 'type/pb_float.php');
-------------------------
And specify this class as class to work with this type in pb_parser.php:
-------------------------
var $scalar_types = array(..., 'double', 'float' => 'PBFloat', 'int32' =>
'PBInt', 'int64' => 'PBInt',
-------------------------
Original comment by fort...@gmail.com
on 20 Jun 2013 at 6:32
Beware, if you want to use both pbDouble and pbFloat, the related pbFloat
weird_type is WIRED_32BIT.
Original comment by Baptiste...@gmail.com
on 20 Aug 2013 at 7:41
Original issue reported on code.google.com by
VoD...@gmail.com
on 26 Apr 2010 at 12:25