C++ Boost

Boost.Python

Header <boost/python/args.hpp>


Contents

Introduction
keyword-expressions
Classes
class arg
class arg synopsis
class arg constructor
class arg template operator =
Keyword-expression operator ,
Functions (deprecated)
args(...)
Example(s)

Introduction

Supplies a family of overloaded functions for specifying argument keywords for wrapped C++ functions.

̡驒뗩֘ԘꯊӃӚΪ碗ൄC++ꯊ햸樲Ί켗֡㼯p>

keyword-expressions

A keyword-expression results in an object which holds a sequence of ntbses, and whose type encodes the number of keywords specified. The keyword-expression may contain default values for some or all of the keywords it holds

阼엖᭴㨫eyword-expression㩼/b>롲ꉺһ趶ԏ㣬 膠ԏ㳖Ӑһשntbs㬍 Ӄ4攖趨儹ؼ엖儐⺅«ᣍ 阼엖᭴Ԏ겿疻∫⿹ؼ엖ɨփĬȏֵ

Classes

class arg;

The objects of class arg are keyword-expressions holding one keyword ( size one )

arg ʇ㖓븶阼엖儹ؼ엖᭴㨴㐡Ϊ1㩼/p>

Class arg synopsis

namespace boost { namespace python
{
        struct arg 
        {
          template <class T>
                  arg &perator = (T const &value);
          explicit arg (char const *name){elements[0].name = name;}
        };

}}

Class arg constructor

arg(char const* name);
Requires: The argument must be a ntbs.
Effects: Constructs an arg object holding a keyword with name name.
Ҫdz㺼/b> ⎊ʇ趠ntbs᣼/dt>
黣꼯b> 鷫쒻趠arg 攏㣬膠ԏ㳖ӐuΪ name 儹ؼ엖᣼/dt>

Class arg operator =

template <class T> arg &operator = (T const &value);
Requires: The argument must convertible to python.
Effects: Assigns default value for the keyword.
Returns: Reference to this.
Ҫdz㺼/b> ⎊껻彰ython᣼/dt>
黣꼯b> Ϊ阼엖賄숏ֵ᣼/dt>
絻أ꼯b> 攠this 儒퓃᣼/dt>

Keyword-expression operator ,

      keyword-expression operator , (keyword-expression, const arg &kw) const
      keyword-expression operator , (keyword-expression, const char *name) const;
Requires: The argument name must be a ntbs.
Effects: Extends the keyword-expression argument with one more keyword.
Returns: The extended keyword-expression.
Ҫdz㺼/b> ⎊code>name ᘐ늇趠ntbs᣼/dt>
黣꼯b> 阼엖᭴⎊픙)㤒븶阼엖ᣍ
絻أ꼯b> )㤺㵄阼엖᭴᣼/dt>

Functions (deprecated)

args(...)

  unspecified1 args(char const*);
    unspecified2 args(char const*, char const*);
       .
       .
       .
    unspecifiedN args(char const*, char const*, ... char const*);

Requires: Every argument must be a ntbs.
Returns: an object representing a keyword-expression encapsulating the arguments passed.
Ҫdz㺼/b> y趲Ίʇ趠ntbs᣼/font>
絻أ꼯b> һ趷◰K䫈벎ʽ儼a href="#keyword-expression">阼엖᭴攏㡣

Example

#include <boost/python/def.hpp>
using namespace boost::python;

int f(double x, double y, double z=0.0, double w=1.0);

BOOST_PYTHON_MODULE(xxx)
{
   def("f", f
            , ( arg("x"), "y", arg("z")=0.0, arg("w")=1.0 ) 
            );
}

Revised 01 August, 2003

© Copyright Dave Abrahams 2002-2003.