2.0.0
In this release the API design of BitByteData has been reworked. Additionally, new functionality for correctly dealing with signed integers and their bit representations has been added. You may find a new Migration to 2.0 section in the README which should be helpful in adopting the new changes. You may also refer to the API Design document for some additional context and reasoning behind the changes.
Byte Reading
ByteReader
class has been renamed toLittleEndianByteReader
.LittleEndianByteReader
(ex-ByteReader
) is now a final class.LsbBitReader
andMsbBitReader
are no longer its subclasses.
- Added a new
BigEndianByteReader
class with the same set of APIs asLittleEndianByteReader
. - Added a
ByteReader
protocol which inheritsAnyObject
.- Most of the methods and properties of the previously existing
ByteReader
class are now requirements of the new protocol. ByteReader
provides default implementations for the initializer, which performs conversion from aBitReader
, and for thebytesLeft
,bytesRead
, andisFinished
properties (all of these are not protocol requirements).- In addition,
ByteReader
provides a default implementation for theint(fromBytes:)
method. - Both
LittleEndianByteReader
andBigEndianByteReader
now conform to theByteReader
protocol.
- Most of the methods and properties of the previously existing
Bit Reading
- Added a
SignedNumberRepresentation
enum with five cases and two instance methods. - The
BitReader
protocol now inherits theByteReader
protocol.- Two new method requirements have been added to the
BitReader
protocol:signedInt(fromBits:representation:)
andadvance(by:)
. BitReader
now provides a default implementation forint(fromBits:)
.
- Two new method requirements have been added to the
- It is no longer possible to set the
offset
property of theLsbBitReader
andMsbBitReader
classes if they are not aligned (a precondition crash occurs instead). - The
signedInt(fromBits:representation:)
function has been added to theLsbBitReader
andMsbBitReader
classes with the default value ofSignedNumberRepresentation.twoComplementNegatives
for therepresentation
argument.
Bit Writing
- Two new method requirements have been added to the
BitWriter
protocol:write(unsignedNumber:bitsCount:)
andwrite(signedNumber:bitsCount:representation:)
. BitWriter
now provides default implementations forwrite(signedNumber:bitsCount:representation:)
andwrite(number:bitsCount:)
.- The default implementation of the
write(number:bitsCount:)
function now has a precondition crash if thebitsCount
argument exceeds the bit width of the integer type on the current platform.
- The default implementation of the
- The
write(unsignedNumber:bitsCount:)
function of theLsbBitWriter
andMsbBitWriter
classes now has a precondition crash if thebitsCount
argument exceeds the bit width of the integer type on the current platform.
General
- Swift 4.2 is no longer supported. For reference, the following platforms and Swift versions are supported at the time of this release:
- Apple platforms: Swift 5.0+
- Linux: Swift 5.0+
- Windows: Swift 5.4+
- Minimum iOS deployment version (when installed via CocoaPods or Carthage) is now 9.0.
- Documentation has been updated.
- Added documentation for new APIs.
- A couple of missing precondition checks are now properly documented.
- Existing documentation has been made more concise and slightly more grammatically correct.