blob: c88fffd190748644d62d11a1e3a6d80894a369cc [file] [log] [blame]
Owen Taylor3473f882001-02-23 17:55:21 +00001/*
2 * hash.c: chained hash tables
3 *
4 * Copyright (C) 2000 Bjorn Reese and Daniel Veillard.
5 *
6 * Permission to use, copy, modify, and distribute this software for any
7 * purpose with or without fee is hereby granted, provided that the above
8 * copyright notice and this permission notice appear in all copies.
9 *
10 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
11 * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
12 * MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE AUTHORS AND
13 * CONTRIBUTORS ACCEPT NO RESPONSIBILITY IN ANY CONCEIVABLE MANNER.
14 *
15 * Author: bjorn.reese@systematic.dk
16 */
17
18#ifndef __XML_HASH_H__
19#define __XML_HASH_H__
20
21#include <libxml/parser.h>
22
23#ifdef __cplusplus
24extern "C" {
25#endif
26
27/*
28 * The hash table
29 */
30typedef struct _xmlHashTable xmlHashTable;
31typedef xmlHashTable *xmlHashTablePtr;
32
33/*
34 * function types:
35 */
36typedef void (*xmlHashDeallocator)(void *payload, xmlChar *name);
37typedef void *(*xmlHashCopier)(void *payload, xmlChar *name);
38typedef void *(*xmlHashScanner)(void *payload, void *data, xmlChar *name);
39
40/*
41 * Constructor and destructor
42 */
43xmlHashTablePtr xmlHashCreate (int size);
44void xmlHashFree (xmlHashTablePtr table,
45 xmlHashDeallocator f);
46
47/*
48 * Add a new entry to the hash table
49 */
50int xmlHashAddEntry (xmlHashTablePtr table,
51 const xmlChar *name,
52 void *userdata);
53int xmlHashUpdateEntry(xmlHashTablePtr table,
54 const xmlChar *name,
55 void *userdata,
56 xmlHashDeallocator f);
57int xmlHashAddEntry2(xmlHashTablePtr table,
58 const xmlChar *name,
59 const xmlChar *name2,
60 void *userdata);
61int xmlHashUpdateEntry2(xmlHashTablePtr table,
62 const xmlChar *name,
63 const xmlChar *name2,
64 void *userdata,
65 xmlHashDeallocator f);
66int xmlHashAddEntry3(xmlHashTablePtr table,
67 const xmlChar *name,
68 const xmlChar *name2,
69 const xmlChar *name3,
70 void *userdata);
71int xmlHashUpdateEntry3(xmlHashTablePtr table,
72 const xmlChar *name,
73 const xmlChar *name2,
74 const xmlChar *name3,
75 void *userdata,
76 xmlHashDeallocator f);
77
78/*
79 * Remove an entry from the hash table
80 */
81int xmlHashRemoveEntry(xmlHashTablePtr table, const xmlChar *name,
82 xmlHashDeallocator f);
83int xmlHashRemoveEntry2(xmlHashTablePtr table, const xmlChar *name,
84 const xmlChar *name2, xmlHashDeallocator f);
85int xmlHashRemoveEntry3(xmlHashTablePtr table, const xmlChar *name,
86 const xmlChar *name2, const xmlChar *name3,
87 xmlHashDeallocator f);
88
89/*
90 * Retrieve the userdata
91 */
92void * xmlHashLookup (xmlHashTablePtr table,
93 const xmlChar *name);
94void * xmlHashLookup2 (xmlHashTablePtr table,
95 const xmlChar *name,
96 const xmlChar *name2);
97void * xmlHashLookup3 (xmlHashTablePtr table,
98 const xmlChar *name,
99 const xmlChar *name2,
100 const xmlChar *name3);
101
102/*
103 * Helpers
104 */
105xmlHashTablePtr xmlHashCopy (xmlHashTablePtr table,
106 xmlHashCopier f);
107int xmlHashSize (xmlHashTablePtr);
108void xmlHashScan (xmlHashTablePtr table,
109 xmlHashScanner f,
110 void *data);
111void xmlHashScan1 (xmlHashTablePtr table,
112 const xmlChar *name,
113 xmlHashScanner f,
114 void *data);
115void xmlHashScan2 (xmlHashTablePtr table,
116 const xmlChar *name,
117 const xmlChar *name2,
118 xmlHashScanner f,
119 void *data);
120void xmlHashScan3 (xmlHashTablePtr table,
121 const xmlChar *name,
122 const xmlChar *name2,
123 const xmlChar *name3,
124 xmlHashScanner f,
125 void *data);
126#ifdef __cplusplus
127}
128#endif
129#endif /* ! __XML_HASH_H__ */