AnyBitStream 1.0.17
See the version list below for details.
dotnet add package AnyBitStream --version 1.0.17
NuGet\Install-Package AnyBitStream -Version 1.0.17
<PackageReference Include="AnyBitStream" Version="1.0.17" />
paket add AnyBitStream --version 1.0.17
#r "nuget: AnyBitStream, 1.0.17"
// Install AnyBitStream as a Cake Addin #addin nuget:?package=AnyBitStream&version=1.0.17 // Install AnyBitStream as a Cake Tool #tool nuget:?package=AnyBitStream&version=1.0.17
AnyBitStream
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 | Versions 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. |
-
.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.
Work with bits efficiently in a stream using standard streams and extending BinaryReader/BinaryWriter.