Skip to content

Commit 51b8ce8

Browse files
committed
Add converting init to BitReader protocol
1 parent 123b3ab commit 51b8ce8

3 files changed

Lines changed: 9 additions & 5 deletions

File tree

Sources/BitReader.swift

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,11 @@ public protocol BitReader: class {
2020
/// Creates an instance for reading bits (and bytes) from `data`.
2121
init(data: Data)
2222

23-
// TODO: Add `init(_ byteReader: ByteReader)`?
23+
/**
24+
Converts a `ByteReader` instance into `BitReader`, enabling bits reading capabilities. Current `offset` value of
25+
`byteReader` is preserved.
26+
*/
27+
init(_ byteReader: ByteReader)
2428

2529
/// Reads bit and returns it, advancing by one BIT position.
2630
func bit() -> UInt8

Sources/LsbBitReader.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,8 @@ public final class LsbBitReader: ByteReader, BitReader {
4242
}
4343

4444
/**
45-
Converts a `ByteReader` instance into `LsbBitReader`, enabling bits reading capabilities.
46-
Current `offset` value of `byteReader` is preserved.
45+
Converts a `ByteReader` instance into `LsbBitReader`, enabling bit reading capabilities. Current `offset` value of
46+
`byteReader` is preserved.
4747
*/
4848
public init(_ byteReader: ByteReader) {
4949
self.currentByte = byteReader.offset < byteReader.data.endIndex ? byteReader.data[byteReader.offset] : 0

Sources/MsbBitReader.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,8 @@ public final class MsbBitReader: ByteReader, BitReader {
4242
}
4343

4444
/**
45-
Converts a `ByteReader` instance into `MsbBitReader`, enabling bit reading capabilities.
46-
Current `offset` value of `byteReader` is preserved.
45+
Converts a `ByteReader` instance into `MsbBitReader`, enabling bit reading capabilities. Current `offset` value of
46+
`byteReader` is preserved.
4747
*/
4848
public init(_ byteReader: ByteReader) {
4949
self.currentByte = byteReader.offset < byteReader.data.endIndex ? byteReader.data[byteReader.offset] : 0

0 commit comments

Comments
 (0)