BitwiseOp
in package
Bit operations. Create bit operations used by client operate command.
Offset orientation is left-to-right. Negative offsets are supported. If the offset is negative, the offset starts backwards from end of the bitmap. If an offset is out of bounds, a parameter error will be returned.
Nested CDT operations are supported by optional CTX context arguments. Example: bin = [[0b00000001, 0b01000010],[0b01011010]] Resize first bitmap (in a list of bitmaps) to 3 bytes. BitOperation.resize("bin", 3, BitResizeFlags.DEFAULT, CTX.listIndex(0)) bin result = [[0b00000001, 0b01000010, 0b00000000],[0b01011010]]
Table of Contents
Methods
- add() : Operation
- BitAddOp creates bit "add" operation.
- and() : Operation
- BitAndOp creates bit "and" operation.
- count() : Operation
- BitCountOp creates bit "count" operation.
- get() : Operation
- BitGetOp creates bit "get" operation.
- getInt() : Operation
- BitGetIntOp creates bit "get integer" operation.
- insert() : Operation
- BitInsertOp creates byte "insert" operation.
- lscan() : Operation
- BitLScanOp creates bit "left scan" operation.
- lshift() : Operation
- BitLShiftOp creates bit "left shift" operation.
- not() : Operation
- BitNotOp creates bit "not" operation.
- or() : Operation
- BitOrOp creates bit "or" operation.
- remove() : Operation
- BitRemoveOp creates byte "remove" operation.
- resize() : Operation
- BitResizeOp creates byte "resize" operation.
- rscan() : Operation
- BitRScanOp creates bit "right scan" operation.
- rshift() : Operation
- BitRShiftOp creates bit "right shift" operation.
- set() : Operation
- BitSetOp creates bit "set" operation.
- setInt() : Operation
- BitSetIntOp creates bit "setInt" operation.
- subtract() : Operation
- BitSubtractOp creates bit "subtract" operation.
- xor() : Operation
- BitXorOp creates bit "exclusive or" operation.
Methods
add()
BitAddOp creates bit "add" operation.
public
static add(BitwisePolicy $policy, string $bin_name, int $bit_offset, int $bit_size, int $value, bool $signed, mixed $action, array<string|int, mixed>|null $ctx) : Operation
Server adds value to []byte bin starting at bitOffset for bitSize. BitSize must be <= 64. Signed indicates if bits should be treated as a signed number. If add overflows/underflows, BitOverflowAction is used. Server does not return a value. Example:
bin = [0b00000001, 0b01000010, 0b00000011, 0b00000100, 0b00000101] bitOffset = 24 bitSize = 16 value = 128 signed = false bin result = [0b00000001, 0b01000010, 0b00000011, 0b00000100, 0b10000101]
Parameters
- $policy : BitwisePolicy
- $bin_name : string
- $bit_offset : int
- $bit_size : int
- $value : int
- $signed : bool
- $action : mixed
- $ctx : array<string|int, mixed>|null
Return values
Operationand()
BitAndOp creates bit "and" operation.
public
static and(BitwisePolicy $policy, string $bin_name, int $bit_offset, int $bit_size, array<string|int, mixed> $value, array<string|int, mixed>|null $ctx) : Operation
Server performs bitwise "and" on value and []byte bin at bitOffset for bitSize. Server does not return a value. Example:
bin = [0b00000001, 0b01000010, 0b00000011, 0b00000100, 0b00000101] bitOffset = 23 bitSize = 9 value = [0b00111100, 0b10000000] bin result = [0b00000001, 0b01000010, 0b00000010, 0b00000000, 0b00000101]
Parameters
- $policy : BitwisePolicy
- $bin_name : string
- $bit_offset : int
- $bit_size : int
- $value : array<string|int, mixed>
- $ctx : array<string|int, mixed>|null
Return values
Operationcount()
BitCountOp creates bit "count" operation.
public
static count(string $bin_name, int $bit_offset, int $bit_size, array<string|int, mixed>|null $ctx) : Operation
Server returns integer count of set bits from []byte bin starting at bitOffset for bitSize. Example:
bin = [0b00000001, 0b01000010, 0b00000011, 0b00000100, 0b00000101] bitOffset = 20 bitSize = 4 returns 2
Parameters
- $bin_name : string
- $bit_offset : int
- $bit_size : int
- $ctx : array<string|int, mixed>|null
Return values
Operationget()
BitGetOp creates bit "get" operation.
public
static get(string $bin_name, int $bit_offset, int $bit_size, array<string|int, mixed>|null $ctx) : Operation
Server returns bits from []byte bin starting at bitOffset for bitSize. Example:
bin = [0b00000001, 0b01000010, 0b00000011, 0b00000100, 0b00000101] bitOffset = 9 bitSize = 5 returns [0b1000000]
Parameters
- $bin_name : string
- $bit_offset : int
- $bit_size : int
- $ctx : array<string|int, mixed>|null
Return values
OperationgetInt()
BitGetIntOp creates bit "get integer" operation.
public
static getInt(string $bin_name, int $bit_offset, int $bit_size, bool $signed, array<string|int, mixed>|null $ctx) : Operation
Server returns integer from []byte bin starting at bitOffset for bitSize. Signed indicates if bits should be treated as a signed number. Example:
bin = [0b00000001, 0b01000010, 0b00000011, 0b00000100, 0b00000101] bitOffset = 8 bitSize = 16 signed = false returns 16899
Parameters
- $bin_name : string
- $bit_offset : int
- $bit_size : int
- $signed : bool
- $ctx : array<string|int, mixed>|null
Return values
Operationinsert()
BitInsertOp creates byte "insert" operation.
public
static insert(BitwisePolicy $policy, string $bin_name, int $byte_offset, array<string|int, mixed> $value, array<string|int, mixed>|null $ctx) : Operation
Server inserts value bytes into []byte bin at byteOffset. Server does not return a value. Example:
$bin = [0b00000001, 0b01000010, 0b00000011, 0b00000100, 0b00000101] $byteOffset = 1 $value = [0b11111111, 0b11000111] $bin result = [0b00000001, 0b11111111, 0b11000111, 0b01000010, 0b00000011, 0b00000100, 0b00000101]
Parameters
- $policy : BitwisePolicy
- $bin_name : string
- $byte_offset : int
- $value : array<string|int, mixed>
- $ctx : array<string|int, mixed>|null
Return values
Operationlscan()
BitLScanOp creates bit "left scan" operation.
public
static lscan(string $bin_name, int $bit_offset, int $bit_size, bool $value, array<string|int, mixed>|null $ctx) : Operation
Server returns integer bit offset of the first specified value bit in []byte bin starting at bitOffset for bitSize. Example:
bin = [0b00000001, 0b01000010, 0b00000011, 0b00000100, 0b00000101] bitOffset = 24 bitSize = 8 value = true returns 5
Parameters
- $bin_name : string
- $bit_offset : int
- $bit_size : int
- $value : bool
- $ctx : array<string|int, mixed>|null
Return values
Operationlshift()
BitLShiftOp creates bit "left shift" operation.
public
static lshift(BitwisePolicy $policy, string $bin_name, int $bit_offset, int $bit_size, int $shift, array<string|int, mixed>|null $ctx) : Operation
Server shifts left []byte bin starting at bitOffset for bitSize. Server does not return a value. Example:
bin = [0b00000001, 0b01000010, 0b00000011, 0b00000100, 0b00000101] bitOffset = 32 bitSize = 8 shift = 3 bin result = [0b00000001, 0b01000010, 0b00000011, 0b00000100, 0b00101000]
Parameters
- $policy : BitwisePolicy
- $bin_name : string
- $bit_offset : int
- $bit_size : int
- $shift : int
- $ctx : array<string|int, mixed>|null
Return values
Operationnot()
BitNotOp creates bit "not" operation.
public
static not(BitwisePolicy $policy, string $bin_name, int $bit_offset, int $bit_size, array<string|int, mixed>|null $ctx) : Operation
Server negates []byte bin starting at bitOffset for bitSize. Server does not return a value. Example:
bin = [0b00000001, 0b01000010, 0b00000011, 0b00000100, 0b00000101] bitOffset = 25 bitSize = 6 bin result = [0b00000001, 0b01000010, 0b00000011, 0b01111010, 0b00000101]
Parameters
- $policy : BitwisePolicy
- $bin_name : string
- $bit_offset : int
- $bit_size : int
- $ctx : array<string|int, mixed>|null
Return values
Operationor()
BitOrOp creates bit "or" operation.
public
static or(BitwisePolicy $policy, string $bin_name, int $bit_offset, int $bit_size, array<string|int, mixed> $value, array<string|int, mixed>|null $ctx) : Operation
Server performs bitwise "or" on value and []byte bin at bitOffset for bitSize. Server does not return a value. Example:
$bin = [0b00000001, 0b01000010, 0b00000011, 0b00000100, 0b00000101] $bitOffset = 17 $bitSize = 6 $value = [0b10101000] bin result = [0b00000001, 0b01000010, 0b01010111, 0b00000100, 0b00000101]
Parameters
- $policy : BitwisePolicy
- $bin_name : string
- $bit_offset : int
- $bit_size : int
- $value : array<string|int, mixed>
- $ctx : array<string|int, mixed>|null
Return values
Operationremove()
BitRemoveOp creates byte "remove" operation.
public
static remove(BitwisePolicy $policy, string $bin_name, int $byte_offset, int $byte_size, array<string|int, mixed>|null $ctx) : Operation
Server removes bytes from []byte bin at byteOffset for byteSize. Server does not return a value. Example:
$bin = [0b00000001, 0b01000010, 0b00000011, 0b00000100, 0b00000101] $byteOffset = 2 $byteSize = 3 $bin result = [0b00000001, 0b01000010]
Parameters
- $policy : BitwisePolicy
- $bin_name : string
- $byte_offset : int
- $byte_size : int
- $ctx : array<string|int, mixed>|null
Return values
Operationresize()
BitResizeOp creates byte "resize" operation.
public
static resize(BitwisePolicy $policy, string $bin_name, int $byte_size, mixed $resize_flags, array<string|int, mixed>|null $ctx) : Operation
Server resizes []byte to byteSize according to resizeFlags (See BitResizeFlags). Server does not return a value. Example:
$bin = [0b00000001, 0b01000010] $byteSize = 4 $resizeFlags = 0 $bin result = [0b00000001, 0b01000010, 0b00000000, 0b00000000]
Parameters
- $policy : BitwisePolicy
- $bin_name : string
- $byte_size : int
- $resize_flags : mixed
- $ctx : array<string|int, mixed>|null
Return values
Operationrscan()
BitRScanOp creates bit "right scan" operation.
public
static rscan(string $bin_name, int $bit_offset, int $bit_size, bool $value, array<string|int, mixed>|null $ctx) : Operation
Server returns integer bit offset of the last specified value bit in []byte bin starting at bitOffset for bitSize. Example:
bin = [0b00000001, 0b01000010, 0b00000011, 0b00000100, 0b00000101] bitOffset = 32 bitSize = 8 value = true returns 7
Parameters
- $bin_name : string
- $bit_offset : int
- $bit_size : int
- $value : bool
- $ctx : array<string|int, mixed>|null
Return values
Operationrshift()
BitRShiftOp creates bit "right shift" operation.
public
static rshift(BitwisePolicy $policy, string $bin_name, int $bit_offset, int $bit_size, int $shift, array<string|int, mixed>|null $ctx) : Operation
Server shifts right []byte bin starting at bitOffset for bitSize. Server does not return a value. Example:
bin = [0b00000001, 0b01000010, 0b00000011, 0b00000100, 0b00000101] bitOffset = 0 bitSize = 9 shift = 1 bin result = [0b00000000, 0b11000010, 0b00000011, 0b00000100, 0b00000101]
Parameters
- $policy : BitwisePolicy
- $bin_name : string
- $bit_offset : int
- $bit_size : int
- $shift : int
- $ctx : array<string|int, mixed>|null
Return values
Operationset()
BitSetOp creates bit "set" operation.
public
static set(BitwisePolicy $policy, string $bin_name, int $bit_offset, int $bit_size, array<string|int, mixed> $value, array<string|int, mixed>|null $ctx) : Operation
Server sets value on []byte bin at bitOffset for bitSize. Server does not return a value. Example:
$bin = [0b00000001, 0b01000010, 0b00000011, 0b00000100, 0b00000101] $bitOffset = 13 $bitSize = 3 $value = [0b11100000] $bin result = [0b00000001, 0b01000111, 0b00000011, 0b00000100, 0b00000101]
Parameters
- $policy : BitwisePolicy
- $bin_name : string
- $bit_offset : int
- $bit_size : int
- $value : array<string|int, mixed>
- $ctx : array<string|int, mixed>|null
Return values
OperationsetInt()
BitSetIntOp creates bit "setInt" operation.
public
static setInt(BitwisePolicy $policy, string $bin_name, int $bit_offset, int $bit_size, int $value, array<string|int, mixed>|null $ctx) : Operation
Server sets value to []byte bin starting at bitOffset for bitSize. Size must be <= 64. Server does not return a value. Example:
bin = [0b00000001, 0b01000010, 0b00000011, 0b00000100, 0b00000101] bitOffset = 1 bitSize = 8 value = 127 bin result = [0b00111111, 0b11000010, 0b00000011, 0b0000100, 0b00000101]
Parameters
- $policy : BitwisePolicy
- $bin_name : string
- $bit_offset : int
- $bit_size : int
- $value : int
- $ctx : array<string|int, mixed>|null
Return values
Operationsubtract()
BitSubtractOp creates bit "subtract" operation.
public
static subtract(BitwisePolicy $policy, string $bin_name, int $bit_offset, int $bit_size, int $value, bool $signed, mixed $action, array<string|int, mixed>|null $ctx) : Operation
Server subtracts value from []byte bin starting at bitOffset for bitSize. BitSize must be <= 64. Signed indicates if bits should be treated as a signed number. If add overflows/underflows, BitOverflowAction is used. Server does not return a value. Example:
bin = [0b00000001, 0b01000010, 0b00000011, 0b00000100, 0b00000101] bitOffset = 24 bitSize = 16 value = 128 signed = false bin result = [0b00000001, 0b01000010, 0b00000011, 0b0000011, 0b10000101]
Parameters
- $policy : BitwisePolicy
- $bin_name : string
- $bit_offset : int
- $bit_size : int
- $value : int
- $signed : bool
- $action : mixed
- $ctx : array<string|int, mixed>|null
Return values
Operationxor()
BitXorOp creates bit "exclusive or" operation.
public
static xor(BitwisePolicy $policy, string $bin_name, int $bit_offset, int $bit_size, array<string|int, mixed> $value, array<string|int, mixed>|null $ctx) : Operation
Server performs bitwise "xor" on value and []byte bin at bitOffset for bitSize. Server does not return a value. Example:
bin = [0b00000001, 0b01000010, 0b00000011, 0b00000100, 0b00000101] bitOffset = 17 bitSize = 6 value = [0b10101100] bin result = [0b00000001, 0b01000010, 0b01010101, 0b00000100, 0b00000101]
Parameters
- $policy : BitwisePolicy
- $bin_name : string
- $bit_offset : int
- $bit_size : int
- $value : array<string|int, mixed>
- $ctx : array<string|int, mixed>|null