summaryrefslogtreecommitdiff
path: root/doc/devhelp/libxml2-dict.html
blob: 08e914d110f8a65e6d37721f4929cee63ef58827 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>dict: string dictionary</title>
<meta name="generator" content="Libxml2 devhelp stylesheet">
<link rel="start" href="index.html" title="libxml2 Reference Manual">
<link rel="up" href="general.html" title="API">
<link rel="stylesheet" href="style.css" type="text/css">
<link rel="chapter" href="general.html" title="API">
</head>
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
<table class="navigation" width="100%" summary="Navigation header" cellpadding="2" cellspacing="2"><tr valign="middle">
<td><a accesskey="p" href="libxml2-debugXML.html"><img src="left.png" width="24" height="24" border="0" alt="Prev"></a></td>
<td><a accesskey="u" href="general.html"><img src="up.png" width="24" height="24" border="0" alt="Up"></a></td>
<td><a accesskey="h" href="index.html"><img src="home.png" width="24" height="24" border="0" alt="Home"></a></td>
<td><a accesskey="n" href="libxml2-encoding.html"><img src="right.png" width="24" height="24" border="0" alt="Next"></a></td>
<th width="100%" align="center">libxml2 Reference Manual</th>
</tr></table>
<h2><span class="refentrytitle">dict</span></h2>
<p>dict - string dictionary</p>
<p>dictionary of reusable strings, just used to avoid allocation and freeing operations. </p>
<p>Author(s): Daniel Veillard </p>
<div class="refsynopsisdiv">
<h2>Synopsis</h2>
<pre class="synopsis">typedef struct _xmlDict <a href="#xmlDict">xmlDict</a>;
typedef <a href="libxml2-dict.html#xmlDict">xmlDict</a> * <a href="#xmlDictPtr">xmlDictPtr</a>;
void	<a href="#xmlDictCleanup">xmlDictCleanup</a>			(void);
<a href="libxml2-dict.html#xmlDictPtr">xmlDictPtr</a>	<a href="#xmlDictCreate">xmlDictCreate</a>		(void);
<a href="libxml2-dict.html#xmlDictPtr">xmlDictPtr</a>	<a href="#xmlDictCreateSub">xmlDictCreateSub</a>	(<a href="libxml2-dict.html#xmlDictPtr">xmlDictPtr</a> sub);
const <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> *	<a href="#xmlDictExists">xmlDictExists</a>		(<a href="libxml2-dict.html#xmlDictPtr">xmlDictPtr</a> dict, <br>					 const <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> * name, <br>					 int len);
void	<a href="#xmlDictFree">xmlDictFree</a>			(<a href="libxml2-dict.html#xmlDictPtr">xmlDictPtr</a> dict);
size_t	<a href="#xmlDictGetUsage">xmlDictGetUsage</a>			(<a href="libxml2-dict.html#xmlDictPtr">xmlDictPtr</a> dict);
const <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> *	<a href="#xmlDictLookup">xmlDictLookup</a>		(<a href="libxml2-dict.html#xmlDictPtr">xmlDictPtr</a> dict, <br>					 const <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> * name, <br>					 int len);
int	<a href="#xmlDictOwns">xmlDictOwns</a>			(<a href="libxml2-dict.html#xmlDictPtr">xmlDictPtr</a> dict, <br>					 const <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> * str);
const <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> *	<a href="#xmlDictQLookup">xmlDictQLookup</a>		(<a href="libxml2-dict.html#xmlDictPtr">xmlDictPtr</a> dict, <br>					 const <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> * prefix, <br>					 const <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> * name);
int	<a href="#xmlDictReference">xmlDictReference</a>		(<a href="libxml2-dict.html#xmlDictPtr">xmlDictPtr</a> dict);
size_t	<a href="#xmlDictSetLimit">xmlDictSetLimit</a>			(<a href="libxml2-dict.html#xmlDictPtr">xmlDictPtr</a> dict, <br>					 size_t limit);
int	<a href="#xmlDictSize">xmlDictSize</a>			(<a href="libxml2-dict.html#xmlDictPtr">xmlDictPtr</a> dict);
int	<a href="#xmlInitializeDict">xmlInitializeDict</a>		(void);
</pre>
</div>
<div class="refsect1" lang="en"><h2>Description</h2></div>
<div class="refsect1" lang="en">
<h2>Details</h2>
<div class="refsect2" lang="en">
<div class="refsect2" lang="en">
<h3>
<a name="xmlDict">Structure </a>xmlDict</h3>
<pre class="programlisting">struct _xmlDict {
The content of this structure is not made public by the API.
} xmlDict;
</pre>
<p></p>
</div>
<hr>
<div class="refsect2" lang="en">
<h3>
<a name="xmlDictPtr">Typedef </a>xmlDictPtr</h3>
<pre class="programlisting"><a href="libxml2-dict.html#xmlDict">xmlDict</a> * xmlDictPtr;
</pre>
<p></p>
</div>
<hr>
<div class="refsect2" lang="en">
<h3>
<a name="xmlDictCleanup"></a>xmlDictCleanup ()</h3>
<pre class="programlisting">void	xmlDictCleanup			(void)<br>
</pre>
<p>DEPRECATED: This function is a no-op. Call <a href="libxml2-parser.html#xmlCleanupParser">xmlCleanupParser</a> to free global state but see the warnings there. <a href="libxml2-parser.html#xmlCleanupParser">xmlCleanupParser</a> should be only called once at program exit. In most cases, you don't have call cleanup functions at all.</p>
</div>
<hr>
<div class="refsect2" lang="en">
<h3>
<a name="xmlDictCreate"></a>xmlDictCreate ()</h3>
<pre class="programlisting"><a href="libxml2-dict.html#xmlDictPtr">xmlDictPtr</a>	xmlDictCreate		(void)<br>
</pre>
<p>Create a new dictionary</p>
<div class="variablelist"><table border="0">
<col align="left">
<tbody><tr>
<td><span class="term"><i><tt>Returns</tt></i>:</span></td>
<td>the newly created dictionary, or NULL if an error occurred.</td>
</tr></tbody>
</table></div>
</div>
<hr>
<div class="refsect2" lang="en">
<h3>
<a name="xmlDictCreateSub"></a>xmlDictCreateSub ()</h3>
<pre class="programlisting"><a href="libxml2-dict.html#xmlDictPtr">xmlDictPtr</a>	xmlDictCreateSub	(<a href="libxml2-dict.html#xmlDictPtr">xmlDictPtr</a> sub)<br>
</pre>
<p>Create a new dictionary, inheriting strings from the read-only dictionary @sub. On lookup, strings are first searched in the new dictionary, then in @sub, and if not found are created in the new dictionary.</p>
<div class="variablelist"><table border="0">
<col align="left">
<tbody>
<tr>
<td><span class="term"><i><tt>sub</tt></i>:</span></td>
<td>an existing dictionary</td>
</tr>
<tr>
<td><span class="term"><i><tt>Returns</tt></i>:</span></td>
<td>the newly created dictionary, or NULL if an error occurred.</td>
</tr>
</tbody>
</table></div>
</div>
<hr>
<div class="refsect2" lang="en">
<h3>
<a name="xmlDictExists"></a>xmlDictExists ()</h3>
<pre class="programlisting">const <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> *	xmlDictExists		(<a href="libxml2-dict.html#xmlDictPtr">xmlDictPtr</a> dict, <br>					 const <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> * name, <br>					 int len)<br>
</pre>
<p>Check if the @name exists in the dictionary @dict.</p>
<div class="variablelist"><table border="0">
<col align="left">
<tbody>
<tr>
<td><span class="term"><i><tt>dict</tt></i>:</span></td>
<td>the dictionary</td>
</tr>
<tr>
<td><span class="term"><i><tt>name</tt></i>:</span></td>
<td>the name of the userdata</td>
</tr>
<tr>
<td><span class="term"><i><tt>len</tt></i>:</span></td>
<td>the length of the name, if -1 it is recomputed</td>
</tr>
<tr>
<td><span class="term"><i><tt>Returns</tt></i>:</span></td>
<td>the internal copy of the name or NULL if not found.</td>
</tr>
</tbody>
</table></div>
</div>
<hr>
<div class="refsect2" lang="en">
<h3>
<a name="xmlDictFree"></a>xmlDictFree ()</h3>
<pre class="programlisting">void	xmlDictFree			(<a href="libxml2-dict.html#xmlDictPtr">xmlDictPtr</a> dict)<br>
</pre>
<p>Free the hash @dict and its contents. The userdata is deallocated with @f if provided.</p>
<div class="variablelist"><table border="0">
<col align="left">
<tbody><tr>
<td><span class="term"><i><tt>dict</tt></i>:</span></td>
<td>the dictionary</td>
</tr></tbody>
</table></div>
</div>
<hr>
<div class="refsect2" lang="en">
<h3>
<a name="xmlDictGetUsage"></a>xmlDictGetUsage ()</h3>
<pre class="programlisting">size_t	xmlDictGetUsage			(<a href="libxml2-dict.html#xmlDictPtr">xmlDictPtr</a> dict)<br>
</pre>
<p>Get how much memory is used by a dictionary for strings Added in 2.9.0</p>
<div class="variablelist"><table border="0">
<col align="left">
<tbody>
<tr>
<td><span class="term"><i><tt>dict</tt></i>:</span></td>
<td>the dictionary</td>
</tr>
<tr>
<td><span class="term"><i><tt>Returns</tt></i>:</span></td>
<td>the amount of strings allocated</td>
</tr>
</tbody>
</table></div>
</div>
<hr>
<div class="refsect2" lang="en">
<h3>
<a name="xmlDictLookup"></a>xmlDictLookup ()</h3>
<pre class="programlisting">const <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> *	xmlDictLookup		(<a href="libxml2-dict.html#xmlDictPtr">xmlDictPtr</a> dict, <br>					 const <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> * name, <br>					 int len)<br>
</pre>
<p>Add the @name to the dictionary @dict if not present.</p>
<div class="variablelist"><table border="0">
<col align="left">
<tbody>
<tr>
<td><span class="term"><i><tt>dict</tt></i>:</span></td>
<td>the dictionary</td>
</tr>
<tr>
<td><span class="term"><i><tt>name</tt></i>:</span></td>
<td>the name of the userdata</td>
</tr>
<tr>
<td><span class="term"><i><tt>len</tt></i>:</span></td>
<td>the length of the name, if -1 it is recomputed</td>
</tr>
<tr>
<td><span class="term"><i><tt>Returns</tt></i>:</span></td>
<td>the internal copy of the name or NULL in case of internal error</td>
</tr>
</tbody>
</table></div>
</div>
<hr>
<div class="refsect2" lang="en">
<h3>
<a name="xmlDictOwns"></a>xmlDictOwns ()</h3>
<pre class="programlisting">int	xmlDictOwns			(<a href="libxml2-dict.html#xmlDictPtr">xmlDictPtr</a> dict, <br>					 const <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> * str)<br>
</pre>
<p>check if a string is owned by the dictionary</p>
<div class="variablelist"><table border="0">
<col align="left">
<tbody>
<tr>
<td><span class="term"><i><tt>dict</tt></i>:</span></td>
<td>the dictionary</td>
</tr>
<tr>
<td><span class="term"><i><tt>str</tt></i>:</span></td>
<td>the string</td>
</tr>
<tr>
<td><span class="term"><i><tt>Returns</tt></i>:</span></td>
<td>1 if true, 0 if false and -1 in case of error -1 in case of error</td>
</tr>
</tbody>
</table></div>
</div>
<hr>
<div class="refsect2" lang="en">
<h3>
<a name="xmlDictQLookup"></a>xmlDictQLookup ()</h3>
<pre class="programlisting">const <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> *	xmlDictQLookup		(<a href="libxml2-dict.html#xmlDictPtr">xmlDictPtr</a> dict, <br>					 const <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> * prefix, <br>					 const <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> * name)<br>
</pre>
<p>Add the QName @prefix:@name to the hash @dict if not present.</p>
<div class="variablelist"><table border="0">
<col align="left">
<tbody>
<tr>
<td><span class="term"><i><tt>dict</tt></i>:</span></td>
<td>the dictionary</td>
</tr>
<tr>
<td><span class="term"><i><tt>prefix</tt></i>:</span></td>
<td>the prefix</td>
</tr>
<tr>
<td><span class="term"><i><tt>name</tt></i>:</span></td>
<td>the name</td>
</tr>
<tr>
<td><span class="term"><i><tt>Returns</tt></i>:</span></td>
<td>the internal copy of the QName or NULL in case of internal error</td>
</tr>
</tbody>
</table></div>
</div>
<hr>
<div class="refsect2" lang="en">
<h3>
<a name="xmlDictReference"></a>xmlDictReference ()</h3>
<pre class="programlisting">int	xmlDictReference		(<a href="libxml2-dict.html#xmlDictPtr">xmlDictPtr</a> dict)<br>
</pre>
<p>Increment the <a href="libxml2-SAX.html#reference">reference</a> counter of a dictionary</p>
<div class="variablelist"><table border="0">
<col align="left">
<tbody>
<tr>
<td><span class="term"><i><tt>dict</tt></i>:</span></td>
<td>the dictionary</td>
</tr>
<tr>
<td><span class="term"><i><tt>Returns</tt></i>:</span></td>
<td>0 in case of success and -1 in case of error</td>
</tr>
</tbody>
</table></div>
</div>
<hr>
<div class="refsect2" lang="en">
<h3>
<a name="xmlDictSetLimit"></a>xmlDictSetLimit ()</h3>
<pre class="programlisting">size_t	xmlDictSetLimit			(<a href="libxml2-dict.html#xmlDictPtr">xmlDictPtr</a> dict, <br>					 size_t limit)<br>
</pre>
<p>Set a size limit for the dictionary Added in 2.9.0</p>
<div class="variablelist"><table border="0">
<col align="left">
<tbody>
<tr>
<td><span class="term"><i><tt>dict</tt></i>:</span></td>
<td>the dictionary</td>
</tr>
<tr>
<td><span class="term"><i><tt>limit</tt></i>:</span></td>
<td>the limit in bytes</td>
</tr>
<tr>
<td><span class="term"><i><tt>Returns</tt></i>:</span></td>
<td>the previous limit of the dictionary or 0</td>
</tr>
</tbody>
</table></div>
</div>
<hr>
<div class="refsect2" lang="en">
<h3>
<a name="xmlDictSize"></a>xmlDictSize ()</h3>
<pre class="programlisting">int	xmlDictSize			(<a href="libxml2-dict.html#xmlDictPtr">xmlDictPtr</a> dict)<br>
</pre>
<p>Query the number of elements installed in the hash @dict.</p>
<div class="variablelist"><table border="0">
<col align="left">
<tbody>
<tr>
<td><span class="term"><i><tt>dict</tt></i>:</span></td>
<td>the dictionary</td>
</tr>
<tr>
<td><span class="term"><i><tt>Returns</tt></i>:</span></td>
<td>the number of elements in the dictionary or -1 in case of error</td>
</tr>
</tbody>
</table></div>
</div>
<hr>
<div class="refsect2" lang="en">
<h3>
<a name="xmlInitializeDict"></a>xmlInitializeDict ()</h3>
<pre class="programlisting">int	xmlInitializeDict		(void)<br>
</pre>
<p>DEPRECATED: Alias for <a href="libxml2-parser.html#xmlInitParser">xmlInitParser</a>.</p>
<div class="variablelist"><table border="0">
<col align="left">
<tbody><tr>
<td><span class="term"><i><tt>Returns</tt></i>:</span></td>
<td></td>
</tr></tbody>
</table></div>
</div>
<hr>
</div>
</div>
</body>
</html>