object_protocol_core.hpp 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  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_CORE_DWA2002615_HPP
  6. # define OBJECT_PROTOCOL_CORE_DWA2002615_HPP
  7. # include <boost/python/detail/prefix.hpp>
  8. # include <boost/python/handle_fwd.hpp>
  9. namespace boost { namespace python {
  10. namespace api
  11. {
  12. class object;
  13. BOOST_PYTHON_DECL object getattr(object const& target, object const& key);
  14. BOOST_PYTHON_DECL object getattr(object const& target, object const& key, object const& default_);
  15. BOOST_PYTHON_DECL void setattr(object const& target, object const& key, object const& value);
  16. BOOST_PYTHON_DECL void delattr(object const& target, object const& key);
  17. // These are defined for efficiency, since attributes are commonly
  18. // accessed through literal strings.
  19. BOOST_PYTHON_DECL object getattr(object const& target, char const* key);
  20. BOOST_PYTHON_DECL object getattr(object const& target, char const* key, object const& default_);
  21. BOOST_PYTHON_DECL void setattr(object const& target, char const* key, object const& value);
  22. BOOST_PYTHON_DECL void delattr(object const& target, char const* key);
  23. BOOST_PYTHON_DECL object getitem(object const& target, object const& key);
  24. BOOST_PYTHON_DECL void setitem(object const& target, object const& key, object const& value);
  25. BOOST_PYTHON_DECL void delitem(object const& target, object const& key);
  26. BOOST_PYTHON_DECL object getslice(object const& target, handle<> const& begin, handle<> const& end);
  27. BOOST_PYTHON_DECL void setslice(object const& target, handle<> const& begin, handle<> const& end, object const& value);
  28. BOOST_PYTHON_DECL void delslice(object const& target, handle<> const& begin, handle<> const& end);
  29. }
  30. using api::getattr;
  31. using api::setattr;
  32. using api::delattr;
  33. using api::getitem;
  34. using api::setitem;
  35. using api::delitem;
  36. using api::getslice;
  37. using api::setslice;
  38. using api::delslice;
  39. }} // namespace boost::python
  40. #endif // OBJECT_PROTOCOL_CORE_DWA2002615_HPP