Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: downloads/boost_1_33_1/boost/python/object_protocol.hpp @ 18

Last change on this file since 18 was 12, checked in by landauf, 17 years ago

added boost

  • Property svn:executable set to *
File size: 2.1 KB
Line 
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
13namespace boost { namespace python { namespace api {
14
15template <class Target, class Key>
16object getattr(Target const& target, Key const& key)
17{
18    return getattr(object(target), object(key));
19}
20
21template <class Target, class Key, class Default>
22object getattr(Target const& target, Key const& key, Default const& default_)
23{
24    return getattr(object(target), object(key), object(default_));
25}
26
27
28template <class Key, class Value>
29void setattr(object const& target, Key const& key, Value const& value)
30{
31    setattr(target, object(key), object(value));
32}
33
34template <class Key>
35void delattr(object const& target, Key const& key)
36{
37    delattr(target, object(key));
38}
39
40template <class Target, class Key>
41object getitem(Target const& target, Key const& key)
42{
43    return getitem(object(target), object(key));
44}
45
46
47template <class Key, class Value>
48void setitem(object const& target, Key const& key, Value const& value)
49{
50    setitem(target, object(key), object(value));
51}
52
53template <class Key>
54void delitem(object const& target, Key const& key)
55{
56    delitem(target, object(key));
57}
58
59template <class Target, class Begin, class End>
60object getslice(Target const& target, Begin const& begin, End const& end)
61{
62    return getslice(object(target), object(begin), object(end));
63}
64
65template <class Begin, class End, class Value>
66void setslice(object const& target, Begin const& begin, End const& end, Value const& value)
67{
68    setslice(target, object(begin), object(end), object(value));
69}
70
71template <class Begin, class End>
72void delslice(object const& target, Begin const& begin, End const& end)
73{
74    delslice(target, object(begin), object(end));
75}
76
77}}} // namespace boost::python::api
78
79#endif // OBJECT_PROTOCOL_DWA2002615_HPP
Note: See TracBrowser for help on using the repository browser.