1 | <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> |
---|
2 | |
---|
3 | <!-- Copyright David Abrahams 2006. Distributed under the Boost --> |
---|
4 | <!-- Software License, Version 1.0. (See accompanying --> |
---|
5 | <!-- file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) --> |
---|
6 | <html> |
---|
7 | <head> |
---|
8 | <meta name="generator" content= |
---|
9 | "HTML Tidy for Cygwin (vers 1st April 2002), see www.w3.org"> |
---|
10 | <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> |
---|
11 | <link rel="stylesheet" type="text/css" href="../boost.css"> |
---|
12 | |
---|
13 | <title>Boost.Python - <boost/python/raw_function.hpp></title> |
---|
14 | </head> |
---|
15 | |
---|
16 | <body> |
---|
17 | <table border="0" cellpadding="7" cellspacing="0" width="100%" summary= |
---|
18 | "header"> |
---|
19 | <tr> |
---|
20 | <td valign="top" width="300"> |
---|
21 | <h3><a href="../../../../index.htm"><img height="86" width="277" |
---|
22 | alt="C++ Boost" src="../../../../boost.png" border="0"></a></h3> |
---|
23 | </td> |
---|
24 | |
---|
25 | <td valign="top"> |
---|
26 | <h1 align="center"><a href="../index.html">Boost.Python</a></h1> |
---|
27 | |
---|
28 | <h2 align="center">Header <boost/python/raw_function.hpp></h2> |
---|
29 | </td> |
---|
30 | </tr> |
---|
31 | </table> |
---|
32 | <hr> |
---|
33 | |
---|
34 | <h2>Contents</h2> |
---|
35 | |
---|
36 | <dl class="page-index"> |
---|
37 | <dt><a href="#introduction">Introduction</a></dt> |
---|
38 | |
---|
39 | <dt><a href="#functions">Functions</a></dt> |
---|
40 | |
---|
41 | <dd> |
---|
42 | <dl class="page-index"> |
---|
43 | <dt><a href="#raw_function-spec">raw_function</a></dt> |
---|
44 | </dl> |
---|
45 | </dd> |
---|
46 | |
---|
47 | <dt><a href="#examples">Example</a></dt> |
---|
48 | </dl> |
---|
49 | <hr> |
---|
50 | |
---|
51 | <h2><a name="introduction"></a>Introduction</h2> |
---|
52 | |
---|
53 | <p><code><a href="#raw_function-spec">raw_function</a>(...)</code> |
---|
54 | is used to convert a function taking a <a |
---|
55 | href="tuple.html#tuple-spec">tuple</a> and a <a |
---|
56 | href="dict.html#dict-spec">dict</a> into a Python callable object |
---|
57 | which accepts a variable number of arguments and arbitrary keyword |
---|
58 | arguments. |
---|
59 | |
---|
60 | <h2><a name="functions"></a>Functions</h2> |
---|
61 | <a name="raw_function-spec"></a>raw_function |
---|
62 | <pre> |
---|
63 | template <class F> |
---|
64 | object raw_function(F f, std::size_t min_args = 0); |
---|
65 | </pre> |
---|
66 | |
---|
67 | <dl class="function-semantics"> |
---|
68 | <dt><b>Requires:</b> <code>f(tuple(), dict())</code> is |
---|
69 | well-formed.</dt> |
---|
70 | |
---|
71 | <dt><b>Returns:</b> a <a href= |
---|
72 | "http://www.python.org/doc/current/lib/built-in-funcs.html#l2h-6">callable</a> object which requires at least <code>min_args</code> arguments. When called, the actual non-keyword arguments will be passed in a <a |
---|
73 | href="tuple.html#tuple-spec">tuple</a> as the first argument to <code>f</code>, and the keyword arguments will be passed in a <a |
---|
74 | href="dict.html#dict-spec">dict</a> as the second argument to <code>f</code>. |
---|
75 | |
---|
76 | </dd> |
---|
77 | </dl> |
---|
78 | |
---|
79 | <h2><a name="examples"></a>Example</h2> |
---|
80 | C++: |
---|
81 | <pre> |
---|
82 | #include <boost/python/def.hpp> |
---|
83 | #include <boost/python/tuple.hpp> |
---|
84 | #include <boost/python/dict.hpp> |
---|
85 | #include <boost/python/module.hpp> |
---|
86 | #include <boost/python/raw_function.hpp> |
---|
87 | |
---|
88 | using namespace boost::python; |
---|
89 | |
---|
90 | tuple raw(tuple args, dict kw) |
---|
91 | { |
---|
92 | return make_tuple(args, kw); |
---|
93 | } |
---|
94 | |
---|
95 | BOOST_PYTHON_MODULE(raw_test) |
---|
96 | { |
---|
97 | def("raw", raw_function(raw)); |
---|
98 | } |
---|
99 | </pre> |
---|
100 | |
---|
101 | Python: |
---|
102 | <pre> |
---|
103 | >>> from raw_test import * |
---|
104 | |
---|
105 | >>> raw(3, 4, foo = 'bar', baz = 42) |
---|
106 | ((3, 4), {'foo': 'bar', 'baz': 42}) |
---|
107 | </pre> |
---|
108 | <p> |
---|
109 | <!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%d %B, %Y" startspan --> |
---|
110 | 7 March, 2003 |
---|
111 | <!--webbot bot="Timestamp" endspan i-checksum="39359" --> |
---|
112 | </p> |
---|
113 | |
---|
114 | <p><i>© Copyright <a href= |
---|
115 | "../../../../people/dave_abrahams.htm">Dave Abrahams</a> 2002.</i></p> |
---|
116 | </body> |
---|
117 | </html> |
---|
118 | |
---|