diff options
| author | Michael Vogt <michael.vogt@ubuntu.com> | 2010-03-23 14:18:44 +0100 |
|---|---|---|
| committer | Michael Vogt <michael.vogt@ubuntu.com> | 2010-03-23 14:18:44 +0100 |
| commit | 37650a078f5504dfbc6622d2c06f4435a3302dd4 (patch) | |
| tree | 35d7df75535420cbe0712a5f7b7b66d61f5e44d1 /doc/source/c++/embedding.rst | |
| parent | 2aa709e41d8896ef897863ea9181c409c4c87a8c (diff) | |
| parent | 3a08cfb10590d5cf5df1f45d94a424ef6a0f674b (diff) | |
| download | python-apt-37650a078f5504dfbc6622d2c06f4435a3302dd4.tar.gz | |
merged from lp:~mvo/python-apt/mvo
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 00000000..754ad398 --- /dev/null +++ b/doc/source/c++/embedding.rst @@ -0,0 +1,34 @@ +.. highlightlang:: 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 +:cfunc:`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 + + +.. highlightlang:: 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 |
