Warning, file /include/boost/python/object_slices.hpp was not indexed
or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).
0001
0002
0003
0004
0005 #ifndef OBJECT_SLICES_DWA2002615_HPP
0006 # define OBJECT_SLICES_DWA2002615_HPP
0007
0008 # include <boost/python/detail/prefix.hpp>
0009
0010 # include <boost/python/proxy.hpp>
0011 # include <boost/python/object_core.hpp>
0012 # include <boost/python/object_protocol.hpp>
0013 # include <boost/python/handle.hpp>
0014 # include <utility>
0015
0016 namespace boost { namespace python { namespace api {
0017
0018 struct const_slice_policies
0019 {
0020 typedef std::pair<handle<>, handle<> > key_type;
0021 static object get(object const& target, key_type const& key);
0022 };
0023
0024 struct slice_policies : const_slice_policies
0025 {
0026 static object const& set(object const& target, key_type const& key, object const& value);
0027 static void del(object const& target, key_type const& key);
0028 };
0029
0030 template <class T, class U>
0031 inline slice_policies::key_type slice_key(T x, U y)
0032 {
0033 return slice_policies::key_type(handle<>(x), handle<>(y));
0034 }
0035
0036
0037
0038
0039 template <class U>
0040 object_slice
0041 object_operators<U>::slice(object_cref start, object_cref finish)
0042 {
0043 object_cref2 x = *static_cast<U*>(this);
0044 return object_slice(x, api::slice_key(borrowed(start.ptr()), borrowed(finish.ptr())));
0045 }
0046
0047 template <class U>
0048 const_object_slice
0049 object_operators<U>::slice(object_cref start, object_cref finish) const
0050 {
0051 object_cref2 x = *static_cast<U const*>(this);
0052 return const_object_slice(x, api::slice_key(borrowed(start.ptr()), borrowed(finish.ptr())));
0053 }
0054
0055 template <class U>
0056 object_slice
0057 object_operators<U>::slice(slice_nil, object_cref finish)
0058 {
0059 object_cref2 x = *static_cast<U*>(this);
0060 return object_slice(x, api::slice_key(allow_null((PyObject*)0), borrowed(finish.ptr())));
0061 }
0062
0063 template <class U>
0064 const_object_slice
0065 object_operators<U>::slice(slice_nil, object_cref finish) const
0066 {
0067 object_cref2 x = *static_cast<U const*>(this);
0068 return const_object_slice(x, api::slice_key(allow_null((PyObject*)0), borrowed(finish.ptr())));
0069 }
0070
0071 template <class U>
0072 object_slice
0073 object_operators<U>::slice(slice_nil, slice_nil)
0074 {
0075 object_cref2 x = *static_cast<U*>(this);
0076 return object_slice(x, api::slice_key(allow_null((PyObject*)0), allow_null((PyObject*)0)));
0077 }
0078
0079 template <class U>
0080 const_object_slice
0081 object_operators<U>::slice(slice_nil, slice_nil) const
0082 {
0083 object_cref2 x = *static_cast<U const*>(this);
0084 return const_object_slice(x, api::slice_key(allow_null((PyObject*)0), allow_null((PyObject*)0)));
0085 }
0086
0087 template <class U>
0088 object_slice
0089 object_operators<U>::slice(object_cref start, slice_nil)
0090 {
0091 object_cref2 x = *static_cast<U*>(this);
0092 return object_slice(x, api::slice_key(borrowed(start.ptr()), allow_null((PyObject*)0)));
0093 }
0094
0095 template <class U>
0096 const_object_slice
0097 object_operators<U>::slice(object_cref start, slice_nil) const
0098 {
0099 object_cref2 x = *static_cast<U const*>(this);
0100 return const_object_slice(x, api::slice_key(borrowed(start.ptr()), allow_null((PyObject*)0)));
0101 }
0102
0103 template <class U>
0104 template <class T, class V>
0105 inline const_object_slice
0106 object_operators<U>::slice(T const& start, V const& end) const
0107 {
0108 return this->slice(
0109 typename slice_bound<T>::type(start)
0110 , typename slice_bound<V>::type(end));
0111 }
0112
0113 template <class U>
0114 template <class T, class V>
0115 inline object_slice
0116 object_operators<U>::slice(T const& start, V const& end)
0117 {
0118 return this->slice(
0119 typename slice_bound<T>::type(start)
0120 , typename slice_bound<V>::type(end));
0121 }
0122
0123 inline object const_slice_policies::get(object const& target, key_type const& key)
0124 {
0125 return getslice(target, key.first, key.second);
0126 }
0127
0128 inline object const& slice_policies::set(
0129 object const& target
0130 , key_type const& key
0131 , object const& value)
0132 {
0133 setslice(target, key.first, key.second, value);
0134 return value;
0135 }
0136
0137 inline void slice_policies::del(
0138 object const& target
0139 , key_type const& key)
0140 {
0141 delslice(target, key.first, key.second);
0142 }
0143
0144 }}}
0145
0146 #endif