Ara3D.Buffers
1.4.3
See the version list below for details.
dotnet add package Ara3D.Buffers --version 1.4.3
NuGet\Install-Package Ara3D.Buffers -Version 1.4.3
<PackageReference Include="Ara3D.Buffers" Version="1.4.3" />
paket add Ara3D.Buffers --version 1.4.3
#r "nuget: Ara3D.Buffers, 1.4.3"
// Install Ara3D.Buffers as a Cake Addin #addin nuget:?package=Ara3D.Buffers&version=1.4.3 // Install Ara3D.Buffers as a Cake Tool #tool nuget:?package=Ara3D.Buffers&version=1.4.3
Ara3D.Buffers
Utilities for working with large arrays of unmanaged types.
IBuffer
The IBuffer
interface is presents a simple interface for an
array of unmanaged types, where the type is not known at compile-time.
This allows us to work more easily with collections of buffers where the underlying type can vary at run-time.
public interface IBuffer
{
Array Data { get; }
void WithPointer(Action<IntPtr> action);
int ElementSize { get; }
}
The total number of bytes is determined by multiply the data array by the element size. This is provided in an extension function
public static long GetNumBytes(this IBuffer buffer)
=> (long)buffer.NumElements() * buffer.ElementSize;
Accessing the raw bytes can be done using a pattern similar to:
public static unsafe void Write(this Stream stream, IBuffer buffer)
=> buffer.WithPointer(ptr => {
stream.WriteBytesBuffered((byte*)ptr.ToPointer(), buffer.GetNumBytes());
});
INamedBuffer
Frequently a buffer is associated with a name or identifier.
The INamedBuffer
introduces a string name property, for convenience.
public interface INamedBuffer : IBuffer
{
string Name { get; }
}
Generic Versions
There exist generic versions of the interfaces as well, which provide access to the underlying data array.
public interface IBuffer<out T> : IBuffer
where T: unmanaged
{
T[] GetTypedData();
}
public interface INamedBuffer<out T>
: INamedBuffer, IBuffer<T> where T: unmanaged
{
}
Use Case
This structure is particularly useful when serializing and manipulating raw memory such as attribute buffers associated with 3D geometry, ZIP files (or other binary archive formats), or color data associated with bitmaps.
Documentation
This is a very small library, and we recommend reading the source code and looking at some projects that use it:
- Ara3D.Graphics
- Ara3D.Serialization.BFAST
- Ara3D.Serialization.G3D
- Ara3D.Serialization.VIM
Size Limitations
Due to limitations in C# the array can have at most 2^31 elements (approximately 2 billion).
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 was computed. 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 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. 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. |
-
.NETStandard 2.0
- No dependencies.
NuGet packages (4)
Showing the top 4 NuGet packages that depend on Ara3D.Buffers:
Package | Downloads |
---|---|
Ara3D.Serialization.BFAST
A library for reading and writing collections of arrays of binary data (archives). |
|
Ara3D.Serialization.VIM
A library for reading and writing architectural BIM models in the VIM format. |
|
Ara3D.Graphics
A library for working with and rendering 2D and 3D graphics. |
|
Speckle.WebIfc.Importer
Package Description |
GitHub repositories
This package is not used by any popular GitHub repositories.