Cxx11BindingsSharp 1.4.0

There is a newer version of this package available.
See the version list below for details.
dotnet add package Cxx11BindingsSharp --version 1.4.0
                    
NuGet\Install-Package Cxx11BindingsSharp -Version 1.4.0
                    
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="Cxx11BindingsSharp" Version="1.4.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Cxx11BindingsSharp" Version="1.4.0" />
                    
Directory.Packages.props
<PackageReference Include="Cxx11BindingsSharp" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Cxx11BindingsSharp --version 1.4.0
                    
#r "nuget: Cxx11BindingsSharp, 1.4.0"
                    
#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.
#:package Cxx11BindingsSharp@1.4.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Cxx11BindingsSharp&version=1.4.0
                    
Install as a Cake Addin
#tool nuget:?package=Cxx11BindingsSharp&version=1.4.0
                    
Install as a Cake Tool

Cxx11BindingsSharp

Introduction

Provide a thin layer to wrap a System.IO.Stream in C# to a portable C++ stream (std::streambuf). The intermediate C layer is exposed and can be used directly in a C11 project. The custom std::streambuf implementation simply uses the portable C layer to call back into the C# stream.

This is somewhat related to System.Runtime.InteropServices.ComTypes.IStream on windows.

Typical usage in your library

In your C# library, you can now write something like:

using Cxx11BindingsSharp;
public void AcmeConvert(System.IO.Stream src, System.IO.Stream dst)
{
  var srcWrap = new ManagedC11Stream(src);
  var dstWrap = new ManagedC11Stream(dst);
  if (NativeService.acme_convert(srcWrap, dstWrap)<0)
  {
    throw new ArgumentException($"Cannot convert");
  }
}

This will expose a C# Stream-like interface to your C11 library.

The only requirement is the following P/Invoke declaration in your C# code:

[DllImport(NativeLibraryName, CallingConvention = CallingConvention.Cdecl)]
internal static extern int acme_convert(C11StreamHandle src, C11StreamHandle dst);

On the C11 side, export your function as:

ACME_EXPORT int acme_convert(c11_stream* src, c11_stream* dst);

At this point you can either re-use one of the existing std::streambuf wrappers, or directly use the c11_stream interface if you prefer to work with C-style APIs.

Implementation details

The stream abstraction is simply defined with a set of five function pointers:

struct c11_stream {
  read_fn read;
  write_fn write;
  seek_fn seek;
  flush_fn flush;
  trunc_fn trunc;
};

Where function declarations are:

typedef int32_t (*read_fn)(byte* buffer, int32_t count);
typedef int32_t (*write_fn)(const byte* buffer, int32_t count);
typedef int64_t (*seek_fn)(int64_t off, int dir);
typedef int (*flush_fn)(void);
typedef int64_t (*trunc_fn)(int64_t size);

See:

Product Compatible and additional computed target framework versions.
.NET net6.0 is compatible.  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 is compatible.  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.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • net6.0

    • No dependencies.
  • net8.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.6.0 131 9/24/2025
1.5.0 281 9/16/2025
1.4.1 152 9/1/2025
1.4.0 280 8/28/2025
1.3.1 219 8/26/2025
1.3.0 129 7/30/2025
1.2.1 134 7/28/2025
1.2.0 448 7/28/2025
1.1.0 390 7/25/2025
1.0.0 394 7/25/2025