123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152 |
- #ifndef DICT_20020706_HPP
- #define DICT_20020706_HPP
- # include <boost/python/detail/prefix.hpp>
- #include <boost/python/object.hpp>
- #include <boost/python/list.hpp>
- #include <boost/python/tuple.hpp>
- #include <boost/python/converter/pytype_object_mgr_traits.hpp>
- namespace boost { namespace python {
- class dict;
- namespace detail
- {
- struct BOOST_PYTHON_DECL dict_base : object
- {
-
- void clear();
-
- dict copy();
-
- object get(object_cref k) const;
-
- object get(object_cref k, object_cref d) const;
-
- bool has_key(object_cref k) const;
-
- list items() const;
-
-
- object iteritems() const;
-
- object iterkeys() const;
-
- object itervalues() const;
-
-
- list keys() const;
-
-
-
- tuple popitem();
-
- object setdefault(object_cref k);
- object setdefault(object_cref k, object_cref d);
-
- void update(object_cref E);
-
- list values() const;
- protected:
-
-
-
-
- dict_base();
- explicit dict_base(object_cref data);
- BOOST_PYTHON_FORWARD_OBJECT_CONSTRUCTORS(dict_base, object)
- private:
- static detail::new_reference call(object const&);
- };
- }
- class dict : public detail::dict_base
- {
- typedef detail::dict_base base;
- public:
-
-
-
-
- dict() {}
- template <class T>
- explicit dict(T const& data)
- : base(object(data))
- {
- }
- template<class T>
- object get(T const& k) const
- {
- return base::get(object(k));
- }
-
- template<class T1, class T2>
- object get(T1 const& k, T2 const& d) const
- {
- return base::get(object(k),object(d));
- }
-
- template<class T>
- bool has_key(T const& k) const
- {
- return base::has_key(object(k));
- }
-
- template<class T>
- object setdefault(T const& k)
- {
- return base::setdefault(object(k));
- }
-
- template<class T1, class T2>
- object setdefault(T1 const& k, T2 const& d)
- {
- return base::setdefault(object(k),object(d));
- }
- template<class T>
- void update(T const& E)
- {
- base::update(object(E));
- }
- public:
- BOOST_PYTHON_FORWARD_OBJECT_CONSTRUCTORS(dict, base)
- };
- namespace converter
- {
- template <>
- struct object_manager_traits<dict>
- : pytype_object_manager_traits<&PyDict_Type,dict>
- {
- };
- }
- }}
- #endif
|