Recovering ByteArray's functionality
This commit is contained in:
parent
0f55bec06b
commit
73b7f646b4
@ -1,5 +1,20 @@
|
|||||||
<?php
|
<?php
|
||||||
require_once 'errors.php';
|
class ERROR {
|
||||||
|
const INVALID_DATA = 1;
|
||||||
|
const UNDEFINED_DATA = 2;
|
||||||
|
const TYPE_MISSMATCH = 3;
|
||||||
|
|
||||||
|
const READ_ONLY = 11;
|
||||||
|
const GREATER_COMPARATIVE = 21;
|
||||||
|
|
||||||
|
const EOF = 100;
|
||||||
|
|
||||||
|
function __construct($type, $a, $b)
|
||||||
|
{
|
||||||
|
throw new Exception($type);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
class ByteArray extends ArrayObject {
|
class ByteArray extends ArrayObject {
|
||||||
private $position = 0;
|
private $position = 0;
|
||||||
public function ByteArray($str = NULL) {
|
public function ByteArray($str = NULL) {
|
||||||
@ -423,14 +438,17 @@ class ByteArray extends ArrayObject {
|
|||||||
return (($num = ($num < 0) ? $num + 256:$num) < 16) ? '0'.dechex($num):dechex($num);
|
return (($num = ($num < 0) ? $num + 256:$num) < 16) ? '0'.dechex($num):dechex($num);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/*tests
|
//* Tests
|
||||||
$a = new ByteArray();
|
$a = new ByteArray();
|
||||||
$a->writeInt(12345);
|
$a->writeInt(12345);
|
||||||
$a->writeShort(11223);
|
$a->writeShort(11223);
|
||||||
$a->writeUnsignedInt(1125434357);
|
$a->writeUnsignedInt(1125434357);
|
||||||
$a->position = 0;
|
$a->position = 0;
|
||||||
|
echo "ReadInt: ";
|
||||||
echo $a->readInt()."\n";
|
echo $a->readInt()."\n";
|
||||||
|
echo "ReadShort: ";
|
||||||
echo $a->readShort()."\n";
|
echo $a->readShort()."\n";
|
||||||
|
echo "readUnsignedShort: ";
|
||||||
echo $a->readUnsignedInt()."\n";
|
echo $a->readUnsignedInt()."\n";
|
||||||
$a->position = 0;
|
$a->position = 0;
|
||||||
$a->writeDouble(1);
|
$a->writeDouble(1);
|
||||||
@ -448,19 +466,31 @@ class ByteArray extends ArrayObject {
|
|||||||
$a->writeFloat(150);
|
$a->writeFloat(150);
|
||||||
$a->writeFloat(132.1);
|
$a->writeFloat(132.1);
|
||||||
$a->position = 0;
|
$a->position = 0;
|
||||||
|
echo "readDouble: ";
|
||||||
echo $a->readDouble()."\n";
|
echo $a->readDouble()."\n";
|
||||||
|
echo "readDouble: ";
|
||||||
echo $a->readDouble()."\n";
|
echo $a->readDouble()."\n";
|
||||||
|
echo "readDouble: ";
|
||||||
echo $a->readDouble()."\n";
|
echo $a->readDouble()."\n";
|
||||||
|
echo "readDouble: ";
|
||||||
echo $a->readDouble()."\n";
|
echo $a->readDouble()."\n";
|
||||||
|
echo "readDouble: ";
|
||||||
echo $a->readDouble()."\n";
|
echo $a->readDouble()."\n";
|
||||||
|
echo "readDouble: ";
|
||||||
echo $a->readDouble()."\n";
|
echo $a->readDouble()."\n";
|
||||||
|
|
||||||
|
echo "readFloat: ";
|
||||||
echo $a->readFloat()."\n";
|
echo $a->readFloat()."\n";
|
||||||
|
echo "readFloat: ";
|
||||||
echo $a->readFloat()."\n";
|
echo $a->readFloat()."\n";
|
||||||
|
echo "readFloat: ";
|
||||||
echo $a->readFloat()."\n";
|
echo $a->readFloat()."\n";
|
||||||
|
echo "readFloat: ";
|
||||||
echo $a->readFloat()."\n";
|
echo $a->readFloat()."\n";
|
||||||
|
echo "readFloat: ";
|
||||||
echo $a->readFloat()."\n";
|
echo $a->readFloat()."\n";
|
||||||
|
echo "readFloat: ";
|
||||||
echo $a->readFloat()."\n";
|
echo $a->readFloat()."\n";
|
||||||
|
|
||||||
//*/
|
//*/
|
||||||
?>
|
?>
|
||||||
|
Loading…
Reference in New Issue
Block a user