blob: dc8ab7ec52c172d48ff7d0088d028a88d4fd012e [file] [log] [blame]
The Android Open Source Projectab4e2e92009-03-03 19:30:06 -08001/*
2 * Summary: Chained hash tables
Selim Gurun94442ad2013-12-30 18:23:42 -08003 * Description: This module implements the hash table support used in
4 * various places in the library.
The Android Open Source Projectab4e2e92009-03-03 19:30:06 -08005 *
6 * Copy: See Copyright for the status of this software.
7 *
8 * Author: Bjorn Reese <bjorn.reese@systematic.dk>
9 */
10
11#ifndef __XML_HASH_H__
12#define __XML_HASH_H__
13
14#ifdef __cplusplus
15extern "C" {
16#endif
17
18/*
19 * The hash table.
20 */
21typedef struct _xmlHashTable xmlHashTable;
22typedef xmlHashTable *xmlHashTablePtr;
23
24#ifdef __cplusplus
25}
26#endif
27
28#include <libxml/xmlversion.h>
29#include <libxml/parser.h>
30#include <libxml/dict.h>
31
32#ifdef __cplusplus
33extern "C" {
34#endif
35
36/*
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.
42 */
43/**
44 * XML_CAST_FPTR:
45 * @fptr: pointer to a function
46 *
47 * Macro to do a casting from an object pointer to a
48 * function pointer without encountering a warning from
49 * gcc
50 *
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
54 */
55
56#define XML_CAST_FPTR(fptr) fptr
57
58
59/*
60 * function types:
61 */
62/**
63 * xmlHashDeallocator:
64 * @payload: the data in the hash
65 * @name: the name associated
66 *
67 * Callback to free data from a hash.
68 */
69typedef void (*xmlHashDeallocator)(void *payload, xmlChar *name);
70/**
71 * xmlHashCopier:
72 * @payload: the data in the hash
73 * @name: the name associated
74 *
75 * Callback to copy data from a hash.
76 *
77 * Returns a copy of the data or NULL in case of error.
78 */
79typedef void *(*xmlHashCopier)(void *payload, xmlChar *name);
80/**
81 * xmlHashScanner:
82 * @payload: the data in the hash
83 * @data: extra scannner data
84 * @name: the name associated
85 *
86 * Callback when scanning data in a hash with the simple scanner.
87 */
88typedef void (*xmlHashScanner)(void *payload, void *data, xmlChar *name);
89/**
90 * xmlHashScannerFull:
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
96 *
97 * Callback when scanning data in a hash with the full scanner.
98 */
99typedef void (*xmlHashScannerFull)(void *payload, void *data,
100 const xmlChar *name, const xmlChar *name2,
101 const xmlChar *name3);
102
103/*
104 * Constructor and destructor.
105 */
106XMLPUBFUN xmlHashTablePtr XMLCALL
107 xmlHashCreate (int size);
108XMLPUBFUN xmlHashTablePtr XMLCALL
109 xmlHashCreateDict(int size,
110 xmlDictPtr dict);
Selim Gurun94442ad2013-12-30 18:23:42 -0800111XMLPUBFUN void XMLCALL
The Android Open Source Projectab4e2e92009-03-03 19:30:06 -0800112 xmlHashFree (xmlHashTablePtr table,
113 xmlHashDeallocator f);
114
115/*
116 * Add a new entry to the hash table.
117 */
Selim Gurun94442ad2013-12-30 18:23:42 -0800118XMLPUBFUN int XMLCALL
The Android Open Source Projectab4e2e92009-03-03 19:30:06 -0800119 xmlHashAddEntry (xmlHashTablePtr table,
120 const xmlChar *name,
121 void *userdata);
Selim Gurun94442ad2013-12-30 18:23:42 -0800122XMLPUBFUN int XMLCALL
The Android Open Source Projectab4e2e92009-03-03 19:30:06 -0800123 xmlHashUpdateEntry(xmlHashTablePtr table,
124 const xmlChar *name,
125 void *userdata,
126 xmlHashDeallocator f);
Selim Gurun94442ad2013-12-30 18:23:42 -0800127XMLPUBFUN int XMLCALL
The Android Open Source Projectab4e2e92009-03-03 19:30:06 -0800128 xmlHashAddEntry2(xmlHashTablePtr table,
129 const xmlChar *name,
130 const xmlChar *name2,
131 void *userdata);
Selim Gurun94442ad2013-12-30 18:23:42 -0800132XMLPUBFUN int XMLCALL
The Android Open Source Projectab4e2e92009-03-03 19:30:06 -0800133 xmlHashUpdateEntry2(xmlHashTablePtr table,
134 const xmlChar *name,
135 const xmlChar *name2,
136 void *userdata,
137 xmlHashDeallocator f);
Selim Gurun94442ad2013-12-30 18:23:42 -0800138XMLPUBFUN int XMLCALL
The Android Open Source Projectab4e2e92009-03-03 19:30:06 -0800139 xmlHashAddEntry3(xmlHashTablePtr table,
140 const xmlChar *name,
141 const xmlChar *name2,
142 const xmlChar *name3,
143 void *userdata);
Selim Gurun94442ad2013-12-30 18:23:42 -0800144XMLPUBFUN int XMLCALL
The Android Open Source Projectab4e2e92009-03-03 19:30:06 -0800145 xmlHashUpdateEntry3(xmlHashTablePtr table,
146 const xmlChar *name,
147 const xmlChar *name2,
148 const xmlChar *name3,
149 void *userdata,
150 xmlHashDeallocator f);
151
152/*
153 * Remove an entry from the hash table.
154 */
Selim Gurun94442ad2013-12-30 18:23:42 -0800155XMLPUBFUN int XMLCALL
The Android Open Source Projectab4e2e92009-03-03 19:30:06 -0800156 xmlHashRemoveEntry(xmlHashTablePtr table, const xmlChar *name,
157 xmlHashDeallocator f);
Selim Gurun94442ad2013-12-30 18:23:42 -0800158XMLPUBFUN int XMLCALL
The Android Open Source Projectab4e2e92009-03-03 19:30:06 -0800159 xmlHashRemoveEntry2(xmlHashTablePtr table, const xmlChar *name,
160 const xmlChar *name2, xmlHashDeallocator f);
Selim Gurun94442ad2013-12-30 18:23:42 -0800161XMLPUBFUN int XMLCALL
The Android Open Source Projectab4e2e92009-03-03 19:30:06 -0800162 xmlHashRemoveEntry3(xmlHashTablePtr table, const xmlChar *name,
163 const xmlChar *name2, const xmlChar *name3,
164 xmlHashDeallocator f);
165
166/*
167 * Retrieve the userdata.
168 */
Selim Gurun94442ad2013-12-30 18:23:42 -0800169XMLPUBFUN void * XMLCALL
The Android Open Source Projectab4e2e92009-03-03 19:30:06 -0800170 xmlHashLookup (xmlHashTablePtr table,
171 const xmlChar *name);
Selim Gurun94442ad2013-12-30 18:23:42 -0800172XMLPUBFUN void * XMLCALL
The Android Open Source Projectab4e2e92009-03-03 19:30:06 -0800173 xmlHashLookup2 (xmlHashTablePtr table,
174 const xmlChar *name,
175 const xmlChar *name2);
Selim Gurun94442ad2013-12-30 18:23:42 -0800176XMLPUBFUN void * XMLCALL
The Android Open Source Projectab4e2e92009-03-03 19:30:06 -0800177 xmlHashLookup3 (xmlHashTablePtr table,
178 const xmlChar *name,
179 const xmlChar *name2,
180 const xmlChar *name3);
Selim Gurun94442ad2013-12-30 18:23:42 -0800181XMLPUBFUN void * XMLCALL
The Android Open Source Projectab4e2e92009-03-03 19:30:06 -0800182 xmlHashQLookup (xmlHashTablePtr table,
183 const xmlChar *name,
184 const xmlChar *prefix);
Selim Gurun94442ad2013-12-30 18:23:42 -0800185XMLPUBFUN void * XMLCALL
The Android Open Source Projectab4e2e92009-03-03 19:30:06 -0800186 xmlHashQLookup2 (xmlHashTablePtr table,
187 const xmlChar *name,
188 const xmlChar *prefix,
189 const xmlChar *name2,
190 const xmlChar *prefix2);
Selim Gurun94442ad2013-12-30 18:23:42 -0800191XMLPUBFUN void * XMLCALL
The Android Open Source Projectab4e2e92009-03-03 19:30:06 -0800192 xmlHashQLookup3 (xmlHashTablePtr table,
193 const xmlChar *name,
194 const xmlChar *prefix,
195 const xmlChar *name2,
196 const xmlChar *prefix2,
197 const xmlChar *name3,
198 const xmlChar *prefix3);
199
200/*
201 * Helpers.
202 */
Selim Gurun94442ad2013-12-30 18:23:42 -0800203XMLPUBFUN xmlHashTablePtr XMLCALL
The Android Open Source Projectab4e2e92009-03-03 19:30:06 -0800204 xmlHashCopy (xmlHashTablePtr table,
205 xmlHashCopier f);
Selim Gurun94442ad2013-12-30 18:23:42 -0800206XMLPUBFUN int XMLCALL
The Android Open Source Projectab4e2e92009-03-03 19:30:06 -0800207 xmlHashSize (xmlHashTablePtr table);
Selim Gurun94442ad2013-12-30 18:23:42 -0800208XMLPUBFUN void XMLCALL
The Android Open Source Projectab4e2e92009-03-03 19:30:06 -0800209 xmlHashScan (xmlHashTablePtr table,
210 xmlHashScanner f,
211 void *data);
Selim Gurun94442ad2013-12-30 18:23:42 -0800212XMLPUBFUN void XMLCALL
The Android Open Source Projectab4e2e92009-03-03 19:30:06 -0800213 xmlHashScan3 (xmlHashTablePtr table,
214 const xmlChar *name,
215 const xmlChar *name2,
216 const xmlChar *name3,
217 xmlHashScanner f,
218 void *data);
Selim Gurun94442ad2013-12-30 18:23:42 -0800219XMLPUBFUN void XMLCALL
The Android Open Source Projectab4e2e92009-03-03 19:30:06 -0800220 xmlHashScanFull (xmlHashTablePtr table,
221 xmlHashScannerFull f,
222 void *data);
Selim Gurun94442ad2013-12-30 18:23:42 -0800223XMLPUBFUN void XMLCALL
The Android Open Source Projectab4e2e92009-03-03 19:30:06 -0800224 xmlHashScanFull3(xmlHashTablePtr table,
225 const xmlChar *name,
226 const xmlChar *name2,
227 const xmlChar *name3,
228 xmlHashScannerFull f,
229 void *data);
230#ifdef __cplusplus
231}
232#endif
233#endif /* ! __XML_HASH_H__ */