SetaPDF_Core_BitConverter A class that allows you to convert base data types to bytes and vice versa.

File: /SetaPDF v2/Core/BitConverter.php

Class hierarchy

Summary

Constants

BYTE

public const SetaPDF_Core_BitConverter::BYTE = 'UInt8'

BYTE_ORDER_BIG_ENDIAN

public const string SetaPDF_Core_BitConverter::BYTE_ORDER_BIG_ENDIAN = 'bigEndian'

Constant for big endian byte order.

BYTE_ORDER_LITTLE_ENDIAN

public const string SetaPDF_Core_BitConverter::BYTE_ORDER_LITTLE_ENDIAN = 'littleEndian'

Constant for little endian byte order.

CHAR

public const SetaPDF_Core_BitConverter::CHAR = 'Int8'

FIXED

public const SetaPDF_Core_BitConverter::FIXED = 'Fixed'

INT16

public const SetaPDF_Core_BitConverter::INT16 = 'Int16'

INT32

public const SetaPDF_Core_BitConverter::INT32 = 'Int32'

INT8

public const SetaPDF_Core_BitConverter::INT8 = 'Int8'

LONG

public const SetaPDF_Core_BitConverter::LONG = 'Int32'

SHORT

public const SetaPDF_Core_BitConverter::SHORT = 'Int16'

UINT16

public const SetaPDF_Core_BitConverter::UINT16 = 'UInt16'

UINT32

public const SetaPDF_Core_BitConverter::UINT32 = 'UInt32'

UINT8

public const SetaPDF_Core_BitConverter::UINT8 = 'UInt8'

ULONG

public const SetaPDF_Core_BitConverter::ULONG = 'UInt32'

USHORT

public const SetaPDF_Core_BitConverter::USHORT = 'UInt16'

Static Properties

$_machineByteOrder

The machine byte order.


Static Methods

formatFromFixed()

public static SetaPDF_Core_BitConverter::formatFromFixed (
string $bytes
): float

Reads a 32-bit signed fixed-point number.

Parameters
$bytes : string
 

formatFromInt()

public static SetaPDF_Core_BitConverter::formatFromInt (
string $byte, integer $size
): integer

Reads a signed integer.

Parameters
$byte : string
 
$size : integer
 

formatFromInt16()

public static SetaPDF_Core_BitConverter::formatFromInt16 (
string $bytes [, string $byteOrder = SetaPDF_Core_BitConverter::BYTE_ORDER_BIG_ENDIAN ]
): integer

Reads a 16-bit signed integer.

Parameters
$bytes : string
 
$byteOrder : string
 

formatFromInt32()

public static SetaPDF_Core_BitConverter::formatFromInt32 (
string $bytes [, string $byteOrder = SetaPDF_Core_BitConverter::BYTE_ORDER_BIG_ENDIAN ]
): mixed

Reads a 32-bit signed integer.

Parameters
$bytes : string
 
$byteOrder : string
 

formatFromInt8()

public static SetaPDF_Core_BitConverter::formatFromInt8 (
string $byte
): integer

Reads a 8-bit/1-byte signed integer.

Parameters
$byte : string
 

formatFromUInt()

public static SetaPDF_Core_BitConverter::formatFromUInt (
string $byte, integer $size
): integer

Reads an unsigned integer.

Parameters
$byte : string
 
$size : integer
 

formatFromUInt16()

public static SetaPDF_Core_BitConverter::formatFromUInt16 (
string $bytes [, string $byteOrder = SetaPDF_Core_BitConverter::BYTE_ORDER_BIG_ENDIAN ]
): integer

Reads a 16-bit unsigned integer.

Parameters
$bytes : string
 
$byteOrder : string
 

formatFromUInt32()

public static SetaPDF_Core_BitConverter::formatFromUInt32 (
string $bytes [, string $byteOrder = SetaPDF_Core_BitConverter::BYTE_ORDER_BIG_ENDIAN ]
): mixed

Reads a 32-bit unsigned integer.

Parameters
$bytes : string
 
$byteOrder : string
 

formatFromUInt8()

public static SetaPDF_Core_BitConverter::formatFromUInt8 (
string $byte
): integer

Reads a 8-bit/1-byte unsigned integer.

Parameters
$byte : string
 

formatToFixed()

public static SetaPDF_Core_BitConverter::formatToFixed (
float $float
): string

Writes a 32-bit signed fixed-point number.

Parameters
$float : float
 

formatToInt()

public static SetaPDF_Core_BitConverter::formatToInt (
integer $int, integer $size
): string

Writes a signed integer.

Parameters
$int : integer
 
$size : integer
 

formatToInt16()

public static SetaPDF_Core_BitConverter::formatToInt16 (
integer $int [, string $byteOrder = SetaPDF_Core_BitConverter::BYTE_ORDER_BIG_ENDIAN ]
): string

Writes a 16-bit signed integer.

Parameters
$int : integer
 
$byteOrder : string
 

formatToInt32()

public static SetaPDF_Core_BitConverter::formatToInt32 (
integer $int [, string $byteOrder = SetaPDF_Core_BitConverter::BYTE_ORDER_BIG_ENDIAN ]
): string

Writes a 32-bit signed integer.

Parameters
$int : integer
 
$byteOrder : string
 

formatToInt8()

public static SetaPDF_Core_BitConverter::formatToInt8 (
integer $int
): string

Writes a 8-bit/1-byte signed integer.

Parameters
$int : integer
 

formatToUInt()

public static SetaPDF_Core_BitConverter::formatToUInt (
integer $int, integer $size
): string

Writes an unsigned integer.

Parameters
$int : integer
 
$size : integer
 

formatToUInt16()

public static SetaPDF_Core_BitConverter::formatToUInt16 (
integer $int [, string $byteOrder = SetaPDF_Core_BitConverter::BYTE_ORDER_BIG_ENDIAN ]
): string

Writes a 16-bit unsigned integer.

Parameters
$int : integer
 
$byteOrder : string
 

formatToUInt32()

public static SetaPDF_Core_BitConverter::formatToUInt32 (
integer $int [, string $byteOrder = SetaPDF_Core_BitConverter::BYTE_ORDER_BIG_ENDIAN ]
): mixed

Formats a 32-bit unsigned integer.

Parameters
$int : integer
 
$byteOrder : string
 

formatToUInt8()

public static SetaPDF_Core_BitConverter::formatToUInt8 (
integer $int
): string

Writes a 8-bit/1-byte unsigned integer.

Parameters
$int : integer
 

getMachineByteOrder()

public static SetaPDF_Core_BitConverter::getMachineByteOrder (
void
): string

Get the machine byte order.

getSize()

public static SetaPDF_Core_BitConverter::getSize (
string $type
): int

Get the size by a specific type.

Parameters
$type : string