os/ossrv/ossrv_pub/boost_apis/boost/python/object_items.hpp
changeset 0 bde4ae8d615e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/os/ossrv/ossrv_pub/boost_apis/boost/python/object_items.hpp	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,89 @@
     1.4 +// Copyright David Abrahams 2002.
     1.5 +// Distributed under the Boost Software License, Version 1.0. (See
     1.6 +// accompanying file LICENSE_1_0.txt or copy at
     1.7 +// http://www.boost.org/LICENSE_1_0.txt)
     1.8 +#ifndef OBJECT_ITEMS_DWA2002615_HPP
     1.9 +# define OBJECT_ITEMS_DWA2002615_HPP
    1.10 +
    1.11 +# include <boost/python/detail/prefix.hpp>
    1.12 +
    1.13 +# include <boost/python/proxy.hpp>
    1.14 +# include <boost/python/object_core.hpp>
    1.15 +# include <boost/python/object_protocol.hpp>
    1.16 +
    1.17 +namespace boost { namespace python { namespace api {
    1.18 +
    1.19 +struct const_item_policies
    1.20 +{
    1.21 +    typedef object key_type;
    1.22 +    static object get(object const& target, object const& key);
    1.23 +};
    1.24 +  
    1.25 +struct item_policies : const_item_policies
    1.26 +{
    1.27 +    static object const& set(object const& target, object const& key, object const& value);
    1.28 +    static void del(object const& target, object const& key);
    1.29 +};
    1.30 +
    1.31 +//
    1.32 +// implementation
    1.33 +//
    1.34 +template <class U>
    1.35 +inline object_item
    1.36 +object_operators<U>::operator[](object_cref key)
    1.37 +{
    1.38 +    object_cref2 x = *static_cast<U*>(this);
    1.39 +    return object_item(x, key);
    1.40 +}
    1.41 +
    1.42 +template <class U>
    1.43 +inline const_object_item
    1.44 +object_operators<U>::operator[](object_cref key) const
    1.45 +{
    1.46 +    object_cref2 x = *static_cast<U const*>(this);
    1.47 +    return const_object_item(x, key);
    1.48 +}
    1.49 +
    1.50 +# if !defined(BOOST_MSVC) || BOOST_MSVC > 1300
    1.51 +template <class U>
    1.52 +template <class T>
    1.53 +inline const_object_item
    1.54 +object_operators<U>::operator[](T const& key) const
    1.55 +{
    1.56 +    return (*this)[object(key)];
    1.57 +}
    1.58 +
    1.59 +template <class U>
    1.60 +template <class T>
    1.61 +inline object_item
    1.62 +object_operators<U>::operator[](T const& key)
    1.63 +{
    1.64 +    return (*this)[object(key)];
    1.65 +}
    1.66 +# endif 
    1.67 +
    1.68 +
    1.69 +inline object const_item_policies::get(object const& target, object const& key)
    1.70 +{
    1.71 +    return getitem(target, key);
    1.72 +}
    1.73 +
    1.74 +inline object const& item_policies::set(
    1.75 +    object const& target
    1.76 +    , object const& key
    1.77 +    , object const& value)
    1.78 +{
    1.79 +    setitem(target, key, value);
    1.80 +    return value;
    1.81 +}
    1.82 +
    1.83 +inline void item_policies::del(
    1.84 +    object const& target
    1.85 +    , object const& key)
    1.86 +{
    1.87 +    delitem(target, key);
    1.88 +}
    1.89 +
    1.90 +}}} // namespace boost::python::api
    1.91 +
    1.92 +#endif // OBJECT_ITEMS_DWA2002615_HPP