diff options
Diffstat (limited to 'doc/source/c++/embedding.rst')
-rw-r--r-- | doc/source/c++/embedding.rst | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/doc/source/c++/embedding.rst b/doc/source/c++/embedding.rst new file mode 100644 index 0000000..cb175f8 --- /dev/null +++ b/doc/source/c++/embedding.rst @@ -0,0 +1,34 @@ +.. highlight:: c++ + +Embedding Python APT +==================== +This is a very basic tutorial for working with the C++ bindings. + +Basics +------- +To use the python-apt C++ bindings, first include the +``python-apt/python-apt.h`` header:: + + #include <python-apt/python-apt.h> + +Now, the module needs to be initialized. This is done by calling the function +:c:func:`import_apt_pkg`. This function returns 0 on success and a negative +value in case of failure:: + + if (import_apt_pkg() < 0) + return; + +Longer example +-------------- +The following code will create a standalone application which provides a +module ``client`` with the attribute ``hash`` which stores an object of the +type :class:`apt_pkg.HashString`: + +.. literalinclude:: ../../client-example.cc + + +.. highlight:: sh + +If this file were called client-example.cc, you could compile it using:: + + g++ -lapt-pkg -lpython2.5 -I/usr/include/python2.5 -o client client-example.cc |