diff --git a/doc/v2/ObjectWrapper.html b/doc/v2/ObjectWrapper.html new file mode 100644 index 00000000..c7d555cd --- /dev/null +++ b/doc/v2/ObjectWrapper.html @@ -0,0 +1,155 @@ + + + +
+ + + + +|
+ |
+
+
+ Boost.Python+ +ObjectWrapper and TypeWrapper Concepts+ |
+
This page defines two concepts used to describe classes which manage a + Python objects, and which are intended to support usage with a + Python-like syntax.
+ +R is itself an TypeWrapper, a member function invocation of
+ the form
++x.some_function(a1, a2,...an) ++ always has semantics equivalent to: +
+extract<R>(x.attr("some_function")(object(a1), object(a2),...object(an)))()
+
+ When the R is an TypeWrapper, the result type may be
+ constructed by taking direct posession of:
+
+x.attr("some_function")(object(a1), object(a2),...object(an)).ptr()
+
+ [see caveat below]
+
+ X. For a given TypeWrapper
+ T, a valid constructor expression
++T(a1, a2,...an) ++ builds a new
T object managing the result of invoking
+ X with arguments corresponding to
++object(a1), object(a2),...object(an) ++ +When used as arguments to wrapped C++ functions, or as the template +parameter to
extract<>, only
+instances of the associated Python type will be considered a match.
+
+ dict member function items
+ returns an object of type list. Now suppose the user defines this
+ dict subclass in Python:
++>>> class mydict(dict): +... def items(self): +... return tuple(dict.items(self)) # return a tuple ++ Since an instance of
mydict is also an instance of
+ dict, when used as an argument to a wrapped C++ function,
+ boost::python::dict can
+ accept objects of Python type mydict. Invoking
+ items() on this object can result in an instance of boost::python::list which actually
+ holds a Python tuple. Subsequent attempts to use list methods (e.g.
+ append, or any other mutating operation) on this object will
+ raise the same exception that would occur if you tried to do it from
+ Python.
+ Revised + + 30 Sept, 2002 +
+ +© Copyright Dave Abrahams 2002. All Rights + Reserved.
+ +Permission to copy, use, modify, sell and distribute this software is + granted provided this copyright notice appears in all copies. This + software is provided "as is" without express or implied warranty, and + with no claim as to its suitability for any purpose.
+ + + diff --git a/doc/v2/args.html b/doc/v2/args.html new file mode 100644 index 00000000..1cff40a8 --- /dev/null +++ b/doc/v2/args.html @@ -0,0 +1,103 @@ + + + + + + + + +|
+ |
+
+
+ Boost.Python+ +Header <boost/python/args.hpp>+ |
+
args(...)Supplies a family of overloaded functions for specifying argument + keywords for wrapped C++ functions.
+ +A keyword-expression results in an object which holds a + sequence of ntbses, and whose type + encodes the number of keywords specified.
+ +args(...)+unspecified1 args(char const*); +unspecified2 args(char const*, char const*); + . + . + . +unspecifiedN args(char const*, char const*, ... char const*); ++ +
+#include <boost/python/def.hpp>
+using namespace boost::python;
+
+int f(int x, int y, int z);
+
+BOOST_PYTHON_MODULE(xxx)
+{
+ def("f", f, args("x", "y", "z"));
+}
+
+
+ Revised 05 November, 2001
+ +© Copyright Dave Abrahams 2002. All Rights + Reserved.
+ + + diff --git a/doc/v2/def.html b/doc/v2/def.html new file mode 100644 index 00000000..25a78bf8 --- /dev/null +++ b/doc/v2/def.html @@ -0,0 +1,195 @@ + + + + + + + + +|
+ |
+
+
+ Boost.Python+ +Header <boost/python/def.hpp>+ |
+
def() is the function which can
+ be used to expose C++ functions and callable objects as Python functions
+ in the current scope.
+template <class F> +void def(char const* name, F f); + +template <class Fn, class A1> +void def(char const* name, Fn fn, A1 const&); + +template <class Fn, class A1, class A2> +void def(char const* name, Fn fn, A1 const&, A2 const&); + +template <class Fn, class A1, class A2, class A3> +void def(char const* name, Fn fn, A1 const&, A2 const&, A3 const&); ++ +
name is an ntbs which conforms to Python's identifier
+ naming rules.a1 is the result of an overload-dispatch-expression,
+ only the second form is allowed and fn must be a pointer to
+ function or pointer to member function whose arity is the same as A1's maximum
+ arity.
+
+ Fn's sequence of argument types, beginning with
+ the one whose length is A1's minimum
+ arity, adds a
+ name(...) function overload
+ to the current scope. Each overload
+ generated invokes a1's call-expression with
+ P, using a copy of a1's call policies. If the longest valid
+ prefix of A1 contains N types and
+ a1 holds M keywords, an initial sequence
+ of the keywords are used for all but the first
+ N - M arguments of each
+ overload.a1-a3 (if supplied) may be selected
+ in any order from the table below.Fn must be [derived from] object, and
+ a1-a2 (if supplied) may be selcted in any order
+ from the first two rows of the table below. To be useful,
+ fn should be
+ callable.| Memnonic Name | + +Requirements/Type properties | + +Effects | +
|---|---|---|
| docstring | + +Any ntbs. | + +Value will be bound to the __doc__ attribute
+ of the resulting method overload. |
+
| policies | + +A model of CallPolicies | + +A copy will be used as the call policies of the resulting + method overload. | +
| keywords | + +The result of a keyword-expression
+ specifying no more arguments than the arity of fn. |
+
+ A copy will be used as the call policies of the resulting + method overload. | +
+#include <boost/python/def.hpp>
+#include <boost/python/module.hpp>
+#include <boost/python/args.hpp>
+
+char const* foo(int x, int y) { return "foo"; }
+
+BOOST_PYTHON_MODULE(def_test)
+{
+ def("foo", foo, args("x", "y"), "foo's docstring");
+}
+
+
+ + + 03 October, 2002 + +
+ +© Copyright Dave Abrahams 2002. All Rights + Reserved.
+ + + diff --git a/doc/v2/dict.html b/doc/v2/dict.html new file mode 100644 index 00000000..4ab47aa3 --- /dev/null +++ b/doc/v2/dict.html @@ -0,0 +1,150 @@ + + + + + + + + +|
+ |
+
+
+ Boost.Python+ +Header <boost/python/dict.hpp>+ |
+
dictdict
+ synopsisExposes a TypeWrapper for the Python + dict + type.
+ +dictExposes the mapping
+ protocol of Python's built-in dict type. The semantics
+ of the constructors and member functions defined below can be fully
+ understood by reading the TypeWrapper concept
+ definition. Since dict is publicly derived from object, the public object
+ interface applies to dict instances as well.
dict
+ synopsis
+namespace boost { namespace python
+{
+ class dict : public object
+ {
+ dict();
+
+ template< class T >
+ dict(T const & data);
+
+ // modifiers
+ void clear();
+ dict copy();
+
+ template <class T1, class T2>
+ tuple popitem();
+
+ template <class T>
+ object setdefault(T const &k);
+
+ template <class T1, class T2>
+ object setdefault(T1 const & k, T2 const & d);
+
+ void update(object_cref E);
+
+ template< class T >
+ void update(T const & E);
+
+ // observers
+ list values() const;
+
+ object get(object_cref k) const;
+
+ template<class T>
+ object get(T const & k) const;
+
+ object get(object_cref k, object_cref d) const;
+ object get(T1 const & k, T2 const & d) const;
+
+ bool has_key(object_cref k) const;
+
+ template< class T >
+ bool has_key(T const & k) const;
+
+ list items() const;
+ object iteritems() const;
+ object iterkeys() const;
+ object itervalues() const;
+ list keys() const;
+ };
+}}
+
+
+
+using namespace boost::python;
+dict swap_object_dict(object target, dict d)
+{
+ dict result = extract<dict>(target.attr("__dict__"));
+ target.attr("__dict__") = d;
+ return result;
+}
+
+
+ Revised 30 September, 2002
+ +© Copyright Dave Abrahams 2002. All Rights + Reserved.
+ + + diff --git a/doc/v2/enum.html b/doc/v2/enum.html new file mode 100644 index 00000000..38d878b1 --- /dev/null +++ b/doc/v2/enum.html @@ -0,0 +1,203 @@ + + + + + + + + +|
+ |
+
+
+ Boost.Python+ +Header <boost/python/enum.hpp>+ |
+
enum_enum_
+ synopsisenum_
+ constructorsenum_
+ modifier functions<boost/python/enum.hpp> defines the
+ interface through which users expose their C++ enumeration types
+ to Python. It declares the
+ enum_ class template, which is parameterized on the
+ enumeration type being exposed.
enum_<T>Creates a Python class derived from Python's int
+ type which is associated with the C++ type passed as its first
+ parameter.
+
+
enum_
+ synopsis
+namespace boost { namespace python
+{
+ template <class T>
+ class enum_ : public object
+ {
+ enum_(char const* name);
+ inline enum_<T>& value(char const* name, T);
+ };
+}}
+
+
+ enum_
+ constructors+enum_(char const* name); ++ +
name is an ntbs which conforms to Python's identifier
+ naming rules.
+
+ enum_ object
+ holding a Python extension type derived from int
+ which is named name. The
+ named attribute of the current scope is bound to the new
+ extension type.enum_ modifier functions+inline enum_<T>& value(char const* name, T x); ++ +
name is an ntbs which conforms to Python's identifier
+ naming rules.
+
+ x to the type's dictionary as the
+ named attribute*thisC++ module definition +
+#include <boost/python/enum.hpp>
+#include <boost/python/def.hpp>
+#include <boost/python/module.hpp>
+
+using namespace boost::python;
+
+enum color { red = 1, green = 2, blue = 4 };
+
+color identity_(color x) { return x; }
+
+BOOST_PYTHON_MODULE(enums)
+{
+ enum_<color>("color")
+ .value("red", red)
+ .value("green", green)
+ .value("blue", blue)
+ ;
+
+ def("identity", identity_);
+}
+
+ Interactive Python: +
+>>> from enums import * + +>>> identity(color.red) +enums.color.red + +>>> identity(color.green) +enums.color.green + +>>> identity(color.blue) +enums.color.blue + +>>> identity(color(1)) +enums.color.red + +>>> identity(color(2)) +enums.color.green + +>>> identity(color(3)) +enums.color(3) + +>>> identity(color(4)) +enums.color.blue + +>>> identity(1) +Traceback (most recent call last): + File "<stdin>", line 1, in ? +TypeError: bad argument type for built-in operation ++
© Copyright Dave Abrahams 2002. All Rights + Reserved.
+ + + diff --git a/doc/v2/exception_translator.html b/doc/v2/exception_translator.html new file mode 100644 index 00000000..f460c1ce --- /dev/null +++ b/doc/v2/exception_translator.html @@ -0,0 +1,148 @@ + + + + + + + + +|
+ |
+
+
+ Boost.Python+ +Header + <boost/python/exception_translator.hpp>+ |
+
As described here, it
+ is important to make sure that exceptions thrown by C++ code do not pass
+ into the Python interpreter core. By default, Boost.Python translates all
+ C++ exceptions thrown by wrapped functions and module init functions into
+ Python, but the default translators are extremely limited: most C++
+ exceptions will appear in Python as a RuntimeError
+ exception whose representation is
+ 'Unidentifiable C++ Exception'. To produce better
+ error messages, users can register additional exception translators as
+ described below.
register_exception_translator+template<class ExceptionType, class Translate> +void register_exception_translator(Translate const& translate); ++ +
Translate is Copyconstructible, and
+ the following code must be well-formed:
+
+void f(ExceptionType x) { translate(x); }
+
+ The expression translate(x) must either throw a C++
+ exception, or a subsequent call to PyErr_Occurred()
+ must return 1.
+ + +
translate to the sequence of
+ exception translators tried when Boost.Python catches an exception that
+ is about to pass into Python's core interpreter. The new translator
+ will get "first shot" at translating all exceptions matching the catch
+ clause shown above. Any subsequently-registered translators will be
+ allowed to translate the exception earlier. A translator which cannot
+ translate a given C++ exception can re-throw it, and it will be handled
+ by a translator which was registered earlier (or by the default
+ translator).
+#include <boost/python/module.hpp>
+#include <boost/python/def.hpp>
+#include <boost/python/exception_translator.hpp>
+#include <exception>
+
+struct my_exception : std::exception
+{
+ char const* what() throw() { return "One of my exceptions"; }
+};
+
+void translate(my_exception const& e)
+{
+ // Use the Python 'C' API to set up an exception object
+ PyErr_SetString(PyExc_RuntimeError, e.what());
+}
+
+void something_which_throws()
+{
+ ...
+ throw my_exception();
+ ...
+}
+
+BOOST_PYTHON_MODULE(exception_translator_ext)
+{
+ using namespace boost::python;
+ register_exception_translator<my_exception>(&translate);
+
+ def("something_which_throws", something_which_throws);
+}
+
+ Revised 03 October, 2002
+ +© Copyright Dave Abrahams 2002. All Rights + Reserved.
+ + + diff --git a/doc/v2/extract.html b/doc/v2/extract.html new file mode 100644 index 00000000..b49d587b --- /dev/null +++ b/doc/v2/extract.html @@ -0,0 +1,230 @@ + + + + + + + + +|
+ |
+
+
+ Boost.Python+ +Header <boost/python/extract.hpp>+ |
+
extractextract
+ synopsisextract
+ constructors and destructorextract observer functionsExposes a mechanism for extracting C++ object values from
+ generalized Python objects. Note that
+ extract<...> can also be used to
+ "downcast" an object to some specific ObjectWrapper. Because
+ invoking a mutable python type with an argument of the same type
+ (e.g. list([1,2]) typically makes a copy of
+ the argument object, this may be the only way to access the ObjectWrapper's
+ interface on the original object.
+
+
extractextract<T> can be used to extract a value of
+ an arbitrary C++ type from an instance of object. Two usages are supported:
+
extract<T>(o) is a temporary object
+which is implicitly convertible to T (explicit conversion
+is also available through the object's function-call
+operator). However, if no conversion is available which can convert
+o to an object of type T, a Python
+TypeError exception will be raised.
+
+extract<T> x(o); constructs an extractor
+whose check() member function can be used to ask whether
+a conversion is available without causing an exception to be thrown.
+extract
+ synopsis
+namespace boost { namespace python
+{
+ template <class T>
+ struct extract
+ {
+ typedef unspecified result_type;
+
+ extract(PyObject*);
+ extract(object const&);
+
+ result_type operator()() const;
+ operator result_type() const;
+
+ bool check() const;
+ };
+}}
+
+
+ extract
+ constructors and destructor+extract(PyObject* p); +extract(object const&); ++ +
p is non-null.extract
+ observer functions+result_type operator()() const; +operator result_type() const; ++ +
result_type, which is either T or
+ T const&.
+ result_type
+ corresponding to the one referenced by the stored pointer.error_already_set
+ and sets a TypeError if no such conversion is
+ available. May also emit other unspecified exceptions thrown by
+ the converter which is actually used.+bool check() const; ++ +
true does not preclude an exception
+ being thrown from operator result_type() or
+ operator()().false only if no conversion from the
+ stored pointer to T is available.
+#include <cstdio>
+using namespace boost::python;
+int Print(str s)
+{
+ // extract a C string from the Python string object
+ char const* c_str = extract<char const*>(s);
+
+ // Print it using printf
+ std::printf("%s\n", c_str);
+
+ // Get the Python string's length and convert it to an int
+ return extract<int>(s.attr("__len__")())
+}
+
+
+The following example shows how extract can be used along with
+class_<...>
+to create and access an instance of a wrapped C++ class.
+
+
+struct X
+{
+ X(int x) : v(x) {}
+ int value() { return v; }
+ private:
+ int v;
+};
+
+BOOST_PYTHON_MODULE(extract_ext)
+{
+ object x_class(
+ class_<X>("X", init<int>())
+ .def("value", &X::value))
+ ;
+
+ // Instantiate an X object through the Python interface.
+ // Its lifetime is now managed by x_obj.
+ object x_obj = x_class(3);
+
+ // Get a reference to the C++ object out of the Python object
+ X const& x = extract<X&>(x_obj);
+ assert(x.value() == 3);
+}
+
+ Revised 30 September, 2002
+ +© Copyright Dave Abrahams 2002. All Rights + Reserved.
+ + + diff --git a/doc/v2/init.html b/doc/v2/init.html new file mode 100644 index 00000000..2f6b938e --- /dev/null +++ b/doc/v2/init.html @@ -0,0 +1,249 @@ + + + + + + + + +|
+ |
+
+
+ Boost.Python+ +Headers <boost/python/init.hpp>+ |
+
initinit synopsisinit
+ constructorsoptionaloptional synopsis<boost/python/init.hpp> defines the interface for
+ exposing C++ constructors to Python as extension class
+ __init__ functions.
__init__ methods to be generated for an extension class, and
+ the result has the following properties:
+
+ ++ ++
+- docstring: An ntbs + whose value will bound to the method's
+ +__doc__+ attribute- keywords: A keyword-expression which will be + used to name (a trailing subsequence of) the arguments to the + generated
+ +__init__function(s).- call policies: An instance of a model of CallPolicies.
+ +- argument types: An MPL sequence of C++ argument types + which will be used to construct the wrapped C++ object. An init + expression has one or more + valid prefixes which are given by a sequence of + prefixes of its argument types.
+
init<T1 =
+ unspecified, T2 =
+ unspecified,...Tn =
+ unspecified>A MPL sequence which
+ can be used to specify a family of one or more __init__
+ functions. Only the last Ti supplied
+ may be an instantiation of optional<...>.
init
+ synopsis
+namespace boost { namespace python
+{
+ template <T1 = unspecified,...Tn = unspecified>
+ struct init
+ {
+ init(char const* doc = 0);
+ template <class Keywords> init(Keywords const& kw, char const* doc = 0);
+ template <class Keywords> init(char const* doc, Keywords const& kw);
+
+ template <class CallPolicies>
+ unspecified operator[](CallPolicies const& policies) const
+ };
+}}
+
+
+ init
+ constructors+init(char const* doc = 0); +template <class Keywords> init(Keywords const& kw, char const* doc = 0); +template <class Keywords> init(char const* doc, Keywords const& kw); ++ +
doc is an ntbs. If supplied, kw is the
+ result of a doc and whose keywords are
+ a reference to kw. If the first form is used, the
+ resulting expression's keywords are empty. The expression's
+ call policies are an instance of default_call_policies.
+ If Tn is optional<U1, U2,...
+ Um>, the
+ expression's valid prefixes are given by:+ (+ Otherwise, the expression has one valid prefix given by the + the template arguments the user specified. +T1, T2,...Tn-1), + (T1, T2,...Tn-1 +, U1), + (T1, T2,...Tn-1 +, U1, U2), + ...(T1, T2,...Tn-1 +, U1, U2,...Um). +
init
+ observer functions+template <class Policies> +unspecified operator[](Policies const& policies) const ++ +
init object except that its call
+ policies are replaced by a reference to
+ policies.optional<T1
+ = unspecified, T2 =
+ unspecified,...Tn =
+ unspecified>A MPL sequence which
+ can be used to specify the optional arguments to an __init__
+ function.
optional synopsis
+namespace boost { namespace python
+{
+ template <T1 = unspecified,...Tn = unspecified>
+ struct optional {};
+}}
+
+
+ Given the C++ declarations:
+
+class Y;
+class X
+{
+ public:
+ X(int x, Y* y) : m_y(y) {}
+ X(double);
+ private:
+ Y* m_y;
+};
+
+ A corresponding Boost.Python extension class can be created with:
+
+using namespace boost::python;
+
+class_<X>("X", "This is X's docstring.",
+ init<int,char const*>(args("x","y"), "X.__init__'s docstring")[
+ with_custodian_and_ward<1,3>()]
+ )
+ .def(init<double>())
+ ;
+
+ © Copyright Dave Abrahams 2002. All Rights + Reserved.
+ + + diff --git a/doc/v2/list.html b/doc/v2/list.html new file mode 100644 index 00000000..858102e0 --- /dev/null +++ b/doc/v2/list.html @@ -0,0 +1,140 @@ + + + + + + + + +|
+ |
+
+
+ Boost.Python+ +Header <boost/python/list.hpp>+ |
+
listlist
+ synopsisExposes a TypeWrapper for the Python + list + type.
+ +listExposes the mapping
+ protocol of Python's built-in list type. The semantics
+ of the constructors and member functions defined below can be fully
+ understood by reading the TypeWrapper concept
+ definition. Since list is publicly derived from object, the public object
+ interface applies to list instances as well.
list
+ synopsis
+namespace boost { namespace python
+{
+ class list : public object
+ {
+ public:
+ list(); // new list
+
+ template <class T>
+ explicit list(T const& sequence);
+
+ template <class T>
+ void append(T const& x);
+
+ template <class T>
+ long count(T const& value) const;
+
+ template <class T>
+ void extend(T const& x);
+
+ template <class T>
+ long index(T const& x) const;
+
+ template <class T>
+ void insert(object const& index, T const& x); // insert object before index
+
+ object pop(); // remove and return item at index (default last)
+ object pop(long index);
+ object pop(object const& index);
+
+ template <class T>
+ void remove(T const& value);
+
+ void reverse(); // reverse *IN PLACE*
+
+ void sort(); // sort *IN PLACE*; if given, cmpfunc(x, y) -> -1, 0, 1
+
+ template <class T>
+ void sort(T const& value);
+ };
+}}
+
+
+
+using namespace boost::python;
+
+// Return the number of zeroes in the list
+long zeroes(list l)
+{
+ return l.count(0);
+}
+
+
+ Revised 1 October, 2002
+ +© Copyright Dave Abrahams 2002. All Rights + Reserved.
+ + + diff --git a/doc/v2/long.html b/doc/v2/long.html new file mode 100644 index 00000000..13079684 --- /dev/null +++ b/doc/v2/long.html @@ -0,0 +1,117 @@ + + + + + + + + +|
+ |
+
+
+ Boost.Python+ +Header <boost/python/long.hpp>+ |
+
long_long_
+ synopsisExposes a TypeWrapper for the Python + long + integer type.
+ +long_Exposes the numeric type
+ protocol of Python's built-in long type. The semantics
+ of the constructors and member functions defined below can be fully
+ understood by reading the TypeWrapper concept
+ definition. Since long_ is publicly derived from object, the public object
+ interface applies to long_ instances as well.
long_
+ synopsis
+namespace boost { namespace python
+{
+ class long_ : public object
+ {
+ public:
+ long_(); // new long_
+
+ template <class T>
+ explicit long_(T const& rhs);
+
+ template <class T, class U>
+ long_(T const& rhs, U const& base);
+ };
+}}
+
+
+
+namespace python = boost::python;
+
+// compute a factorial without overflowing
+python::long_ fact(long n)
+{
+ if (n == 0)
+ return python::long_(1);
+ else
+ return n * fact(n - 1);
+}
+
+
+ Revised 1 October, 2002
+ +© Copyright Dave Abrahams 2002. All Rights + Reserved.
+ + + diff --git a/doc/v2/numeric.html b/doc/v2/numeric.html new file mode 100644 index 00000000..554d7611 --- /dev/null +++ b/doc/v2/numeric.html @@ -0,0 +1,268 @@ + + + + + + + + +|
+ |
+
+
+ Boost.Python+ +Header <boost/python/numeric.hpp>+ |
+
arrayarray
+ synopsisarray
+ observer functionsarray
+ static functionsExposes a TypeWrapper for the Python + array + type.
+ +arrayProvides access to the array types of Numerical Python's Numeric and NumArray modules. With
+ the exception of the functions documented below, the semantics of the constructors and
+ member functions defined below can be fully understood by reading the TypeWrapper concept
+ definition. Since array is publicly derived from object, the public object
+ interface applies to array instances as well.
The default behavior is to use
+ Numeric.ArrayType as the associated Python type if the
+ Numeric module is installed in the default location.
+ Otherwise it falls back to use numarray.NDArray. If neither
+ extension module is installed, conversions to arguments of type
+ numeric::array will cause overload resolution to reject the
+ overload, and other attempted uses of numeric::array will raise an appropriate Python exception.
+ The associated Python type can be set manually using the set_module_and_type(...) static
+ function.
array
+ synopsis
+namespace boost { namespace python { namespace numeric
+{
+ class array : public object
+ {
+ public:
+ object astype();
+ template <class Type>
+ object astype(Type const& type_);
+
+ template <class Type>
+ object new_(Type const& type_) const;
+
+ template <class Sequence>
+ void resize(Sequence const& x);
+ void resize(long x1);
+ void resize(long x1, long x2);
+ ...
+ void resize(long x1, long x2,...long xn);
+
+ template <class Sequence>
+ void setshape(Sequence const& x);
+ void setshape(long x1);
+ void setshape(long x1, long x2);
+ ...
+ void setshape(long x1, long x2,...long xn);
+
+ template <class Indices, class Values>
+ void put(Indices const& indices, Values const& values);
+
+ template <class Sequence>
+ object take(Sequence const& sequence, long axis = 0);
+
+ template <class File>
+ void tofile(File const& f) const;
+
+ object factory();
+ template <class Buffer>
+ object factory(Buffer const&);
+ template <class Buffer, class Type>
+ object factory(Buffer const&, Type const&);
+ template <class Buffer, class Type, class Shape>
+ object factory(Buffer const&, Type const&, Shape const&, bool copy = true, bool savespace = false);
+ template <class Buffer, class Type, class Shape>
+ object factory(Buffer const&, Type const&, Shape const&, bool copy, bool savespace, char typecode);
+
+ template <class T1>
+ explicit array(T1 const& x1);
+ template <class T1, class T2>
+ explicit array(T1 const& x1, T2 const& x2);
+ ...
+ template <class T1, class T2,...class Tn>
+ explicit array(T1 const& x1, T2 const& x2,...Tn const& xn);
+
+ static void set_module_and_type();
+ static void set_module_and_type(char const* package_path = 0, char const* type_name = 0);
+
+ object argmax(long axis=-1);
+
+ object argmin(long axis=-1);
+
+ object argsort(long axis=-1);
+
+ void byteswap();
+
+ object copy() const;
+
+ object diagonal(long offset = 0, long axis1 = 0, long axis2 = 1) const;
+
+ void info() const;
+
+ bool is_c_array() const;
+ bool isbyteswapped() const;
+ void sort();
+ object trace(long offset = 0, long axis1 = 0, long axis2 = 1) const;
+ object type() const;
+ char typecode() const;
+
+ object getflat() const;
+ long getrank() const;
+ object getshape() const;
+ bool isaligned() const;
+ bool iscontiguous() const;
+ long itemsize() const;
+ long nelements() const;
+ object nonzero() const;
+
+ void ravel();
+
+ object repeat(object const& repeats, long axis=0);
+
+ void setflat(object const& flat);
+
+ void swapaxes(long axis1, long axis2);
+
+ str tostring() const;
+
+ void transpose(object const& axes = object());
+
+ object view() const;
+ };
+}}}
+
+
+ array observer
+ functions+object factory(); +template <class Buffer> +object factory(Buffer const&); +template <class Buffer, class Type> +object factory(Buffer const&, Type const&); +template <class Buffer, class Type, class Shape> +object factory(Buffer const&, Type const&, Shape const&, bool copy = true, bool savespace = false); +template <class Buffer, class Type, class Shape> +object factory(Buffer const&, Type const&, Shape const&, bool copy, bool savespace, char typecode); ++ These functions map to the underlying array type's
array()
+ function family. They are not called "array" because of the
+ C++ limitation that you can't define a member function with the same name
+ as its enclosing class.
++template <class Type> +object new_(Type const&) const; ++ This function maps to the underlying array type's
new()
+ function. It is not called "new" because that is a keyword
+ in C++.
+
+ array static
+ functions+static void set_module_and_type(char const* package_path, char const* type_name); +static void set_module_and_type(); ++ +
package_path and
+ type_name, if supplied, is an ntbs.type_name to
+ package_path. The second form restores the default search behavior. The associated Python
+ type will be searched for only the first time it is needed, and
+ thereafter the first time it is needed after an invocation of
+ set_module_and_type.
+#include <boost/python/numeric.hpp>
+#include <boost/python/tuple.hpp>
+
+// sets the first element in a 2d numeric array
+void set_first_element(numeric::array& y, double value)
+{
+ y[make_tuple(0,0)] = value;
+}
+
+
+ Revised 03 October, 2002
+ +© Copyright Dave Abrahams 2002. All Rights + Reserved.
+ + + diff --git a/doc/v2/object.html b/doc/v2/object.html new file mode 100644 index 00000000..9d6c6b53 --- /dev/null +++ b/doc/v2/object.html @@ -0,0 +1,931 @@ + + + + + + + + +|
+ |
+
+
+ Boost.Python+ +Header <boost/python/object.hpp>+ |
+
const_attribute_policiesconst_attribute_policies synopsisconst_attribute_policies static functionsattribute_policiesattribute_policies synopsisattribute_policies static functionsconst_item_policiesconst_item_policies synopsisconst_item_policies static functionsitem_policiesitem_policies synopsisitem_policies static functionsconst_slice_policiesconst_slice_policies synopsisconst_slice_policies static functionsslice_policiesslice_policies synopsisslice_policies static functionsobject_operatorsobject_operators synopsisobject_operators observer functionsobjectobject
+ synopsisobject
+ constructors and destructorobject modifier functionsobject observer functionsproxyproxy synopsisproxy modifier functionsproxy observer functionsExposes the generic Python object wrapper class object,
+ and related classes. In order to avoid some potenential problems with
+ argument-dependent lookup and the generalized operators defined on
+ object, all these facilities are defined in
+ namespace boost::python::api, and object
+ is imported into namespace boost::python with a
+ using-declaration.
+enum slice_nil { _ };
+
+ A type that can be used to get the effect of leaving out an index in a
+ Python slice expression:
++>>> x[:-1] ++ C++ equivalent: +
+x.slice(_,-1) ++ +
const_attribute_policiesThe policies which are used for proxies representing an attribute
+ access to a const object.
const_attribute_policies synopsis
+namespace boost { namespace python { namespace api
+{
+ struct const_attribute_policies
+ {
+ typedef char const* key_type;
+ static object get(object const& target, char const* key);
+ };
+}}}
+
+
+ const_attribute_policies static functions+static object get(object const& target, char const* key); ++ +
key is an ntbs.target named
+ by key.object managing the result of the
+ attribute access.error_already_set if a
+ Python exception is raised.attribute_policiesThe policies which are used for proxies representing an attribute
+ access to a mutable object.
attribute_policies synopsis
+namespace boost { namespace python { namespace api
+{
+ struct attribute_policies : const_attribute_policies
+ {
+ static object const& set(object const& target, char const* key, object const& value);
+ static void del(object const&target, char const* key);
+ };
+}}}
+
+
+ attribute_policies static functions+static object const& set(object const& target, char const* key, object const& value); ++ +
key is an ntbs.target named by
+ key to value.error_already_set if a
+ Python exception is raised.+static void del(object const&target, char const* key); ++ +
key is an ntbs.target named
+ by key.error_already_set if a
+ Python exception is raised.const_item_policiesThe policies which are used for proxies representing an item access
+ (via the Python bracket operators []) to a
+ const object.
const_item_policies synopsis
+namespace boost { namespace python { namespace api
+{
+ struct const_item_policies
+ {
+ typedef object key_type;
+ static object get(object const& target, object const& key);
+ };
+}}}
+
+
+ const_item_policies static functions+static object get(object const& target, object const& key); ++ +
target specified
+ by key.object managing the result of the
+ item access.error_already_set if a
+ Python exception is raised.item_policiesThe policies which are used for proxies representing an item access
+ (via the Python bracket operators []) to a mutable
+ object.
item_policies synopsis
+namespace boost { namespace python { namespace api
+{
+ struct item_policies : const_item_policies
+ {
+ static object const& set(object const& target, object const& key, object const& value);
+ static void del(object const& target, object const& key);
+ };
+}}}
+
+
+ item_policies static functions+static object const& set(object const& target, object const& key, object const& value); ++ +
target specified by
+ key to value.error_already_set if a
+ Python exception is raised.+static void del(object const& target, object const& key); ++ +
target specified
+ by key.error_already_set if a
+ Python exception is raised.const_slice_policiesThe policies which are used for proxies representing an slice access
+ (via the Python slice notation
+ [x:y]) to a
+ const object.
const_slice_policies synopsis
+namespace boost { namespace python { namespace api
+{
+ struct const_slice_policies
+ {
+ typedef std::pair<handle<>, handle<> > key_type;
+ static object get(object const& target, key_type const& key);
+ };
+}}}
+
+
+ const_slice_policies static functions+static object get(object const& target, key_type const& key); ++ +
target specified
+ by key.object managing the result of the
+ slice access.error_already_set if a
+ Python exception is raised.slice_policiesThe policies which are used for proxies representing an slice access
+ to a mutable object.
slice_policies synopsis
+namespace boost { namespace python { namespace api
+{
+ struct slice_policies : const_slice_policies
+ {
+ static object const& set(object const& target, key_type const& key, object const& value);
+ static void del(object const& target, key_type const& key);
+ };
+}}}
+
+
+ slice_policies static functions+static object const& set(object const& target, key_type const& key, object const& value); ++ +
target specified by
+ key to value.error_already_set if a
+ Python exception is raised.+static void del(object const& target, key_type const& key); ++ +
target specified
+ by key.error_already_set if a
+ Python exception is raised.object_operators<U>This is the base class of object and its
+ proxy template used to supply common interface: member
+ functions, and operators which must be defined within the class body. Its
+ template parameter U is expected to be a class derived from
+ object_operators<U>. In practice users should never
+ use this class directly, but it is documented here because it supplies
+ important interface to object and its proxies.
object_operators synopsis
+namespace boost { namespace python { namespace api
+{
+ template <class U>
+ class object_operators
+ {
+ public:
+ // function call
+ //
+ object operator()() const;
+
+ template <class A0>
+ object operator()(A0 const&) const;
+ template <class A0, class A1>
+ object operator()(A0 const&, A1 const&) const;
+ ...
+ template <class A0, class A1,...class An>
+ object operator()(A0 const&, A1 const&,...An const&) const;
+
+ // truth value testing
+ //
+ typedef unspecified bool_type;
+ operator bool_type() const;
+
+ // Attribute access
+ //
+ proxy<const_object_attribute> attr(char const*) const;
+ proxy<object_attribute> attr(char const*);
+
+ // item access
+ //
+ template <class T>
+ proxy<const_object_item> operator[](T const& key) const;
+
+ template <class T>
+ proxy<object_item> operator[](T const& key);
+
+ // slicing
+ //
+ template <class T, class V>
+ proxy<const_object_slice> slice(T const& start, V const& end) const
+
+ template <class T, class V>
+ proxy<object_slice> slice(T const& start, V const& end);
+ };
+}}}
+
+
+ object_operators observer functions+object operator()() const; +template <class A0> +object operator()(A0 const&) const; +template <class A0, class A1> +object operator()(A0 const&, A1 const&) const; +... +template <class A0, class A1,...class An> +object operator()(A0 const& a1, A1 const& a2,...An const& aN) const; ++ +
+operator bool_type() const; ++ +
*this.+proxy<const_object_attribute> attr(char const* name) const; +proxy<object_attribute> attr(char const* name); ++ +
*this.object(*static_cast<U*>(this)) as its target, and
+ name as its key.+template <class T> +proxy<const_object_item> operator[](T const& key) const; +template <class T> +proxy<object_item> operator[](T const& key); ++ +
*this indicated
+ by key.object(*static_cast<U*>(this)) as its target, and
+ object(key) as its key.+template <class T, class V> +proxy<const_object_slice> slice(T const& start; start, V const& finish) const +template <class T, class V> +proxy<object_slice> slice(T const& start; start, V const& finish); ++ +
*this indicated
+ by std::make_pair(object(start), object(finish)).object(*static_cast<U*>(this)) as its target, and
+ std::make_pair(object(start), object(finish)) as its
+ key.objectThe intention is that object acts as much like a
+ Python variable as possible. Thus expressions you'd expect to work
+ in Python should generally work in the same way from C++. Most of
+ object's interface is provided by its base class
+ object_operators<object>,
+ and the free functions defined in this
+ header.
+
object
+ synopsis
+namespace boost { namespace python { namespace api
+{
+ class object : public object_operators<object>
+ {
+ public:
+ object();
+
+ object(object const&);
+
+ template <class T>
+ explicit object(T const& x);
+
+ ~object();
+
+ object& operator=(object const&);
+
+ PyObject* ptr() const;
+ };
+}}}
+
+
+ object
+ constructors and destructor+object(); ++ +
None object.+template <class T> +explicit object(T const& x); ++ +
x to python and manages a
+ reference to it.error_already_set and sets a Python
+ TypeError exception if no such conversion is
+ possible.+~object(); ++ +
object
+ modifiers+object& operator=(object const& rhs); ++ +
rhs and decrements the reference count of the object
+ held by *this.object
+ observers+PyObject* ptr() const; ++ +
proxyThis template is instantiated with various Policies described in this
+ document in order to implement attribute, item, and slice access for
+ object. It stores an object of type
+ Policies::key_type.
proxy
+ synopsis
+namespace boost { namespace python { namespace api
+{
+ template <class Policies>
+ class proxy : public object_operators<proxy<Policies> >
+ {
+ public:
+ operator object() const;
+
+ proxy const& operator=(proxy const&) const;
+ template <class T>
+ inline proxy const& operator=(T const& rhs) const;
+
+ void del() const;
+
+ template <class R>
+ proxy operator+=(R const& rhs);
+ template <class R>
+ proxy operator-=(R const& rhs);
+ template <class R>
+ proxy operator*=(R const& rhs);
+ template <class R>
+ proxy operator/=(R const& rhs);
+ template <class R>
+ proxy operator%=(R const& rhs);
+ template <class R>
+ proxy operator<<=(R const& rhs);
+ template <class R>
+ proxy operator>>=(R const& rhs);
+ template <class R>
+ proxy operator&=(R const& rhs);
+ template <class R>
+ proxy operator|=(R const& rhs);
+ };
+}}}
+
+
+ proxy
+ observer functions+operator object() const; ++ +
Policies::get(target, key
+ ) with the proxy's target and key objects.proxy
+ modifier functions+proxy const& operator=(proxy const& rhs) const; +template <class T> +inline proxy const& operator=(T const& rhs) const; ++ +
Policies::set(target, key
+ , object(rhs)) with the proxy's target and key
+ objects.+template <class R> +proxy operator+=(R const& rhs); +template <class R> +proxy operator-=(R const& rhs); +template <class R> +proxy operator*=(R const& rhs); +template <class R> +proxy operator/=(R const& rhs); +template <class R> +proxy operator%=(R const& rhs); +template <class R> +proxy operator<<=(R const& rhs); +template <class R> +proxy operator>>=(R const& rhs); +template <class R> +proxy operator&=(R const& rhs); +template <class R> +proxy operator|=(R const& rhs); ++ +
object(*this) @= rhs;*this+void del() const; ++ +
Policies::del(target, key
+ ) with the proxy's target and key objects.+template <class T> +void del(proxy<T> const& x); ++ +
+ +template<class L,class R> bool operator>(L const&l,R const&r); +template<class L,class R> bool operator>=(L const&l,R const&r); +template<class L,class R> bool operator<(L const&l,R const&r); +template<class L,class R> bool operator<=(L const&l,R const&r); +template<class L,class R> bool operator==(L const&l,R const&r); +template<class L,class R> bool operator!=(L const&l,R const&r); ++ +
object(l) and object(r), respectively, in
+ Python.+ +template<class L,class R> object operator+(L const&l,R const&r); +template<class L,class R> object operator-(L const&l,R const&r); +template<class L,class R> object operator*(L const&l,R const&r); +template<class L,class R> object operator/(L const&l,R const&r); +template<class L,class R> object operator%(L const&l,R const&r); +template<class L,class R> object operator<<(L const&l,R const&r); +template<class L,class R> object operator>>(L const&l,R const&r); +template<class L,class R> object operator&(L const&l,R const&r); +template<class L,class R> object operator^(L const&l,R const&r); +template<class L,class R> object operator|(L const&l,R const&r); ++ +
object(l) and object(r), respectively, in
+ Python.+ +template<class R> object& operator+=(object&l,R const&r); +template<class R> object& operator-=(object&l,R const&r); +template<class R> object& operator*=(object&l,R const&r); +template<class R> object& operator/=(object&l,R const&r); +template<class R> object& operator%=(object&l,R const&r); +template<class R> object& operator<<=(object&l,R const&r) +template<class R> object& operator>>=(object&l,R const&r); +template<class R> object& operator&=(object&l,R const&r); +template<class R> object& operator^=(object&l,R const&r); +template<class R> object& operator|=(object&l,R const&r); ++ +
l and
+ object(r), respectively.l.+def sum_items(seq): + result = 0 + for x in seq: + result += x + return result ++ C++ version: +
+object sum_items(object seq)
+{
+ object result = object(0);
+ for (int i = 0; i < seq.attr("__len__")(); ++i)
+ result += seq[i];
+ return result;
+}
+
+
+ Revised + + 02 October, 2002 + +
+ +© Copyright Dave Abrahams 2002. All Rights + Reserved.
+ + + diff --git a/doc/v2/overloads.html b/doc/v2/overloads.html new file mode 100644 index 00000000..3e931980 --- /dev/null +++ b/doc/v2/overloads.html @@ -0,0 +1,225 @@ + + + + + + + + +|
+ |
+
+
+ Boost.Python+ +Header <boost/python/overloads.hpp>+ |
+
Defines facilities for generating families of overloaded Python + functions and extension class methods from C++ functions and + member functions with default arguments, or from similar families + of C++ overloads
+ ++ An overload-dispatch-expression is used to describe a + family of overloaded methods to be generated for an extension + class. It has the following properties: + +
++ ++
+- docstring: An ntbs + whose value will bound to the methods'
+ +__doc__+ attribute- keywords: A keyword-expression which + will be used to name (a trailing subsequence of) the arguments + to the generated methods.
+ +- call policies: An instance of some type which models CallPolicies.
+ +- minimum arity + The minimum number of arguments to be accepted by a generated + method overload.
+ +- maximum arity + The maximum number of arguments to be accepted by a generated + method overload.
+
X is a class which has a
+ minimum arity and a maximum arity, and for which
+ the following following are valid overload-dispatch-expressions,
+ with the same minimum and maximum arity as the OverloadDispatcher.
+
++X() +X(docstring) +X(docstring, keywords) +X(keywords, docstring) +X()[policies] +X(docstring)[policies] +X(docstring, keywords)[policies] +X(keywords, docstring)[policies] ++ +
policies are supplied, it must be an instance of a
+type which models CallPolicies, and
+will be used as the result's call policies. Otherwise the result's
+call policies will be an instance of default_call_policies.
+
+docstring is supplied it must be an ntbs, and will be used as the result's docstring. Otherwise the result has an empty docstring.
+
+keywords is supplied it must be the result of a keyword-expression
+ whose length is no greater than X's maximum
+ arity, and will be used as the result's keywords. Otherwise
+ the result's keywords will be empty.
+name in the current scope which can be used to
+ generate the following function invocation:
++func_id(a1, a2,...ai); ++ + for all
min_args <= i <= max_args.
+
+ name in the current scope which can be used to
+ generate the following function invocation:
++x.member_name(a1, a2,...ai); ++ + for all
min_args <= i <=
+ max_args, where x is a reference to an
+ object of class type.
+
+
+#include <boost/python/module.hpp>
+#include <boost/python/def.hpp>
+#include <boost/python/args.hpp>
+#include <boost/python/tuple.hpp>
+#include <boost/python/class.hpp>
+#include <boost/python/overloads.hpp>
+#include <boost/python/return_internal_reference.hpp>
+
+using namespace boost::python;
+
+tuple f(int x = 1, double y = 4.25, char const* z = "wow")
+{
+ return make_tuple(x, y, z);
+}
+
+BOOST_PYTHON_FUNCTION_OVERLOADS(f_overloads, f, 0, 3)
+
+stryct Y {};
+struct X
+{
+ Y& f(int x, double y = 4.25, char const* z = "wow")
+ {
+ return inner;
+ }
+ Y inner;
+};
+
+BOOST_PYTHON_MEMBER_FUNCTION_OVERLOADS(X_f_overloads, X::f, 1, 3)
+
+BOOST_PYTHON_MODULE(args_ext)
+{
+ def("f", f, args("x", "y", "z")
+ , "This is f's docstring"
+ );
+
+
+ class_<Y>("Y")
+ ;
+
+ class_<X>("X", "This is X's docstring")
+ .def("f1", &X::f,
+ X_f_overloads(args("x", "y", "z"),
+ "f's docstring"
+ )[return_internal_reference<>()])
+ ;
+}
+
+
+ Revised + + 01 October, 2002 + +
+ +© Copyright Dave Abrahams 2002. All Rights + Reserved.
+ + + diff --git a/doc/v2/pointee.html b/doc/v2/pointee.html new file mode 100644 index 00000000..a5387da4 --- /dev/null +++ b/doc/v2/pointee.html @@ -0,0 +1,116 @@ + + + + + +|
+ |
+ Boost.Python+ +Header <boost/python/pointee.hpp>+ |
pointee
+
+ pointee synopsis
+ <boost/python/pointee.hpp> introduces a
+ traits metafunction
+ template pointee<T> which can be used to extract the "pointed-to" type from the type of a pointer or smart pointer.
+
+
pointee<class T>pointee<T> is used by the class_<...>
+ template to deduce the type being held when a pointer or smart
+ pointer type is used as its HeldType argument.
+
+
pointee synopsis
+namespace boost { namespace python
+{
+ template <class T> struct pointee
+ {
+ typedef T::element_type type;
+ };
+
+ // specialization for pointers
+ template <T> struct pointee<T*>
+ {
+ typedef T type;
+ };
+}
+
+
+
+ smart_pointer<T>, one might partially specialize
+pointee<smart_pointer<T> > so that it can be
+used as the HeldType for a class wrapper:
+
+
+#include <boost/python/pointee.hpp>
+#include <boost/python/class.hpp>
+#include <third_party_lib.hpp>
+
+namespace boost { namespace python
+{
+ template <class T> struct pointee<smart_pointer<T> >
+ {
+ typedef T type;
+ };
+}}
+
+BOOST_PYTHON_MODULE(pointee_demo)
+{
+ class_<third_party_class, smart_pointer<third_party_class> >("third_party_class")
+ .def(...)
+ ...
+ ;
+}
+
+
+ Revised + + 03 October, 2002 + + + +
© Copyright Dave + Abrahams 2002. All Rights Reserved. + diff --git a/doc/v2/scope.html b/doc/v2/scope.html new file mode 100644 index 00000000..17450645 --- /dev/null +++ b/doc/v2/scope.html @@ -0,0 +1,153 @@ + + + +
+ + + + +|
+ |
+
+
+ Boost.Python+ +Header <boost/python/scope.hpp>+ |
+
scopescope
+ synopsisscope
+ constructors and destructorDefines facilities for querying and controlling the Python scope + (namespace) which will contain new wrapped classes and functions.
+ +scopeThe scope class has an associated global Python object
+ which controls the Python namespace in which new extension classes and
+ wrapped functions will be defined as attributes. Default-constructing a
+ new scope object binds that object to the associated Python
+ object. Constructing a is associated with , and
scope
+ synopsis
+namespace boost { namespace python
+{
+ class scope : public object, private noncopyable
+ {
+ public:
+ scope(object const&);
+ scope();
+ ~scope()
+ };
+}}
+
+
+ scope constructors
+ and destructor+scope(object const& x); ++ Stores a reference to the current associated scope object, and sets the + associated scope object to the one referred to by
x.ptr().
+ The object base class is initialized with x.
++scope(); ++ Stores a reference to the current associated scope object. The +
object base class is initialized with the current associated
+ scope object. Outside any module initialization function, the current
+ associated Python object is None.
++~scope() ++ Sets the current associated Python object to the stored object. + +
C++ Module definition:
+
+#include <boost/python/class.hpp>
+#include <boost/python/scope.hpp>
+using namespace boost::python;
+
+struct X
+{
+ void f();
+
+ struct Y { int g() { return 0; } };
+};
+
+BOOST_PYTHON_MODULE(nested)
+{
+ scope outer
+ = class_<X>("X")
+ .def("f", &X::f)
+ ;
+ class_<Y>("Y")
+ .def("g", &Y::g)
+ ;
+}
+
+ Interactive Python:
++>>> import nested +>>> y = nested.X.Y() +>>> y.g() +0 ++ +
Revised 03 October, 2002
+ +© Copyright Dave Abrahams 2002. All Rights + Reserved.
+ + + diff --git a/doc/v2/str.html b/doc/v2/str.html new file mode 100644 index 00000000..842dc660 --- /dev/null +++ b/doc/v2/str.html @@ -0,0 +1,230 @@ + + + + + + + + +|
+ |
+
+
+ Boost.Python+ +Header <boost/python/str.hpp>+ |
+
strstr
+ synopsisExposes a TypeWrapper for the Python + str + type.
+ +strExposes the string
+ methods of Python's built-in str type. The
+ semantics of the constructors and member functions defined below
+ can be fully understood by reading the TypeWrapper concept
+ definition. Since str is publicly derived from
+ object, the
+ public object interface applies to str instances as
+ well.
str
+ synopsis
+namespace boost { namespace python
+{
+ class str : public object
+ {
+ public:
+ str(); // new str
+
+ str(const char* s); // new str
+
+ template <class T>
+ explicit str(T const& other);
+
+ str capitalize() const;
+
+ template <class T>
+ str center(T const& width) const;
+
+ template<class T>
+ long count(T const& sub) const;
+ template<class T1, class T2>
+ long count(T1 const& sub,T2 const& start) const;
+ template<class T1, class T2, class T3>
+ long count(T1 const& sub,T2 const& start, T3 const& end) const;
+
+ object decode() const;
+ template<class T>
+ object decode(T const& encoding) const;
+ template<class T1, class T2>
+ object decode(T1 const& encoding, T2 const& errors) const;
+
+ object encode() const;
+ template <class T>
+ object encode(T const& encoding) const;
+ template <class T1, class T2>
+ object encode(T1 const& encoding, T2 const& errors) const;
+
+ template <class T>
+ bool endswith(T const& suffix) const;
+ template <class T1, class T2>
+ bool endswith(T1 const& suffix, T2 const& start) const;
+ template <class T1, class T2, class T3>
+ bool endswith(T1 const& suffix, T2 const& start, T3 const& end) const;
+
+ str expandtabs() const;
+ template <class T>
+ str expandtabs(T const& tabsize) const;
+
+ template <class T>
+ long find(T const& sub) const;
+ template <class T1, class T2>
+ long find(T1 const& sub, T2 const& start) const;
+ template <class T1, class T2, class T3>
+ long find(T1 const& sub, T2 const& start, T3 const& end) const;
+
+ template <class T>
+ long index(T const& sub) const;
+ template <class T1, class T2>
+ long index(T1 const& sub, T2 const& start) const;
+ template <class T1, class T2, class T3>
+ long index(T1 const& sub, T2 const& start, T3 const& end) const;
+
+ bool isalnum() const;
+ bool isalpha() const;
+ bool isdigit() const;
+ bool islower() const;
+ bool isspace() const;
+ bool istitle() const;
+ bool isupper() const;
+
+ template <class T>
+ str join(T const& sequence) const;
+
+ template <class T>
+ str ljust(T const& width) const;
+
+ str lower() const;
+ str lstrip() const;
+
+ template <class T1, class T2>
+ str replace(T1 const& old, T2 const& new_) const;
+ template <class T1, class T2, class T3>
+ str replace(T1 const& old, T2 const& new_, T3 const& maxsplit) const;
+
+ template <class T>
+ long rfind(T const& sub) const;
+ template <class T1, class T2>
+ long rfind(T1 const& sub, T2 const& start) const;
+ template <class T1, class T2, class T3>
+ long rfind(T1 const& sub, T2 const& start, T3 const& end) const;
+
+ template <class T>
+ long rindex(T const& sub) const;
+ template <class T1, class T2>
+ long rindex(T1 const& sub, T2 const& start) const;
+ template <class T1, class T2, class T3>
+ long rindex(T1 const& sub, T2 const& start, T3 const& end) const;
+
+ template <class T>
+ str rjust(T const& width) const;
+
+ str rstrip() const;
+
+ list split() const;
+ template <class T>
+ list split(T const& sep) const;
+ template <class T1, class T2>
+ list split(T1 const& sep, T2 const& maxsplit) const;
+
+ list splitlines() const;
+ template <class T>
+ list splitlines(T const& keepends) const;
+
+ template <class T>
+ bool startswith(T const& prefix) const;
+ template <class T1, class T2>
+ bool startswidth(T1 const& prefix, T2 const& start) const;
+ template <class T1, class T2, class T3>
+ bool startswidth(T1 const& prefix, T2 const& start, T3 const& end) const;
+
+ str strip() const;
+ str swapcase() const;
+ str title() const;
+
+ template <class T>
+ str translate(T const& table) const;
+ template <class T1, class T2>
+ str translate(T1 const& table, T2 const& deletechars) const;
+
+ str upper() const;
+ };
+}}
+
+
+
+using namespace boost::python;
+str remove_angle_brackets(str x)
+{
+ return x.strip('<').strip('>');
+}
+
+
+ Revised 3 October, 2002
+ +© Copyright Dave Abrahams 2002. All Rights + Reserved.
+ + + diff --git a/doc/v2/tuple.html b/doc/v2/tuple.html new file mode 100644 index 00000000..8fb672fa --- /dev/null +++ b/doc/v2/tuple.html @@ -0,0 +1,137 @@ + + + + + + + + +|
+ |
+
+
+ Boost.Python+ +Header <boost/python/tuple.hpp>+ |
+
tupletuple
+ synopsismake_tupleExposes a TypeWrapper for the Python + + tuple type.
+ +tupleExposes the interface of Python's built-in tuple type.
+ The semantics of the constructors and member functions defined below can
+ be fully understood by reading the TypeWrapper concept
+ definition. Since tuple is publicly derived from object, the public object
+ interface applies to tuple instances as well.
tuple
+ synopsis
+namespace boost { namespace python
+{
+ class tuple : public object
+ {
+ // tuple() -> an empty tuple
+ tuple();
+
+ // tuple(sequence) -> tuple initialized from sequence's items
+ template <class T>
+ explicit tuple(T const& sequence)
+ };
+}}
+
+
+ make_tuple
+namespace boost { namespace python
+{
+ tuple make_tuple();
+
+ template <class A0>
+ tuple make_tuple(A0 const& a0);
+
+ template <class A0, class A1>
+ tuple make_tuple(A0 const& a0, A1 const& a1);
+ ...
+ template <class A0, class A1,...class An>
+ tuple make_tuple(A0 const& a0, A1 const& a1,...An const& an);
+}}
+
+ Constructs a new tuple object composed of object(a0),
+ object(a0),...object(an).
+
+
+using namespace boost::python;
+tuple head_and_tail(object sequence)
+{
+ return make_tuple(sequence[0],sequence[-1]);
+}
+
+
+ Revised 03 October, 2002
+ +© Copyright Dave Abrahams 2002. All Rights + Reserved.
+ + + diff --git a/include/boost/python/detail/overloads_fwd.hpp b/include/boost/python/detail/overloads_fwd.hpp new file mode 100644 index 00000000..94ec503f --- /dev/null +++ b/include/boost/python/detail/overloads_fwd.hpp @@ -0,0 +1,19 @@ +// Copyright David Abrahams 2002. Permission to copy, use, +// modify, sell and distribute this software is granted provided this +// copyright notice appears in all copies. This software is provided +// "as is" without express or implied warranty, and with no claim as +// to its suitability for any purpose. +#ifndef OVERLOADS_FWD_DWA2002101_HPP +# define OVERLOADS_FWD_DWA2002101_HPP + +namespace boost { namespace python { namespace detail { + +// forward declarations +struct overloads_base; + +template