Files
Testing/vidchat/m/SabreAMF/OutputStream.php
sean 0e8a8b3028
Some checks are pending
deploy-testing / deploy (push) Waiting to run
Initial testing snapshot
2026-11-17 16:15:01 -05:00

102 lines
2.0 KiB
PHP

<?php
/**
* SabreAMF_OutputStream
*
* This class provides methods to encode bytes, longs, strings, int's etc. to a binary format
*
* @package SabreAMF
* @version $Id: OutputStream.php 233 2009-06-27 23:10:34Z evertpot $
* @copyright Copyright (C) 2006-2009 Rooftop Solutions. All rights reserved.
* @author Evert Pot (http://www.rooftopsolutions.nl/)
* @licence http://www.freebsd.org/copyright/license.html BSD License (4 Clause)
*/
class SabreAMF_OutputStream {
/**
* rawData
*
* @var string
*/
private $rawData = '';
/**
* writeBuffer
*
* @param string $str
* @return void
*/
public function writeBuffer($str) {
$this->rawData.=$str;
}
/**
* writeByte
*
* @param int $byte
* @return void
*/
public function writeByte($byte) {
$this->rawData.=pack('c',$byte);
}
/**
* writeInt
*
* @param int $int
* @return void
*/
public function writeInt($int) {
$this->rawData.=pack('n',$int);
}
/**
* writeDouble
*
* @param float $double
* @return void
*/
public function writeDouble($double) {
$bin = pack("d",$double);
$testEndian = unpack("C*",pack("S*",256));
$bigEndian = !$testEndian[1]==1;
if ($bigEndian) $bin = strrev($bin);
$this->rawData.=$bin;
}
/**
* writeLong
*
* @param int $long
* @return void
*/
public function writeLong($long) {
$this->rawData.=pack("N",$long);
}
/**
* getRawData
*
* @return string
*/
public function getRawData() {
return $this->rawData;
}
}