os/ossrv/ossrv_pub/boost_apis/boost/python/object_attributes.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_attributes.hpp	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,68 @@
     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_ATTRIBUTES_DWA2002615_HPP
     1.9 +# define OBJECT_ATTRIBUTES_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_attribute_policies
    1.20 +{
    1.21 +    typedef char const* key_type;
    1.22 +    static object get(object const& target, char const* key);
    1.23 +};
    1.24 +  
    1.25 +struct attribute_policies : const_attribute_policies
    1.26 +{
    1.27 +    static object const& set(object const& target, char const* key, object const& value);
    1.28 +    static void del(object const&target, char const* key);
    1.29 +};
    1.30 +
    1.31 +//
    1.32 +// implementation
    1.33 +//
    1.34 +template <class U>
    1.35 +inline object_attribute object_operators<U>::attr(char const* name)
    1.36 +{
    1.37 +    object_cref2 x = *static_cast<U*>(this);
    1.38 +    return object_attribute(x, name);
    1.39 +}
    1.40 +
    1.41 +template <class U>
    1.42 +inline const_object_attribute object_operators<U>::attr(char const* name) const
    1.43 +{
    1.44 +    object_cref2 x = *static_cast<U const*>(this);
    1.45 +    return const_object_attribute(x, name);
    1.46 +}
    1.47 +
    1.48 +inline object const_attribute_policies::get(object const& target, char const* key)
    1.49 +{
    1.50 +    return python::getattr(target, key);
    1.51 +}
    1.52 +
    1.53 +inline object const& attribute_policies::set(
    1.54 +    object const& target
    1.55 +    , char const* key
    1.56 +    , object const& value)
    1.57 +{
    1.58 +    python::setattr(target, key, value);
    1.59 +    return value;
    1.60 +}
    1.61 +
    1.62 +inline void attribute_policies::del(
    1.63 +    object const& target
    1.64 +    , char const* key)
    1.65 +{
    1.66 +    python::delattr(target, key);
    1.67 +}
    1.68 +
    1.69 +}}} // namespace boost::python::api
    1.70 +
    1.71 +#endif // OBJECT_ATTRIBUTES_DWA2002615_HPP