2 * Summary: Chained hash tables
3 * Description: This module implements the hash table support used in
4 * various places in the library.
6 * Copy: See Copyright for the status of this software.
8 * Author: Bjorn Reese <bjorn.reese@systematic.dk>
11 #ifndef __XML_HASH_H__
12 #define __XML_HASH_H__
21 typedef struct _xmlHashTable xmlHashTable
;
22 typedef xmlHashTable
*xmlHashTablePtr
;
28 #include <libxml/xmlversion.h>
29 #include <libxml/parser.h>
30 #include <libxml/dict.h>
37 * Recent version of gcc produce a warning when a function pointer is assigned
38 * to an object pointer, or vice versa. The following macro is a dirty hack
39 * to allow suppression of the warning. If your architecture has function
40 * pointers which are a different size than a void pointer, there may be some
41 * serious trouble within the library.
45 * @fptr: pointer to a function
47 * Macro to do a casting from an object pointer to a
48 * function pointer without encountering a warning from
51 * #define XML_CAST_FPTR(fptr) (*(void **)(&fptr))
52 * This macro violated ISO C aliasing rules (gcc4 on s390 broke)
53 * so it is disabled now
56 #define XML_CAST_FPTR(fptr) fptr
64 * @payload: the data in the hash
65 * @name: the name associated
67 * Callback to free data from a hash.
69 typedef void (*xmlHashDeallocator
)(void *payload
, const xmlChar
*name
);
72 * @payload: the data in the hash
73 * @name: the name associated
75 * Callback to copy data from a hash.
77 * Returns a copy of the data or NULL in case of error.
79 typedef void *(*xmlHashCopier
)(void *payload
, const xmlChar
*name
);
82 * @payload: the data in the hash
83 * @data: extra scannner data
84 * @name: the name associated
86 * Callback when scanning data in a hash with the simple scanner.
88 typedef void (*xmlHashScanner
)(void *payload
, void *data
, const xmlChar
*name
);
91 * @payload: the data in the hash
92 * @data: extra scannner data
93 * @name: the name associated
94 * @name2: the second name associated
95 * @name3: the third name associated
97 * Callback when scanning data in a hash with the full scanner.
99 typedef void (*xmlHashScannerFull
)(void *payload
, void *data
,
100 const xmlChar
*name
, const xmlChar
*name2
,
101 const xmlChar
*name3
);
104 * Constructor and destructor.
106 XMLPUBFUN xmlHashTablePtr XMLCALL
107 xmlHashCreate (int size
);
108 XMLPUBFUN xmlHashTablePtr XMLCALL
109 xmlHashCreateDict(int size
,
111 XMLPUBFUN
void XMLCALL
112 xmlHashFree (xmlHashTablePtr table
,
113 xmlHashDeallocator f
);
114 XMLPUBFUN
void XMLCALL
115 xmlHashDefaultDeallocator(void *entry
,
116 const xmlChar
*name
);
119 * Add a new entry to the hash table.
121 XMLPUBFUN
int XMLCALL
122 xmlHashAddEntry (xmlHashTablePtr table
,
125 XMLPUBFUN
int XMLCALL
126 xmlHashUpdateEntry(xmlHashTablePtr table
,
129 xmlHashDeallocator f
);
130 XMLPUBFUN
int XMLCALL
131 xmlHashAddEntry2(xmlHashTablePtr table
,
133 const xmlChar
*name2
,
135 XMLPUBFUN
int XMLCALL
136 xmlHashUpdateEntry2(xmlHashTablePtr table
,
138 const xmlChar
*name2
,
140 xmlHashDeallocator f
);
141 XMLPUBFUN
int XMLCALL
142 xmlHashAddEntry3(xmlHashTablePtr table
,
144 const xmlChar
*name2
,
145 const xmlChar
*name3
,
147 XMLPUBFUN
int XMLCALL
148 xmlHashUpdateEntry3(xmlHashTablePtr table
,
150 const xmlChar
*name2
,
151 const xmlChar
*name3
,
153 xmlHashDeallocator f
);
156 * Remove an entry from the hash table.
158 XMLPUBFUN
int XMLCALL
159 xmlHashRemoveEntry(xmlHashTablePtr table
, const xmlChar
*name
,
160 xmlHashDeallocator f
);
161 XMLPUBFUN
int XMLCALL
162 xmlHashRemoveEntry2(xmlHashTablePtr table
, const xmlChar
*name
,
163 const xmlChar
*name2
, xmlHashDeallocator f
);
164 XMLPUBFUN
int XMLCALL
165 xmlHashRemoveEntry3(xmlHashTablePtr table
, const xmlChar
*name
,
166 const xmlChar
*name2
, const xmlChar
*name3
,
167 xmlHashDeallocator f
);
170 * Retrieve the userdata.
172 XMLPUBFUN
void * XMLCALL
173 xmlHashLookup (xmlHashTablePtr table
,
174 const xmlChar
*name
);
175 XMLPUBFUN
void * XMLCALL
176 xmlHashLookup2 (xmlHashTablePtr table
,
178 const xmlChar
*name2
);
179 XMLPUBFUN
void * XMLCALL
180 xmlHashLookup3 (xmlHashTablePtr table
,
182 const xmlChar
*name2
,
183 const xmlChar
*name3
);
184 XMLPUBFUN
void * XMLCALL
185 xmlHashQLookup (xmlHashTablePtr table
,
187 const xmlChar
*prefix
);
188 XMLPUBFUN
void * XMLCALL
189 xmlHashQLookup2 (xmlHashTablePtr table
,
191 const xmlChar
*prefix
,
192 const xmlChar
*name2
,
193 const xmlChar
*prefix2
);
194 XMLPUBFUN
void * XMLCALL
195 xmlHashQLookup3 (xmlHashTablePtr table
,
197 const xmlChar
*prefix
,
198 const xmlChar
*name2
,
199 const xmlChar
*prefix2
,
200 const xmlChar
*name3
,
201 const xmlChar
*prefix3
);
206 XMLPUBFUN xmlHashTablePtr XMLCALL
207 xmlHashCopy (xmlHashTablePtr table
,
209 XMLPUBFUN
int XMLCALL
210 xmlHashSize (xmlHashTablePtr table
);
211 XMLPUBFUN
void XMLCALL
212 xmlHashScan (xmlHashTablePtr table
,
215 XMLPUBFUN
void XMLCALL
216 xmlHashScan3 (xmlHashTablePtr table
,
218 const xmlChar
*name2
,
219 const xmlChar
*name3
,
222 XMLPUBFUN
void XMLCALL
223 xmlHashScanFull (xmlHashTablePtr table
,
224 xmlHashScannerFull f
,
226 XMLPUBFUN
void XMLCALL
227 xmlHashScanFull3(xmlHashTablePtr table
,
229 const xmlChar
*name2
,
230 const xmlChar
*name3
,
231 xmlHashScannerFull f
,
236 #endif /* ! __XML_HASH_H__ */