Class rehex.BitOffset
A file offset with bit precision.
NOTE: In addition to the methods below, operator overloads are available on BitOffset objects for addition/subtraction/comparison/etc.
Usage:
local zero = rehex.BitOffset( 0, 0) local one_byte = rehex.BitOffset( 1, 0) local ten_bytes_and_one_bit = rehex.BitOffset(10, 1)
Methods
rehex.BitOffset:bit () | Fetch the bit portion of a BitOffset object. |
rehex.BitOffset:byte () | Fetch the byte portion of a BitOffset object. |
rehex.BitOffset:byte_aligned () | Check if a BitOffset is aligned to a whole number of bytes. |
rehex.BitOffset:byte_round_up () | Fetch the number of bytes in a BitOffset object, rounded up to the nearest whole byte. |
rehex.BitOffset:total_bits () | Fetch the total number of bits in a BitOffset object. |
Methods
- rehex.BitOffset:bit ()
-
Fetch the bit portion of a BitOffset object.
Usage:
my_offset:bit()
- rehex.BitOffset:byte ()
-
Fetch the byte portion of a BitOffset object.
Usage:
my_offset:byte()
- rehex.BitOffset:byte_aligned ()
-
Check if a BitOffset is aligned to a whole number of bytes.
Usage:
my_offset:byte_aligned()
- rehex.BitOffset:byte_round_up ()
-
Fetch the number of bytes in a BitOffset object, rounded up to the nearest whole byte.
Usage:
local byte = my_offset:byte_round_up() rehex.BitOffset(10, 0) --- Returns 10 rehex.BitOffset(10, 1) --- Returns 11
- rehex.BitOffset:total_bits ()
-
Fetch the total number of bits in a BitOffset object.
Usage:
local total_bits = my_offset:total_bits() rehex.BitOffset(10, 0):total_bits() --- Returns 80 rehex.BitOffset(10, 4):total_bits() --- Returns 84