Swiftpack.co - Package - tsolomko/BitByteData

BitByteData

Swift 4 GitHub license Build Status

A Swift framework with classes for reading and writing bits and bytes.

Installation

BitByteData can be integrated into your project using Swift Package Manager, CocoaPods or Carthage.

Swift Package Manager

To install using SPM, add BitByteData to you package dependencies and specify it as a dependency for your target, e.g.:

import PackageDescription

let package = Package(
    name: "PackageName",
    dependencies: [
        .package(url: "https://github.com/tsolomko/BitByteData.git",
                 from: "1.0.0")
    ],
    targets: [
        .target(
            name: "TargetName",
            dependencies: ["BitByteData"]
        )
    ]
)

More details you can find in Swift Package Manager's Documentation.

CocoaPods

Add pod 'BitByteData', '~> 1.0' and use_frameworks! lines to your Podfile.

To complete installation, run pod install.

Carthage

Add to your Cartfile github "tsolomko/BitByteData" ~> 1.0.

Then run carthage update.

Finally, drag and drop BitByteData.framework from Carthage/Build folder into the "Embedded Binaries" section on your targets' "General" tab in Xcode.

Usage

Use ByteReader class to read bytes. For reading bits there are two classes: LsbBitReader and MsbBitReader, which implement BitReader protocol for two bit-numbering schemes ("LSB 0" and "MSB 0" correspondingly). Both LsbBitReader and MsbBitReader classes inherit from ByteReader so you can also use them to read bytes (but they must be aligned, see documentation for more details).

Writing bits is implemented in two classes LsbBitWriter and MsbBitWriter (again, for two bit-numbering schemes). They both conform to BitWriter protocol.

Note: All readers and writers aren't structs, but classes intentionally. This is done to make it easier to pass them as arguments to functions and to eliminate unnecessary copying and inouts.

Documentation

Every function or type of BitByteData's public API is documented. This documentation can be found at its own website.

Contributing

Whether you find a bug, have a suggestion, idea or something else, please create an issue on GitHub.

If you'd like to contribute code, please create a pull request on GitHub.

Note: If you are considering working on BitByteData, please note that Xcode project (BitByteData.xcodeproj) was created manually and you shouldn't use swift package generate-xcodeproj command.

Github

link
Stars: 0
Help us keep the lights on

Dependencies

Used By

Total: 0

Releases

1.0.1 - Jan 6, 2018

  • Made behaviour more consistent in situations when there is not enough data left to complete reading operation.
    • Now it is always a precondition failure instead of default out-of-bounds crash.
    • These preconditions are checked at the beginning of reading functions, so no time is wasted doing something that will not succeed.
  • Increased performance of bit(), bits(count:) and int(fromBits:) functions for both LsbBitReader and MsbBitReader.
  • Small updates to documentation.

1.0.0 - Jan 3, 2018

This is the first release of BitByteData. It includes the following functionality:

  • ByteReader class for reading bytes.
  • BitReader protocol, LsbBitReader and MsbBitReader classes for reading bits (and bytes).
  • BitWriter protocol, LsbBitWriter and MsbBitWriter classes for writing bits (and bytes).

1.0.0-test.3 - Jan 2, 2018

  • Added Xcode project which is used for Carthage support (at least).
  • Added documentation comments.
  • Renamed BitReader.intFromBits(count:) to BitReader.int(fromBits:).
  • Renamed ByteReader.isAtTheEnd to ByteReader.isFinished.
  • BitWriter.align() now does nothing if BitWriter is already aligned.
  • BitReader.bit() now returns UInt8 instead of Int.

1.0.0-test.2 - Dec 26, 2017

  • Added BitWriter protocol and two implementations (LSB and MSB).
  • Added ByteReader's methods to BitReader to improve substitutability.
  • Removed BitReader.bitMask.
  • Added test specification to podspec.

1.0.0-test.1 - Dec 18, 2017

First test release for first release.