]> git.proxmox.com Git - ceph.git/blame - ceph/src/boost/libs/python/include/boost/python/object_protocol.hpp
add subtree-ish sources for 12.0.3
[ceph.git] / ceph / src / boost / libs / python / include / boost / python / object_protocol.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_PROTOCOL_DWA2002615_HPP
6# define OBJECT_PROTOCOL_DWA2002615_HPP
7
8# include <boost/python/detail/prefix.hpp>
9
10# include <boost/python/object_protocol_core.hpp>
11# include <boost/python/object_core.hpp>
12
13# include <boost/detail/workaround.hpp>
14
15namespace boost { namespace python { namespace api {
16
17# if BOOST_WORKAROUND(__SUNPRO_CC, BOOST_TESTED_AT(0x590))
18// attempt to use SFINAE to prevent functions accepting T const& from
19// coming up as ambiguous with the one taking a char const* when a
20// string literal is passed
21# define BOOST_PYTHON_NO_ARRAY_ARG(T) , T (*)() = 0
22# else
23# define BOOST_PYTHON_NO_ARRAY_ARG(T)
24# endif
25
26template <class Target, class Key>
27object getattr(Target const& target, Key const& key BOOST_PYTHON_NO_ARRAY_ARG(Key))
28{
29 return getattr(object(target), object(key));
30}
31
32template <class Target, class Key, class Default>
33object getattr(Target const& target, Key const& key, Default const& default_ BOOST_PYTHON_NO_ARRAY_ARG(Key))
34{
35 return getattr(object(target), object(key), object(default_));
36}
37
38
39template <class Key, class Value>
40void setattr(object const& target, Key const& key, Value const& value BOOST_PYTHON_NO_ARRAY_ARG(Key))
41{
42 setattr(target, object(key), object(value));
43}
44
45template <class Key>
46void delattr(object const& target, Key const& key BOOST_PYTHON_NO_ARRAY_ARG(Key))
47{
48 delattr(target, object(key));
49}
50
51template <class Target, class Key>
52object getitem(Target const& target, Key const& key BOOST_PYTHON_NO_ARRAY_ARG(Key))
53{
54 return getitem(object(target), object(key));
55}
56
57
58template <class Key, class Value>
59void setitem(object const& target, Key const& key, Value const& value BOOST_PYTHON_NO_ARRAY_ARG(Key))
60{
61 setitem(target, object(key), object(value));
62}
63
64template <class Key>
65void delitem(object const& target, Key const& key BOOST_PYTHON_NO_ARRAY_ARG(Key))
66{
67 delitem(target, object(key));
68}
69
70template <class Target, class Begin, class End>
71object getslice(Target const& target, Begin const& begin, End const& end)
72{
73 return getslice(object(target), object(begin), object(end));
74}
75
76template <class Begin, class End, class Value>
77void setslice(object const& target, Begin const& begin, End const& end, Value const& value)
78{
79 setslice(target, object(begin), object(end), object(value));
80}
81
82template <class Begin, class End>
83void delslice(object const& target, Begin const& begin, End const& end)
84{
85 delslice(target, object(begin), object(end));
86}
87
88}}} // namespace boost::python::api
89
90#endif // OBJECT_PROTOCOL_DWA2002615_HPP