Less_SourceMap_Base64VLQ
in package
Encode / Decode Base64 VLQ.
Tags
Table of Contents
- $charToIntMap : array<string|int, mixed>
- Char to integer map
- $continuationBit : int
- Continuation bit
- $intToCharMap : array<string|int, mixed>
- Integer to char map
- $mask : int
- Mask
- $shift : int
- Shift
- __construct() : mixed
- Constructor
- base64Decode() : number
- Decode single 6-bit digit from base64
- base64Encode() : string
- Encode single 6-bit digit as base64.
- decode() : int
- Return the value decoded from base 64 VLQ.
- encode() : string
- Return the base 64 VLQ encoded value.
- fromVLQSigned() : mixed
- Convert to a two-complement value from a value where the sign bit is is placed in the least significant bit. For example, as decimals: 2 (10 binary) becomes 1, 3 (11 binary) becomes -1 4 (100 binary) becomes 2, 5 (101 binary) becomes -2 We assume that the value was generated with a 32 bit machine in mind.
- toVLQSigned() : mixed
- Convert from a two-complement value to a value where the sign bit is is placed in the least significant bit. For example, as decimals: 1 becomes 2 (10 binary), -1 becomes 3 (11 binary) 2 becomes 4 (100 binary), -2 becomes 5 (101 binary) We generate the value for 32 bit machines, hence -2147483648 becomes 1, not 4294967297, even on a 64 bit machine.
- zeroFill() : int
- Right shift with zero fill.
Properties
$charToIntMap
Char to integer map
private
array<string|int, mixed>
$charToIntMap
= array('A' => 0, 'B' => 1, 'C' => 2, 'D' => 3, 'E' => 4, 'F' => 5, 'G' => 6, 'H' => 7, 'I' => 8, 'J' => 9, 'K' => 10, 'L' => 11, 'M' => 12, 'N' => 13, 'O' => 14, 'P' => 15, 'Q' => 16, 'R' => 17, 'S' => 18, 'T' => 19, 'U' => 20, 'V' => 21, 'W' => 22, 'X' => 23, 'Y' => 24, 'Z' => 25, 'a' => 26, 'b' => 27, 'c' => 28, 'd' => 29, 'e' => 30, 'f' => 31, 'g' => 32, 'h' => 33, 'i' => 34, 'j' => 35, 'k' => 36, 'l' => 37, 'm' => 38, 'n' => 39, 'o' => 40, 'p' => 41, 'q' => 42, 'r' => 43, 's' => 44, 't' => 45, 'u' => 46, 'v' => 47, 'w' => 48, 'x' => 49, 'y' => 50, 'z' => 51, 0 => 52, 1 => 53, 2 => 54, 3 => 55, 4 => 56, 5 => 57, 6 => 58, 7 => 59, 8 => 60, 9 => 61, '+' => 62, '/' => 63)
$continuationBit
Continuation bit
private
int
$continuationBit
= 0x20
$intToCharMap
Integer to char map
private
array<string|int, mixed>
$intToCharMap
= array(0 => 'A', 1 => 'B', 2 => 'C', 3 => 'D', 4 => 'E', 5 => 'F', 6 => 'G', 7 => 'H', 8 => 'I', 9 => 'J', 10 => 'K', 11 => 'L', 12 => 'M', 13 => 'N', 14 => 'O', 15 => 'P', 16 => 'Q', 17 => 'R', 18 => 'S', 19 => 'T', 20 => 'U', 21 => 'V', 22 => 'W', 23 => 'X', 24 => 'Y', 25 => 'Z', 26 => 'a', 27 => 'b', 28 => 'c', 29 => 'd', 30 => 'e', 31 => 'f', 32 => 'g', 33 => 'h', 34 => 'i', 35 => 'j', 36 => 'k', 37 => 'l', 38 => 'm', 39 => 'n', 40 => 'o', 41 => 'p', 42 => 'q', 43 => 'r', 44 => 's', 45 => 't', 46 => 'u', 47 => 'v', 48 => 'w', 49 => 'x', 50 => 'y', 51 => 'z', 52 => '0', 53 => '1', 54 => '2', 55 => '3', 56 => '4', 57 => '5', 58 => '6', 59 => '7', 60 => '8', 61 => '9', 62 => '+', 63 => '/')
$mask
Mask
private
int
$mask
= 0x1f
$shift
Shift
private
int
$shift
= 5
Methods
__construct()
Constructor
public
__construct() : mixed
Return values
mixed —base64Decode()
Decode single 6-bit digit from base64
public
base64Decode(string $char) : number
Parameters
- $char : string
Tags
Return values
number —base64Encode()
Encode single 6-bit digit as base64.
public
base64Encode(int $number) : string
Parameters
- $number : int
Tags
Return values
string —decode()
Return the value decoded from base 64 VLQ.
public
decode(string $encoded) : int
Parameters
- $encoded : string
-
The encoded value to decode
Return values
int —The decoded value
encode()
Return the base 64 VLQ encoded value.
public
encode(string $aValue) : string
Parameters
- $aValue : string
-
The value to encode
Return values
string —The encoded value
fromVLQSigned()
Convert to a two-complement value from a value where the sign bit is is placed in the least significant bit. For example, as decimals: 2 (10 binary) becomes 1, 3 (11 binary) becomes -1 4 (100 binary) becomes 2, 5 (101 binary) becomes -2 We assume that the value was generated with a 32 bit machine in mind.
public
fromVLQSigned(int $aValue) : mixed
Hence 1 becomes -2147483648 even on a 64 bit machine.
Parameters
- $aValue : int
Return values
mixed —toVLQSigned()
Convert from a two-complement value to a value where the sign bit is is placed in the least significant bit. For example, as decimals: 1 becomes 2 (10 binary), -1 becomes 3 (11 binary) 2 becomes 4 (100 binary), -2 becomes 5 (101 binary) We generate the value for 32 bit machines, hence -2147483648 becomes 1, not 4294967297, even on a 64 bit machine.
public
toVLQSigned(string $aValue) : mixed
Parameters
- $aValue : string
Return values
mixed —zeroFill()
Right shift with zero fill.
public
zeroFill(int $a, int $b) : int
Parameters
- $a : int
-
number to shift
- $b : int
-
number of bits to shift