BitReader
public protocol BitReader : ByteReader
A type that contains functions for reading Data bit-by-bit and byte-by-byte.
-
True, if a bit pointer is aligned to a byte boundary.
Declaration
Swift
var isAligned: Bool { get } -
Amount of bits left to read.
Declaration
Swift
var bitsLeft: Int { get } -
Amount of bits that were already read.
Declaration
Swift
var bitsRead: Int { get } -
Converts a
ByteReaderinstance into aBitReader, enabling bits reading capabilities. The currentoffsetvalue of thebyteReaderis preserved.Declaration
Swift
init(_ byteReader: ByteReader) -
Advances a bit pointer by the amount of bits.
Declaration
Swift
func advance(by count: Int) -
Reads a bit and returns it, advancing by one bit position.
Declaration
Swift
func bit() -> UInt8 -
Reads
countbits and returns them as a[UInt8]array, advancing bycountbit positions.Declaration
Swift
func bits(count: Int) -> [UInt8] -
int(fromBits:Default implementation) Reads
fromBitsbits and returns them as aIntnumber, advancing byfromBitsbit positions.Default Implementation
Reads
fromBitsbits by either usinguint64(fromBits:)oruint32(fromBits:)depending on the platform’s integer bit width, converts the result toInt, and returns it, advancing byfromBitsbit positions.Note
If the data is supposed to represent a signed integer, it is recommended to use thesignedInt(fromBits:representation:)function to get a correct result.Declaration
Swift
func int(fromBits count: Int) -> Int -
Reads
fromBitsbits, treating them as a binaryrepresenationof a signed integer, and returns the result as aIntnumber, advancing byfromBitsbit positions.Declaration
Swift
func signedInt(fromBits count: Int, representation: SignedNumberRepresentation) -> Int -
Reads
fromBitsbits and returns them as aUInt8number, advancing byfromBitsbit positions.Declaration
Swift
func byte(fromBits count: Int) -> UInt8 -
Reads
fromBitsbits and returns them as aUInt16number, advancing byfromBitsbit positions.Declaration
Swift
func uint16(fromBits count: Int) -> UInt16 -
Reads
fromBitsbits and returns them as aUInt32number, advancing byfromBitsbit positions.Declaration
Swift
func uint32(fromBits count: Int) -> UInt32 -
Reads
fromBitsbits and returns them as aUInt64number, advancing byfromBitsbit positions.Declaration
Swift
func uint64(fromBits count: Int) -> UInt64 -
Aligns a bit pointer to a byte boundary, i.e. moves the bit pointer to the first bit of the next byte.
Declaration
Swift
func align()
View on GitHub
BitReader Protocol Reference