C++/Python interfacing

Introduction

Boost.Python allows to define automatic conversion from\to C++\Python types. While this is very, very useful functionality, the documentation for it does not exist. This example will shed some light on "r-value"\"l-value" converters.

Content

This example actually consist from 2 small, well documented examples.

The first one shows how to handle conversion between tuples: boost::tuples::tuple and Python tuple.

The second one shows how to add an automatic conversion from Python tuple to some registered class. The class registration allows you to use its functionality and enjoy from automatic conversion.

Files

  • tuples.hpp file contains Boost.Tuple to\from Python tuple conversion implementation
  • tuples_tester.cpp file contains few functions, which test the tuples conversion functionality
  • custom_rvalue.cpp file contains example of registration custom r-value converter
  • sconstruct file contains build instructions for scons build tool.
  • test.py file contains complete unit tests for both example

All files contain comments, which describe what and why was done.



Valid HTML 4.01 Transitional Valid CSS! SourceForge.net Logo