args.qbk 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. [section boost/python/args.hpp]
  2. [section Introduction]
  3. Supplies a family of overloaded functions for specifying argument keywords for wrapped C++ functions.
  4. [section keyword-expressions]
  5. A keyword-expression results in an object which holds a sequence of [link ntbs]\ es, 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
  6. [endsect]
  7. [endsect]
  8. [section Class `arg`]
  9. The objects of class arg are keyword-expressions holding one keyword ( size one )
  10. ``
  11. namespace boost { namespace python
  12. {
  13. struct arg
  14. {
  15. template <class T>
  16. arg &operator = (T const &value);
  17. explicit arg (char const *name){elements[0].name = name;}
  18. };
  19. }}
  20. ``
  21. [endsect]
  22. [section Class `arg` constructor]
  23. ``arg(char const* name);``
  24. [variablelist
  25. [[Requires][The argument must be a [link ntbs].]]
  26. [[Effects][Constructs an arg object holding a keyword with name name.]]
  27. ]
  28. [endsect]
  29. [section Class `arg` operator=]
  30. ``template <class T> arg &operator = (T const &value);``
  31. [variablelist
  32. [[Requires][The argument must convertible to python.]]
  33. [[Effects][Assigns default value for the keyword.]]
  34. [[Returns][Reference to `this`.]]
  35. ]
  36. [endsect]
  37. [section Keyword-expression operator,]
  38. ``
  39. keyword-expression operator , (keyword-expression, const arg &kw) const
  40. keyword-expression operator , (keyword-expression, const char *name) const;
  41. ``
  42. [variablelist
  43. [[Requires][The argument name must be a [link ntbs].]]
  44. [[Effects][Extends the keyword-expression argument with one more keyword.]]
  45. [[Returns][The extended keyword-expression.]]
  46. ]
  47. [endsect]
  48. [section Example]
  49. ``
  50. #include <boost/python/def.hpp>
  51. using namespace boost::python;
  52. int f(double x, double y, double z=0.0, double w=1.0);
  53. BOOST_PYTHON_MODULE(xxx)
  54. {
  55. def("f", f, (arg("x"), "y", arg("z")=0.0, arg("w")=1.0));
  56. }
  57. ``
  58. [endsect]
  59. [endsect]