Warning, file /include/boost/python/dict.hpp was not indexed
or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).
0001
0002
0003
0004
0005 #ifndef DICT_20020706_HPP
0006 #define DICT_20020706_HPP
0007
0008 # include <boost/python/detail/prefix.hpp>
0009
0010 #include <boost/python/object.hpp>
0011 #include <boost/python/list.hpp>
0012 #include <boost/python/tuple.hpp>
0013 #include <boost/python/converter/pytype_object_mgr_traits.hpp>
0014
0015 namespace boost { namespace python {
0016
0017 class dict;
0018
0019 namespace detail
0020 {
0021 struct BOOST_PYTHON_DECL dict_base : object
0022 {
0023
0024 void clear();
0025
0026
0027 dict copy();
0028
0029
0030 object get(object_cref k) const;
0031
0032 object get(object_cref k, object_cref d) const;
0033
0034
0035 bool has_key(object_cref k) const;
0036
0037
0038 list items() const;
0039
0040
0041 object iteritems() const;
0042
0043
0044 object iterkeys() const;
0045
0046
0047 object itervalues() const;
0048
0049
0050 list keys() const;
0051
0052
0053
0054 tuple popitem();
0055
0056
0057 object setdefault(object_cref k);
0058
0059 object setdefault(object_cref k, object_cref d);
0060
0061
0062 void update(object_cref E);
0063
0064
0065 list values() const;
0066
0067 protected:
0068
0069
0070
0071
0072 dict_base();
0073 explicit dict_base(object_cref data);
0074
0075 BOOST_PYTHON_FORWARD_OBJECT_CONSTRUCTORS(dict_base, object)
0076 private:
0077 static detail::new_reference call(object const&);
0078 };
0079 }
0080
0081 class dict : public detail::dict_base
0082 {
0083 typedef detail::dict_base base;
0084 public:
0085
0086
0087
0088
0089 dict() {}
0090
0091 template <class T>
0092 explicit dict(T const& data)
0093 : base(object(data))
0094 {
0095 }
0096
0097 template<class T>
0098 object get(T const& k) const
0099 {
0100 return base::get(object(k));
0101 }
0102
0103 template<class T1, class T2>
0104 object get(T1 const& k, T2 const& d) const
0105 {
0106 return base::get(object(k),object(d));
0107 }
0108
0109 template<class T>
0110 bool has_key(T const& k) const
0111 {
0112 return base::has_key(object(k));
0113 }
0114
0115 template<class T>
0116 object setdefault(T const& k)
0117 {
0118 return base::setdefault(object(k));
0119 }
0120
0121 template<class T1, class T2>
0122 object setdefault(T1 const& k, T2 const& d)
0123 {
0124 return base::setdefault(object(k),object(d));
0125 }
0126
0127 template<class T>
0128 void update(T const& E)
0129 {
0130 base::update(object(E));
0131 }
0132
0133 public:
0134 BOOST_PYTHON_FORWARD_OBJECT_CONSTRUCTORS(dict, base)
0135 };
0136
0137
0138
0139
0140 namespace converter
0141 {
0142 template <>
0143 struct object_manager_traits<dict>
0144 : pytype_object_manager_traits<&PyDict_Type,dict>
0145 {
0146 };
0147 }
0148
0149 }}
0150
0151 #endif
0152