Python package:
master:
testing:
This repository contains reusable material for interoperability between C/C++ and other languages such as python, R, etc. It is using template-only C++, avoiding code duplications across several projects. The code design also stems from learning over the years to prevent some "gotchas" one can get into when diving deep in native interop accross compilation modules.
The C++
header files cover interop for:
- common base types (characters, numeric, and vectors thereof)
- boost date-time
- time series (inherited from its usage in time step modelling systems)
The repo also includes interop packages for several higher level languages, that helps handling consistently (including memory management...) some of the data stemming from the C/C++ glue code:
- python package cinterop, also available on pypi
- R package cinterop
- Matlab reference counting helpers
One use case arising from hydrologic forecasting is uchronia-time-series.
Some features in the present repository depend on related material:
- moirai, a C++ library designed to help handling C++ objects from so-called opaque pointers, via a C API.
- The python package refcount for reference counting external resources.
Another resource is a blog post on generating programming language bindings to a C API.
For instance this library defines a template function to_custom_character_vector
to convert C char**
types to something useful for the higher level language at hand.
namespace cinterop
{
namespace utils
{
template<typename T>
T to_custom_character_vector(char** names, int size, bool cleanup);
One specialization of this is a conversion to Rcpp's CharacterVector
type for interop with R, which would be used like this:
int size;
char** values = GetEnsembleDatasetDataIdentifiers(dataLibrary->get(), &size);
CharacterVector cv = to_custom_character_vector<CharacterVector>(values, size, true);
- native interop glue code generation
- An R package pupetting the former - I have yet to open source it though.