Commit | Line | Data |
---|---|---|
86530b38 AT |
1 | <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> |
2 | <html> | |
3 | <head> | |
4 | <link rel="STYLESHEET" href="api.css" type='text/css' /> | |
5 | <link rel="SHORTCUT ICON" href="../icons/pyfav.png" type="image/png" /> | |
6 | <link rel='start' href='../index.html' title='Python Documentation Index' /> | |
7 | <link rel="first" href="api.html" title='Python/C API Reference Manual' /> | |
8 | <link rel='contents' href='contents.html' title="Contents" /> | |
9 | <link rel='index' href='genindex.html' title='Index' /> | |
10 | <link rel='last' href='about.html' title='About this document...' /> | |
11 | <link rel='help' href='about.html' title='About this document...' /> | |
12 | <link rel="prev" href="iterator.html" /> | |
13 | <link rel="parent" href="abstract.html" /> | |
14 | <link rel="next" href="concrete.html" /> | |
15 | <meta name='aesop' content='information' /> | |
16 | <title>6.6 Buffer Protocol </title> | |
17 | </head> | |
18 | <body> | |
19 | <DIV CLASS="navigation"> | |
20 | <div id='top-navigation-panel' xml:id='top-navigation-panel'> | |
21 | <table align="center" width="100%" cellpadding="0" cellspacing="2"> | |
22 | <tr> | |
23 | <td class='online-navigation'><a rel="prev" title="6.5 Iterator Protocol" | |
24 | href="iterator.html"><img src='../icons/previous.png' | |
25 | border='0' height='32' alt='Previous Page' width='32' /></A></td> | |
26 | <td class='online-navigation'><a rel="parent" title="6. Abstract Objects Layer" | |
27 | href="abstract.html"><img src='../icons/up.png' | |
28 | border='0' height='32' alt='Up One Level' width='32' /></A></td> | |
29 | <td class='online-navigation'><a rel="next" title="7. Concrete Objects Layer" | |
30 | href="concrete.html"><img src='../icons/next.png' | |
31 | border='0' height='32' alt='Next Page' width='32' /></A></td> | |
32 | <td align="center" width="100%">Python/C API Reference Manual</td> | |
33 | <td class='online-navigation'><a rel="contents" title="Table of Contents" | |
34 | href="contents.html"><img src='../icons/contents.png' | |
35 | border='0' height='32' alt='Contents' width='32' /></A></td> | |
36 | <td class='online-navigation'><img src='../icons/blank.png' | |
37 | border='0' height='32' alt='' width='32' /></td> | |
38 | <td class='online-navigation'><a rel="index" title="Index" | |
39 | href="genindex.html"><img src='../icons/index.png' | |
40 | border='0' height='32' alt='Index' width='32' /></A></td> | |
41 | </tr></table> | |
42 | <div class='online-navigation'> | |
43 | <b class="navlabel">Previous:</b> | |
44 | <a class="sectref" rel="prev" href="iterator.html">6.5 Iterator Protocol</A> | |
45 | <b class="navlabel">Up:</b> | |
46 | <a class="sectref" rel="parent" href="abstract.html">6. Abstract Objects Layer</A> | |
47 | <b class="navlabel">Next:</b> | |
48 | <a class="sectref" rel="next" href="concrete.html">7. Concrete Objects Layer</A> | |
49 | </div> | |
50 | <hr /></div> | |
51 | </DIV> | |
52 | <!--End of Navigation Panel--> | |
53 | ||
54 | <H1><A NAME="SECTION008600000000000000000"></A><A NAME="abstract-buffer"></A> | |
55 | <BR> | |
56 | 6.6 Buffer Protocol | |
57 | </H1> | |
58 | ||
59 | <P> | |
60 | <dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline"><td><nobr>int <b><tt id='l2h-348' xml:id='l2h-348' class="cfunction">PyObject_AsCharBuffer</tt></b>(</nobr></td><td>PyObject *<var>obj</var>, | |
61 | const char **<var>buffer</var>, | |
62 | int *<var>buffer_len</var>)</td></tr></table></dt> | |
63 | <dd> | |
64 | Returns a pointer to a read-only memory location useable as character- | |
65 | based input. The <var>obj</var> argument must support the single-segment | |
66 | character buffer interface. On success, returns <code>0</code>, sets | |
67 | <var>buffer</var> to the memory location and <var>buffer_len</var> to the buffer | |
68 | length. Returns <code>-1</code> and sets a <tt class="exception">TypeError</tt> on error. | |
69 | ||
70 | <span class="versionnote">New in version 1.6.</span> | |
71 | ||
72 | </dd></dl> | |
73 | ||
74 | <P> | |
75 | <dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline"><td><nobr>int <b><tt id='l2h-349' xml:id='l2h-349' class="cfunction">PyObject_AsReadBuffer</tt></b>(</nobr></td><td>PyObject *<var>obj</var>, | |
76 | const void **<var>buffer</var>, | |
77 | int *<var>buffer_len</var>)</td></tr></table></dt> | |
78 | <dd> | |
79 | Returns a pointer to a read-only memory location containing | |
80 | arbitrary data. The <var>obj</var> argument must support the | |
81 | single-segment readable buffer interface. On success, returns | |
82 | <code>0</code>, sets <var>buffer</var> to the memory location and <var>buffer_len</var> | |
83 | to the buffer length. Returns <code>-1</code> and sets a | |
84 | <tt class="exception">TypeError</tt> on error. | |
85 | ||
86 | <span class="versionnote">New in version 1.6.</span> | |
87 | ||
88 | </dd></dl> | |
89 | ||
90 | <P> | |
91 | <dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline"><td><nobr>int <b><tt id='l2h-350' xml:id='l2h-350' class="cfunction">PyObject_CheckReadBuffer</tt></b>(</nobr></td><td>PyObject *<var>o</var>)</td></tr></table></dt> | |
92 | <dd> | |
93 | Returns <code>1</code> if <var>o</var> supports the single-segment readable | |
94 | buffer interface. Otherwise returns <code>0</code>. | |
95 | ||
96 | <span class="versionnote">New in version 2.2.</span> | |
97 | ||
98 | </dd></dl> | |
99 | ||
100 | <P> | |
101 | <dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline"><td><nobr>int <b><tt id='l2h-351' xml:id='l2h-351' class="cfunction">PyObject_AsWriteBuffer</tt></b>(</nobr></td><td>PyObject *<var>obj</var>, | |
102 | void **<var>buffer</var>, | |
103 | int *<var>buffer_len</var>)</td></tr></table></dt> | |
104 | <dd> | |
105 | Returns a pointer to a writeable memory location. The <var>obj</var> | |
106 | argument must support the single-segment, character buffer | |
107 | interface. On success, returns <code>0</code>, sets <var>buffer</var> to the | |
108 | memory location and <var>buffer_len</var> to the buffer length. Returns | |
109 | <code>-1</code> and sets a <tt class="exception">TypeError</tt> on error. | |
110 | ||
111 | <span class="versionnote">New in version 1.6.</span> | |
112 | ||
113 | </dd></dl> | |
114 | ||
115 | <DIV CLASS="navigation"> | |
116 | <div class='online-navigation'> | |
117 | <p></p><hr /> | |
118 | <table align="center" width="100%" cellpadding="0" cellspacing="2"> | |
119 | <tr> | |
120 | <td class='online-navigation'><a rel="prev" title="6.5 Iterator Protocol" | |
121 | href="iterator.html"><img src='../icons/previous.png' | |
122 | border='0' height='32' alt='Previous Page' width='32' /></A></td> | |
123 | <td class='online-navigation'><a rel="parent" title="6. Abstract Objects Layer" | |
124 | href="abstract.html"><img src='../icons/up.png' | |
125 | border='0' height='32' alt='Up One Level' width='32' /></A></td> | |
126 | <td class='online-navigation'><a rel="next" title="7. Concrete Objects Layer" | |
127 | href="concrete.html"><img src='../icons/next.png' | |
128 | border='0' height='32' alt='Next Page' width='32' /></A></td> | |
129 | <td align="center" width="100%">Python/C API Reference Manual</td> | |
130 | <td class='online-navigation'><a rel="contents" title="Table of Contents" | |
131 | href="contents.html"><img src='../icons/contents.png' | |
132 | border='0' height='32' alt='Contents' width='32' /></A></td> | |
133 | <td class='online-navigation'><img src='../icons/blank.png' | |
134 | border='0' height='32' alt='' width='32' /></td> | |
135 | <td class='online-navigation'><a rel="index" title="Index" | |
136 | href="genindex.html"><img src='../icons/index.png' | |
137 | border='0' height='32' alt='Index' width='32' /></A></td> | |
138 | </tr></table> | |
139 | <div class='online-navigation'> | |
140 | <b class="navlabel">Previous:</b> | |
141 | <a class="sectref" rel="prev" href="iterator.html">6.5 Iterator Protocol</A> | |
142 | <b class="navlabel">Up:</b> | |
143 | <a class="sectref" rel="parent" href="abstract.html">6. Abstract Objects Layer</A> | |
144 | <b class="navlabel">Next:</b> | |
145 | <a class="sectref" rel="next" href="concrete.html">7. Concrete Objects Layer</A> | |
146 | </div> | |
147 | </div> | |
148 | <hr /> | |
149 | <span class="release-info">Release 2.4.2, documentation updated on 28 September 2005.</span> | |
150 | </DIV> | |
151 | <!--End of Navigation Panel--> | |
152 | <ADDRESS> | |
153 | See <i><a href="about.html">About this document...</a></i> for information on suggesting changes. | |
154 | </ADDRESS> | |
155 | </BODY> | |
156 | </HTML> |