Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: downloads/boost_1_34_1/libs/python/doc/v2/dict.html @ 45

Last change on this file since 45 was 29, checked in by landauf, 17 years ago

updated boost from 1_33_1 to 1_34_1

File size: 4.2 KB
Line 
1<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
2
3<!-- Copyright David Abrahams 2006. Distributed under the Boost -->
4<!-- Software License, Version 1.0. (See accompanying -->
5<!-- file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) -->
6<html>
7  <head>
8    <meta name="generator" content=
9    "HTML Tidy for Windows (vers 1st August 2002), see www.w3.org">
10    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
11    <link rel="stylesheet" type="text/css" href="../boost.css">
12
13    <title>Boost.Python - &lt;boost/python/dict.hpp&gt;</title>
14  </head>
15
16  <body>
17    <table border="0" cellpadding="7" cellspacing="0" width="100%" summary=
18    "header">
19      <tr>
20        <td valign="top" width="300">
21          <h3><a href="../../../../index.htm"><img height="86" width="277"
22          alt="C++ Boost" src="../../../../boost.png" border="0"></a></h3>
23        </td>
24
25        <td valign="top">
26          <h1 align="center"><a href="../index.html">Boost.Python</a></h1>
27
28          <h2 align="center">Header &lt;boost/python/dict.hpp&gt;</h2>
29        </td>
30      </tr>
31    </table>
32    <hr>
33
34    <h2>Contents</h2>
35
36    <dl class="page-index">
37      <dt><a href="#introduction">Introduction</a></dt>
38
39      <dt><a href="#classes">Classes</a></dt>
40
41      <dd>
42        <dl class="page-index">
43          <dt><a href="#dict-spec">Class <code>dict</code></a></dt>
44
45          <dd>
46            <dl class="page-index">
47              <dt><a href="#dict-spec-synopsis">Class <code>dict</code>
48              synopsis</a></dt>
49            </dl>
50          </dd>
51        </dl>
52      </dd>
53
54      <dt><a href="#examples">Example(s)</a></dt>
55    </dl>
56    <hr>
57
58    <h2><a name="introduction"></a>Introduction</h2>
59
60    <p>Exposes a <a href=
61    "ObjectWrapper.html#TypeWrapper-concept">TypeWrapper</a> for the Python
62    <a href=
63    "http://www.python.org/dev/doc/devel/lib/typesmapping.html">dict</a>
64    type.</p>
65
66    <h2><a name="classes"></a>Classes</h2>
67
68    <h3><a name="dict-spec"></a>Class <code>dict</code></h3>
69
70    <p>Exposes the <a href=
71    "http://www.python.org/dev/doc/devel/lib/typesmapping.html">mapping
72    protocol</a> of Python's built-in <code>dict</code> type. The semantics
73    of the constructors and member functions defined below can be fully
74    understood by reading the <a href=
75    "ObjectWrapper.html#TypeWrapper-concept">TypeWrapper</a> concept
76    definition. Since <code>dict</code> is publicly derived from <code><a
77    href="object.html#object-spec">object</a></code>, the public object
78    interface applies to <code>dict</code> instances as well.</p>
79
80    <h4><a name="dict-spec-synopsis"></a>Class <code>dict</code>
81    synopsis</h4>
82<pre>
83namespace boost { namespace python
84{
85   class dict : public object
86   {
87      dict();
88
89      template&lt; class T &gt;
90      dict(T const &amp; data);
91
92      // modifiers
93      void clear();
94      dict copy();
95
96      template &lt;class T1, class T2&gt;
97      tuple popitem();
98
99      template &lt;class T&gt;
100      object setdefault(T const &amp;k);
101
102      template &lt;class T1, class T2&gt;
103      object setdefault(T1 const &amp; k, T2 const &amp; d);
104
105      void update(object_cref E);
106 
107      template&lt; class T &gt;
108      void update(T const &amp; E);
109
110      // observers
111      list values() const;
112   
113      object get(object_cref k) const;
114
115      template&lt;class T&gt;
116      object get(T const &amp; k) const;
117
118      object get(object_cref k, object_cref d) const;
119      object get(T1 const &amp; k, T2 const &amp; d) const;
120
121      bool has_key(object_cref k) const;
122
123      template&lt; class T &gt;
124      bool has_key(T const &amp; k) const;
125
126      list items() const;
127      object iteritems() const;
128      object iterkeys() const;
129      object itervalues() const;
130      list keys() const;
131  };
132}}
133</pre>
134
135    <h2><a name="examples"></a>Example</h2>
136<pre>
137using namespace boost::python;
138dict swap_object_dict(object target, dict d)
139{
140    dict result = extract&lt;dict&gt;(target.attr("__dict__"));
141    target.attr("__dict__") = d;
142    return result;
143}
144</pre>
145
146    <p>Revised 30 September, 2002</p>
147
148    <p><i>&copy; Copyright <a href=
149    "../../../../people/dave_abrahams.htm">Dave Abrahams</a> 2002.</i></p>
150  </body>
151</html>
152
Note: See TracBrowser for help on using the repository browser.