Skip to content

Commit c7d53b8

Browse files
committed
Add mutating functions to increment the cursor
1 parent 60e3761 commit c7d53b8

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

Sources/BinaryKit/BinaryKit.swift

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,16 @@ public struct Binary {
4141
return bitCursor + (bytes * byteSize)
4242
}
4343

44+
/// Increments the `bitCursor`-value by the given `bits`.
45+
private mutating func incrementCursorBy(bits: Int) {
46+
bitCursor = incrementedCursorBy(bits: bits)
47+
}
48+
49+
/// Increments the `bitCursor`-value by the given `bytes`.
50+
private mutating func incrementCursorBy(bytes: Int) {
51+
bitCursor = incrementedCursorBy(bytes: bytes)
52+
}
53+
4454
/// Sets the reading cursor back to its initial value.
4555
public mutating func resetCursor() {
4656
self.bitCursor = 0

0 commit comments

Comments
 (0)