| 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/args.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/args.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="#keyword-expression"><i>keyword-expressions</i></a></dt> |
|---|
| 40 | |
|---|
| 41 | <dt><a href="#classes">Classes</a></dt> |
|---|
| 42 | |
|---|
| 43 | <dd> |
|---|
| 44 | <dl class="page-index"> |
|---|
| 45 | <dt><a href="#arg-spec">class <code>arg</code></a></dt> |
|---|
| 46 | |
|---|
| 47 | <dd> |
|---|
| 48 | <dl class="page-index"> |
|---|
| 49 | <dt><a href="#arg-synopsis">class <code>arg</code> |
|---|
| 50 | synopsis</a></dt> |
|---|
| 51 | |
|---|
| 52 | <dt><a href="#arg-ctor">class <code>arg</code> |
|---|
| 53 | constructor</a></dt> |
|---|
| 54 | |
|---|
| 55 | <dt><a href="#arg-operator">class <code>arg</code> template |
|---|
| 56 | <code>operator =</code></a></dt> |
|---|
| 57 | </dl> |
|---|
| 58 | </dd> |
|---|
| 59 | </dl> |
|---|
| 60 | </dd> |
|---|
| 61 | |
|---|
| 62 | <dt><a href="#keyword-expression-operators"><i>Keyword-expression</i> |
|---|
| 63 | operator <code>,</code></a></dt> |
|---|
| 64 | |
|---|
| 65 | <dt><a href="#functions">Functions (deprecated)</a></dt> |
|---|
| 66 | |
|---|
| 67 | <dd> |
|---|
| 68 | <dl class="page-index"> |
|---|
| 69 | <dt><code><a href= |
|---|
| 70 | "#args-spec">args</a>(</code>...<code>)</code></dt> |
|---|
| 71 | </dl> |
|---|
| 72 | </dd> |
|---|
| 73 | |
|---|
| 74 | <dt><a href="#examples">Example(s)</a></dt> |
|---|
| 75 | </dl> |
|---|
| 76 | <hr> |
|---|
| 77 | |
|---|
| 78 | <h2><a name="introduction"></a>Introduction</h2> |
|---|
| 79 | |
|---|
| 80 | <p>Supplies a family of overloaded functions for specifying argument |
|---|
| 81 | keywords for wrapped C++ functions.</p> |
|---|
| 82 | |
|---|
| 83 | <h2><a name="keyword-expression"></a><i>keyword-expressions</i></h2> |
|---|
| 84 | |
|---|
| 85 | <p>A <b>keyword-expression</b> results in an object which holds a |
|---|
| 86 | sequence of <a href="definitions.html#ntbs">ntbs</a>es, and whose type |
|---|
| 87 | encodes the number of keywords specified. The <b>keyword-expression</b> |
|---|
| 88 | may contain default values for some or all of the keywords it holds</p> |
|---|
| 89 | |
|---|
| 90 | <h2><a name="classes"></a>Classes</h2> |
|---|
| 91 | |
|---|
| 92 | <h3><a name="arg-spec"></a><code>class arg;</code></h3> |
|---|
| 93 | |
|---|
| 94 | <p>The objects of class arg are keyword-expressions holding one keyword ( |
|---|
| 95 | size one )</p> |
|---|
| 96 | |
|---|
| 97 | <h4><a name="arg-synopsis"></a>Class <code>arg</code> synopsis</h4> |
|---|
| 98 | <pre> |
|---|
| 99 | namespace boost { namespace python |
|---|
| 100 | { |
|---|
| 101 | struct arg |
|---|
| 102 | { |
|---|
| 103 | template <class T> |
|---|
| 104 | arg &perator = (T const &value); |
|---|
| 105 | explicit arg (char const *name){elements[0].name = name;} |
|---|
| 106 | }; |
|---|
| 107 | |
|---|
| 108 | }} |
|---|
| 109 | </pre> |
|---|
| 110 | |
|---|
| 111 | <h4><a name="arg-ctor"></a>Class <code>arg</code> constructor</h4> |
|---|
| 112 | <pre> |
|---|
| 113 | arg(char const* name); |
|---|
| 114 | </pre> |
|---|
| 115 | |
|---|
| 116 | <dl class="function-semantics"> |
|---|
| 117 | <dt><b>Requires:</b> The argument must be a <a href= |
|---|
| 118 | "definitions.html#ntbs">ntbs</a>.</dt> |
|---|
| 119 | |
|---|
| 120 | <dt><b>Effects:</b> Constructs an <code>arg</code> object holding a |
|---|
| 121 | keyword with name <code>name</code>.</dt> |
|---|
| 122 | </dl> |
|---|
| 123 | |
|---|
| 124 | <h4><a name="arg-operator"></a>Class <code>arg</code> operator =</h4> |
|---|
| 125 | <pre> |
|---|
| 126 | template <class T> arg &operator = (T const &value); |
|---|
| 127 | </pre> |
|---|
| 128 | |
|---|
| 129 | <dl class="function-semantics"> |
|---|
| 130 | <dt><b>Requires:</b> The argument must convertible to python.</dt> |
|---|
| 131 | |
|---|
| 132 | <dt><b>Effects:</b> Assigns default value for the keyword.</dt> |
|---|
| 133 | |
|---|
| 134 | <dt><b>Returns:</b> Reference to <code>this</code>.</dt> |
|---|
| 135 | </dl> |
|---|
| 136 | |
|---|
| 137 | <h2><a name="keyword-expression-operators"><i>Keyword-expression</i> |
|---|
| 138 | operator <code>,</code></a></h2> |
|---|
| 139 | <pre> |
|---|
| 140 | <i>keyword-expression</i> operator , (<i>keyword-expression</i>, const arg &kw) const |
|---|
| 141 | <i>keyword-expression</i> operator , (<i>keyword-expression</i>, const char *name) const; |
|---|
| 142 | </pre> |
|---|
| 143 | |
|---|
| 144 | <dl class="function-semantics"> |
|---|
| 145 | <dt><b>Requires:</b> The argument <code>name</code> must be a <a href= |
|---|
| 146 | "definitions.html#ntbs">ntbs</a>.</dt> |
|---|
| 147 | |
|---|
| 148 | <dt><b>Effects:</b> Extends the <i>keyword-expression</i> argument with |
|---|
| 149 | one more keyword.</dt> |
|---|
| 150 | |
|---|
| 151 | <dt><b>Returns:</b> The extended <i>keyword-expression</i>.</dt> |
|---|
| 152 | </dl> |
|---|
| 153 | |
|---|
| 154 | <h2><font color="#7F7F7F"><a name="functions"></a>Functions |
|---|
| 155 | (deprecated)</font></h2> |
|---|
| 156 | |
|---|
| 157 | <h3><a name="args-spec"></a><code><font color= |
|---|
| 158 | "#7F7F7F">args</font>(</code>...<code>)</code></h3> |
|---|
| 159 | <pre> |
|---|
| 160 | <font color="#7F7F7F"> <i>unspecified1</i> args(char const*); |
|---|
| 161 | <i>unspecified2</i> args(char const*, char const*); |
|---|
| 162 | . |
|---|
| 163 | . |
|---|
| 164 | . |
|---|
| 165 | <i>unspecifiedN</i> args(char const*, char const*, ... char const*); |
|---|
| 166 | </font> |
|---|
| 167 | </pre> |
|---|
| 168 | |
|---|
| 169 | <dl class="function-semantics"> |
|---|
| 170 | <dt><font color="#7F7F7F"><b>Requires:</b> Every argument must be a <a |
|---|
| 171 | href="definitions.html#ntbs">ntbs</a>.</font></dt> |
|---|
| 172 | |
|---|
| 173 | <dt><font color="#7F7F7F"><b>Returns:</b> an object representing a <a |
|---|
| 174 | href="#keyword-expression"><i>keyword-expression</i></a> encapsulating |
|---|
| 175 | the arguments passed.</font></dt> |
|---|
| 176 | </dl> |
|---|
| 177 | |
|---|
| 178 | <h2><a name="examples"></a>Example</h2> |
|---|
| 179 | <pre> |
|---|
| 180 | #include <boost/python/def.hpp> |
|---|
| 181 | using namespace boost::python; |
|---|
| 182 | |
|---|
| 183 | int f(double x, double y, double z=0.0, double w=1.0); |
|---|
| 184 | |
|---|
| 185 | BOOST_PYTHON_MODULE(xxx) |
|---|
| 186 | { |
|---|
| 187 | def("f", f |
|---|
| 188 | , ( arg("x"), "y", arg("z")=0.0, arg("w")=1.0 ) |
|---|
| 189 | ); |
|---|
| 190 | } |
|---|
| 191 | </pre> |
|---|
| 192 | |
|---|
| 193 | <p>Revised 01 August, 2003</p> |
|---|
| 194 | |
|---|
| 195 | <p><i>© Copyright <a href= |
|---|
| 196 | "../../../../people/dave_abrahams.htm">Dave Abrahams</a> 2002-2003.</i></p> |
|---|
| 197 | </body> |
|---|
| 198 | </html> |
|---|
| 199 | |
|---|