Slide 62
Slide 62 text
このインターフェースを通じて 32 ビットや 64 ビットの整数値
を取り出すクラスも作る
final class LittleEndianReader implements IntegerByteSequenceReader
{
public function read8(ByteReaderInterface $data, int $offset): int
{
return $data[$offset];
}
public function read16(ByteReaderInterface $data, int $offset): int
{
return ($data[$offset + 1] << 8) | $data[$offset];
}
public function read32(ByteReaderInterface $data, int $offset): int
{
return ($data[$offset + 3] << 24)
| ($data[$offset + 2] << 16)
| ($data[$offset + 1] << 8)
| $data[$offset];
}