Back to home page

EIC code displayed by LXR

 
 

    


Warning, file /include/boost/python/object_items.hpp was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).

0001 // Copyright David Abrahams 2002.
0002 // Distributed under the Boost Software License, Version 1.0. (See
0003 // accompanying file LICENSE_1_0.txt or copy at
0004 // http://www.boost.org/LICENSE_1_0.txt)
0005 #ifndef OBJECT_ITEMS_DWA2002615_HPP
0006 # define OBJECT_ITEMS_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 
0014 namespace boost { namespace python { namespace api {
0015 
0016 struct const_item_policies
0017 {
0018     typedef object key_type;
0019     static object get(object const& target, object const& key);
0020 };
0021   
0022 struct item_policies : const_item_policies
0023 {
0024     static object const& set(object const& target, object const& key, object const& value);
0025     static void del(object const& target, object const& key);
0026 };
0027 
0028 //
0029 // implementation
0030 //
0031 template <class U>
0032 inline object_item
0033 object_operators<U>::operator[](object_cref key)
0034 {
0035     object_cref2 x = *static_cast<U*>(this);
0036     return object_item(x, key);
0037 }
0038 
0039 template <class U>
0040 inline const_object_item
0041 object_operators<U>::operator[](object_cref key) const
0042 {
0043     object_cref2 x = *static_cast<U const*>(this);
0044     return const_object_item(x, key);
0045 }
0046 
0047 template <class U>
0048 template <class T>
0049 inline const_object_item
0050 object_operators<U>::operator[](T const& key) const
0051 {
0052     return (*this)[object(key)];
0053 }
0054 
0055 template <class U>
0056 template <class T>
0057 inline object_item
0058 object_operators<U>::operator[](T const& key)
0059 {
0060     return (*this)[object(key)];
0061 }
0062 
0063 inline object const_item_policies::get(object const& target, object const& key)
0064 {
0065     return getitem(target, key);
0066 }
0067 
0068 inline object const& item_policies::set(
0069     object const& target
0070     , object const& key
0071     , object const& value)
0072 {
0073     setitem(target, key, value);
0074     return value;
0075 }
0076 
0077 inline void item_policies::del(
0078     object const& target
0079     , object const& key)
0080 {
0081     delitem(target, key);
0082 }
0083 
0084 }}} // namespace boost::python::api
0085 
0086 #endif // OBJECT_ITEMS_DWA2002615_HPP