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