AnyBitStream 1.0.20

dotnet add package AnyBitStream --version 1.0.20                
NuGet\Install-Package AnyBitStream -Version 1.0.20                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="AnyBitStream" Version="1.0.20" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add AnyBitStream --version 1.0.20                
#r "nuget: AnyBitStream, 1.0.20"                
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install AnyBitStream as a Cake Addin
#addin nuget:?package=AnyBitStream&version=1.0.20

// Install AnyBitStream as a Cake Tool
#tool nuget:?package=AnyBitStream&version=1.0.20                

AnyBitStream

nuget nuget Build status Codacy Badge

Work with bits efficiently in a stream using standard streams and extending BinaryReader/BinaryWriter.

Description

AnyBitStream is an efficient stream based class for working with data at the bit level. It supports non-standard numeric types such as Int2 to Int7, Int10,Int12,Int24,Int48 and is perfect for working with network protocols or general bit-packing operations.

Installation

Install AnyBitStream from the Package Manager Console:

PM> Install-Package AnyBitStream

Usage

using AnyBitStream;

var buffer = new byte[64] { // some byte data };
var stream = new BitStream(buffer);
var reader = new BitStreamReader(stream);

// read a 12 byte header
var header = new MyHeader {
  Marker = reader.ReadInt4(),
  ContinuityId = reader.ReadInt3(),
  IsValid = reader.ReadBit(),
  Length = reader.ReadInt32()
};
// read in some bytes
var data = reader.ReadBytes(header.Length);

Unaligned vs Aligned bytes

By default, the BitStream will not allow unaligned data to be read/written. For example, if you've read 5 bits and then try to read a byte an exception will be thrown. Because you tried to read a byte that doesn't reside on a byte boundary (8 bits) it doesn't want to give you potentially bad data. However sometimes this behavior is desired with certain bit packing formats.

To enable reading/writing unaligned data:

// via constructor(s) on the stream
var stream = new BitStream(true);
var stream = new BitStream(buffer, writable: true, allowUnalignedOperations: true);
// via property
stream.AllowUnalignedOperations = true;
// also available via the reader/writers
var reader = new BitStreamReader(stream, leaveOpen: true, allowUnalignedOperations: true);
var writer = new BitStreamWriter(stream, leaveOpen: true, allowUnalignedOperations: true);

See more on reading unaligned streams in the wiki.

Product Compatible and additional computed target framework versions.
.NET net5.0 is compatible.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
.NET Core netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 was computed. 
.NET Framework net461 is compatible.  net462 is compatible.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 is compatible.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • .NETFramework 4.6.1

    • No dependencies.
  • .NETFramework 4.6.2

    • No dependencies.
  • .NETFramework 4.8

    • No dependencies.
  • .NETStandard 2.0

    • No dependencies.
  • net5.0

    • No dependencies.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.0.20 1,893 3/4/2021
1.0.19 396 3/4/2021
1.0.18 370 3/3/2021
1.0.17 353 3/3/2021
1.0.16 335 3/3/2021
1.0.15 362 3/2/2021
1.0.14 359 3/2/2021
1.0.10 349 3/1/2021
1.0.7 343 3/1/2021
1.0.3 331 3/1/2021

Work with bits efficiently in a stream using standard streams and extending BinaryReader/BinaryWriter.