Blame view

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