File indexing completed on 2025-01-18 09:50:41
0001
0002
0003
0004
0005 #ifndef LIST_DWA2002627_HPP
0006 # define LIST_DWA2002627_HPP
0007
0008 # include <boost/python/detail/prefix.hpp>
0009
0010 # include <boost/python/object.hpp>
0011 # include <boost/python/converter/pytype_object_mgr_traits.hpp>
0012 # include <boost/python/ssize_t.hpp>
0013
0014 namespace boost { namespace python {
0015
0016 namespace detail
0017 {
0018 struct BOOST_PYTHON_DECL list_base : object
0019 {
0020 void append(object_cref);
0021
0022 ssize_t count(object_cref value) const;
0023
0024 void extend(object_cref sequence);
0025
0026 long index(object_cref value) const;
0027
0028 void insert(ssize_t index, object_cref);
0029 void insert(object const& index, object_cref);
0030
0031 object pop();
0032 object pop(ssize_t index);
0033 object pop(object const& index);
0034
0035 void remove(object_cref value);
0036
0037 void reverse();
0038
0039 void sort();
0040 #if PY_VERSION_HEX >= 0x03000000
0041 void sort(args_proxy const &args,
0042 kwds_proxy const &kwds);
0043 #else
0044 void sort(object_cref cmpfunc);
0045 #endif
0046
0047 protected:
0048 list_base();
0049 explicit list_base(object_cref sequence);
0050
0051 BOOST_PYTHON_FORWARD_OBJECT_CONSTRUCTORS(list_base, object)
0052 private:
0053 static detail::new_non_null_reference call(object const&);
0054 };
0055 }
0056
0057 class list : public detail::list_base
0058 {
0059 typedef detail::list_base base;
0060 public:
0061 list() {}
0062
0063 template <class T>
0064 explicit list(T const& sequence)
0065 : base(object(sequence))
0066 {
0067 }
0068
0069 template <class T>
0070 void append(T const& x)
0071 {
0072 base::append(object(x));
0073 }
0074
0075 template <class T>
0076 ssize_t count(T const& value) const
0077 {
0078 return base::count(object(value));
0079 }
0080
0081 template <class T>
0082 void extend(T const& x)
0083 {
0084 base::extend(object(x));
0085 }
0086
0087 template <class T>
0088 long index(T const& x) const
0089 {
0090 return base::index(object(x));
0091 }
0092
0093 template <class T>
0094 void insert(ssize_t index, T const& x)
0095 {
0096 base::insert(index, object(x));
0097 }
0098
0099 template <class T>
0100 void insert(object const& index, T const& x)
0101 {
0102 base::insert(index, object(x));
0103 }
0104
0105 object pop() { return base::pop(); }
0106 object pop(ssize_t index) { return base::pop(index); }
0107
0108 template <class T>
0109 object pop(T const& index)
0110 {
0111 return base::pop(object(index));
0112 }
0113
0114 template <class T>
0115 void remove(T const& value)
0116 {
0117 base::remove(object(value));
0118 }
0119
0120 #if PY_VERSION_HEX <= 0x03000000
0121 void sort() { base::sort(); }
0122
0123 template <class T>
0124 void sort(T const& value)
0125 {
0126 base::sort(object(value));
0127 }
0128 #endif
0129
0130 public:
0131 BOOST_PYTHON_FORWARD_OBJECT_CONSTRUCTORS(list, base)
0132 };
0133
0134
0135
0136
0137 namespace converter
0138 {
0139 template <>
0140 struct object_manager_traits<list>
0141 : pytype_object_manager_traits<&PyList_Type,list>
0142 {
0143 };
0144 }
0145
0146 }}
0147
0148 #endif