blob: e045313695dda6cfefd73e5a913f3292c07d19fe [file] [log] [blame]
Daniel Veillard3fe87682000-10-23 08:10:05 +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/*
Daniel Veillard126f2792000-10-24 17:10:12 +000028 * The hash table
Daniel Veillard3fe87682000-10-23 08:10:05 +000029 */
30typedef struct _xmlHashTable xmlHashTable;
31typedef xmlHashTable *xmlHashTablePtr;
Daniel Veillard3fe87682000-10-23 08:10:05 +000032
33/*
34 * function types:
35 */
Daniel Veillard126f2792000-10-24 17:10:12 +000036typedef void (*xmlHashDeallocator)(void *payload, xmlChar *name);
37typedef void *(*xmlHashCopier)(void *payload, xmlChar *name);
38typedef void *(*xmlHashScanner)(void *payload, void *data, xmlChar *name);
Daniel Veillard3fe87682000-10-23 08:10:05 +000039
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);
Daniel Veillard126f2792000-10-24 17:10:12 +000057int 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);
Daniel Veillard3fe87682000-10-23 08:10:05 +000077/*
78 * Retrieve the userdata
79 */
80void * xmlHashLookup (xmlHashTablePtr table,
81 const xmlChar *name);
Daniel Veillard126f2792000-10-24 17:10:12 +000082void * xmlHashLookup2 (xmlHashTablePtr table,
83 const xmlChar *name,
84 const xmlChar *name2);
85void * xmlHashLookup3 (xmlHashTablePtr table,
86 const xmlChar *name,
87 const xmlChar *name2,
88 const xmlChar *name3);
Daniel Veillard3fe87682000-10-23 08:10:05 +000089
90/*
91 * Helpers
92 */
93xmlHashTablePtr xmlHashCopy (xmlHashTablePtr table,
94 xmlHashCopier f);
95void xmlHashScan (xmlHashTablePtr table,
96 xmlHashScanner f,
97 void *data);
Daniel Veillard126f2792000-10-24 17:10:12 +000098void xmlHashScan1 (xmlHashTablePtr table,
99 const xmlChar *name,
100 xmlHashScanner f,
101 void *data);
102void xmlHashScan2 (xmlHashTablePtr table,
103 const xmlChar *name,
104 const xmlChar *name2,
105 xmlHashScanner f,
106 void *data);
107void xmlHashScan3 (xmlHashTablePtr table,
108 const xmlChar *name,
109 const xmlChar *name2,
110 const xmlChar *name3,
111 xmlHashScanner f,
112 void *data);
Daniel Veillard3fe87682000-10-23 08:10:05 +0000113#ifdef __cplusplus
114}
115#endif
116#endif /* ! __XML_HASH_H__ */