Annotation of XML/hash.h, revision 1.4
1.1 veillard 1: /*
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
24: extern "C" {
25: #endif
26:
27: /*
28: * A single entry in the hash table
29: */
1.2 veillard 30: typedef struct _xmlHashEntry xmlHashEntry;
31: typedef xmlHashEntry *xmlHashEntryPtr;
32: struct _xmlHashEntry {
1.1 veillard 33: struct _xmlHashEntry *next;
34: xmlChar *name;
1.3 veillard 35: xmlChar *name2;
36: xmlChar *name3;
1.1 veillard 37: void *payload;
1.2 veillard 38: };
1.1 veillard 39:
40: /*
41: * The entire hash table
42: */
1.2 veillard 43: typedef struct _xmlHashTable xmlHashTable;
44: typedef xmlHashTable *xmlHashTablePtr;
45: struct _xmlHashTable {
1.1 veillard 46: struct _xmlHashEntry **table;
47: int size;
1.2 veillard 48: };
1.1 veillard 49:
50: /*
1.2 veillard 51: * function types:
1.1 veillard 52: */
1.2 veillard 53: typedef void (*xmlHashDeallocator)(void *payload);
54: typedef void *(*xmlHashCopier)(void *payload);
55: typedef void *(*xmlHashScanner)(void *payload, void *data);
1.1 veillard 56:
57: /*
58: * Constructor and destructor
59: */
60: xmlHashTablePtr xmlHashCreate (int size);
61: void xmlHashFree (xmlHashTablePtr table,
62: xmlHashDeallocator f);
63:
64: /*
65: * Add a new entry to the hash table
66: */
67: int xmlHashAddEntry (xmlHashTablePtr table,
68: const xmlChar *name,
69: void *userdata);
70: int xmlHashUpdateEntry(xmlHashTablePtr table,
71: const xmlChar *name,
72: void *userdata,
73: xmlHashDeallocator f);
1.3 veillard 74: int xmlHashAddEntry2(xmlHashTablePtr table,
75: const xmlChar *name,
76: const xmlChar *name2,
77: void *userdata);
78: int xmlHashUpdateEntry2(xmlHashTablePtr table,
79: const xmlChar *name,
80: const xmlChar *name2,
81: void *userdata,
82: xmlHashDeallocator f);
83: int xmlHashAddEntry3(xmlHashTablePtr table,
84: const xmlChar *name,
85: const xmlChar *name2,
86: const xmlChar *name3,
87: void *userdata);
88: int xmlHashUpdateEntry3(xmlHashTablePtr table,
89: const xmlChar *name,
90: const xmlChar *name2,
91: const xmlChar *name3,
92: void *userdata,
93: xmlHashDeallocator f);
1.1 veillard 94: /*
95: * Retrieve the userdata
96: */
97: void * xmlHashLookup (xmlHashTablePtr table,
98: const xmlChar *name);
1.3 veillard 99: void * xmlHashLookup2 (xmlHashTablePtr table,
100: const xmlChar *name,
101: const xmlChar *name2);
102: void * xmlHashLookup3 (xmlHashTablePtr table,
103: const xmlChar *name,
104: const xmlChar *name2,
105: const xmlChar *name3);
1.1 veillard 106:
1.2 veillard 107: /*
108: * Helpers
109: */
110: xmlHashTablePtr xmlHashCopy (xmlHashTablePtr table,
111: xmlHashCopier f);
112: void xmlHashScan (xmlHashTablePtr table,
113: xmlHashScanner f,
114: void *data);
1.4 ! veillard 115: void xmlHashScan1 (xmlHashTablePtr table,
! 116: const xmlChar *name,
! 117: xmlHashScanner f,
! 118: void *data);
! 119: void xmlHashScan2 (xmlHashTablePtr table,
! 120: const xmlChar *name,
! 121: const xmlChar *name2,
! 122: xmlHashScanner f,
! 123: void *data);
! 124: void xmlHashScan3 (xmlHashTablePtr table,
! 125: const xmlChar *name,
! 126: const xmlChar *name2,
! 127: const xmlChar *name3,
! 128: xmlHashScanner f,
! 129: void *data);
1.1 veillard 130: #ifdef __cplusplus
131: }
132: #endif
133: #endif /* ! __XML_HASH_H__ */
Webmaster