]> git.proxmox.com Git - ceph.git/blame - ceph/src/boost/libs/python/include/boost/python/object_items.hpp
bump version to 12.2.2-pve1
[ceph.git] / ceph / src / boost / libs / python / include / boost / python / object_items.hpp
CommitLineData
7c673cae
FG
1// Copyright David Abrahams 2002.
2// Distributed under the Boost Software License, Version 1.0. (See
3// accompanying file LICENSE_1_0.txt or copy at
4// http://www.boost.org/LICENSE_1_0.txt)
5#ifndef OBJECT_ITEMS_DWA2002615_HPP
6# define OBJECT_ITEMS_DWA2002615_HPP
7
8# include <boost/python/detail/prefix.hpp>
9
10# include <boost/python/proxy.hpp>
11# include <boost/python/object_core.hpp>
12# include <boost/python/object_protocol.hpp>
13
14namespace boost { namespace python { namespace api {
15
16struct const_item_policies
17{
18 typedef object key_type;
19 static object get(object const& target, object const& key);
20};
21
22struct item_policies : const_item_policies
23{
24 static object const& set(object const& target, object const& key, object const& value);
25 static void del(object const& target, object const& key);
26};
27
28//
29// implementation
30//
31template <class U>
32inline object_item
33object_operators<U>::operator[](object_cref key)
34{
35 object_cref2 x = *static_cast<U*>(this);
36 return object_item(x, key);
37}
38
39template <class U>
40inline const_object_item
41object_operators<U>::operator[](object_cref key) const
42{
43 object_cref2 x = *static_cast<U const*>(this);
44 return const_object_item(x, key);
45}
46
47template <class U>
48template <class T>
49inline const_object_item
50object_operators<U>::operator[](T const& key) const
51{
52 return (*this)[object(key)];
53}
54
55template <class U>
56template <class T>
57inline object_item
58object_operators<U>::operator[](T const& key)
59{
60 return (*this)[object(key)];
61}
62
63inline object const_item_policies::get(object const& target, object const& key)
64{
65 return getitem(target, key);
66}
67
68inline object const& item_policies::set(
69 object const& target
70 , object const& key
71 , object const& value)
72{
73 setitem(target, key, value);
74 return value;
75}
76
77inline void item_policies::del(
78 object const& target
79 , object const& key)
80{
81 delitem(target, key);
82}
83
84}}} // namespace boost::python::api
85
86#endif // OBJECT_ITEMS_DWA2002615_HPP