Daniel Veillard | 3fe8768 | 2000-10-23 08:10:05 +0000 | [diff] [blame] | 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 | /* |
Daniel Veillard | 126f279 | 2000-10-24 17:10:12 +0000 | [diff] [blame] | 28 | * The hash table |
Daniel Veillard | 3fe8768 | 2000-10-23 08:10:05 +0000 | [diff] [blame] | 29 | */ |
| 30 | typedef struct _xmlHashTable xmlHashTable; |
| 31 | typedef xmlHashTable *xmlHashTablePtr; |
Daniel Veillard | 3fe8768 | 2000-10-23 08:10:05 +0000 | [diff] [blame] | 32 | |
| 33 | /* |
| 34 | * function types: |
| 35 | */ |
Daniel Veillard | 126f279 | 2000-10-24 17:10:12 +0000 | [diff] [blame] | 36 | typedef void (*xmlHashDeallocator)(void *payload, xmlChar *name); |
| 37 | typedef void *(*xmlHashCopier)(void *payload, xmlChar *name); |
| 38 | typedef void *(*xmlHashScanner)(void *payload, void *data, xmlChar *name); |
Daniel Veillard | 3fe8768 | 2000-10-23 08:10:05 +0000 | [diff] [blame] | 39 | |
| 40 | /* |
| 41 | * Constructor and destructor |
| 42 | */ |
| 43 | xmlHashTablePtr xmlHashCreate (int size); |
| 44 | void xmlHashFree (xmlHashTablePtr table, |
| 45 | xmlHashDeallocator f); |
| 46 | |
| 47 | /* |
| 48 | * Add a new entry to the hash table |
| 49 | */ |
| 50 | int xmlHashAddEntry (xmlHashTablePtr table, |
| 51 | const xmlChar *name, |
| 52 | void *userdata); |
| 53 | int xmlHashUpdateEntry(xmlHashTablePtr table, |
| 54 | const xmlChar *name, |
| 55 | void *userdata, |
| 56 | xmlHashDeallocator f); |
Daniel Veillard | 126f279 | 2000-10-24 17:10:12 +0000 | [diff] [blame] | 57 | int xmlHashAddEntry2(xmlHashTablePtr table, |
| 58 | const xmlChar *name, |
| 59 | const xmlChar *name2, |
| 60 | void *userdata); |
| 61 | int xmlHashUpdateEntry2(xmlHashTablePtr table, |
| 62 | const xmlChar *name, |
| 63 | const xmlChar *name2, |
| 64 | void *userdata, |
| 65 | xmlHashDeallocator f); |
| 66 | int xmlHashAddEntry3(xmlHashTablePtr table, |
| 67 | const xmlChar *name, |
| 68 | const xmlChar *name2, |
| 69 | const xmlChar *name3, |
| 70 | void *userdata); |
| 71 | int xmlHashUpdateEntry3(xmlHashTablePtr table, |
| 72 | const xmlChar *name, |
| 73 | const xmlChar *name2, |
| 74 | const xmlChar *name3, |
| 75 | void *userdata, |
| 76 | xmlHashDeallocator f); |
Daniel Veillard | 3fe8768 | 2000-10-23 08:10:05 +0000 | [diff] [blame] | 77 | /* |
| 78 | * Retrieve the userdata |
| 79 | */ |
| 80 | void * xmlHashLookup (xmlHashTablePtr table, |
| 81 | const xmlChar *name); |
Daniel Veillard | 126f279 | 2000-10-24 17:10:12 +0000 | [diff] [blame] | 82 | void * xmlHashLookup2 (xmlHashTablePtr table, |
| 83 | const xmlChar *name, |
| 84 | const xmlChar *name2); |
| 85 | void * xmlHashLookup3 (xmlHashTablePtr table, |
| 86 | const xmlChar *name, |
| 87 | const xmlChar *name2, |
| 88 | const xmlChar *name3); |
Daniel Veillard | 3fe8768 | 2000-10-23 08:10:05 +0000 | [diff] [blame] | 89 | |
| 90 | /* |
| 91 | * Helpers |
| 92 | */ |
| 93 | xmlHashTablePtr xmlHashCopy (xmlHashTablePtr table, |
| 94 | xmlHashCopier f); |
| 95 | void xmlHashScan (xmlHashTablePtr table, |
| 96 | xmlHashScanner f, |
| 97 | void *data); |
Daniel Veillard | 126f279 | 2000-10-24 17:10:12 +0000 | [diff] [blame] | 98 | void xmlHashScan1 (xmlHashTablePtr table, |
| 99 | const xmlChar *name, |
| 100 | xmlHashScanner f, |
| 101 | void *data); |
| 102 | void xmlHashScan2 (xmlHashTablePtr table, |
| 103 | const xmlChar *name, |
| 104 | const xmlChar *name2, |
| 105 | xmlHashScanner f, |
| 106 | void *data); |
| 107 | void xmlHashScan3 (xmlHashTablePtr table, |
| 108 | const xmlChar *name, |
| 109 | const xmlChar *name2, |
| 110 | const xmlChar *name3, |
| 111 | xmlHashScanner f, |
| 112 | void *data); |
Daniel Veillard | 3fe8768 | 2000-10-23 08:10:05 +0000 | [diff] [blame] | 113 | #ifdef __cplusplus |
| 114 | } |
| 115 | #endif |
| 116 | #endif /* ! __XML_HASH_H__ */ |