hash.h

Go to the documentation of this file.
00001 /*
00002  * Summary: Chained hash tables
00003  * Description: This module implements the hash table support used in 
00004  *      various places in the library.
00005  *
00006  * Copy: See Copyright for the status of this software.
00007  *
00008  * Author: Bjorn Reese <bjorn.reese@systematic.dk>
00009  */
00010 
00011 #ifndef __XML_HASH_H__
00012 #define __XML_HASH_H__
00013 
00014 #ifdef __cplusplus
00015 extern "C" {
00016 #endif
00017 
00018 /*
00019  * The hash table.
00020  */
00021 typedef struct _xmlHashTable xmlHashTable;
00022 typedef xmlHashTable *xmlHashTablePtr;
00023 
00024 #ifdef __cplusplus
00025 }
00026 #endif
00027 
00028 #include <libxml/xmlversion.h>
00029 #include <libxml/parser.h>
00030 #include <libxml/dict.h>
00031 
00032 #ifdef __cplusplus
00033 extern "C" {
00034 #endif
00035 
00036 /*
00037  * Recent version of gcc produce a warning when a function pointer is assigned
00038  * to an object pointer, or vice versa.  The following macro is a dirty hack
00039  * to allow suppression of the warning.  If your architecture has function
00040  * pointers which are a different size than a void pointer, there may be some
00041  * serious trouble within the library.
00042  */
00056 #define XML_CAST_FPTR(fptr) fptr
00057 
00058 
00059 /*
00060  * function types:
00061  */
00069 typedef void (*xmlHashDeallocator)(void *payload, xmlChar *name);
00079 typedef void *(*xmlHashCopier)(void *payload, xmlChar *name);
00088 typedef void (*xmlHashScanner)(void *payload, void *data, xmlChar *name);
00099 typedef void (*xmlHashScannerFull)(void *payload, void *data,
00100                    const xmlChar *name, const xmlChar *name2,
00101                    const xmlChar *name3);
00102 
00103 /*
00104  * Constructor and destructor.
00105  */
00106 XMLPUBFUN xmlHashTablePtr XMLCALL
00107             xmlHashCreate   (int size);
00108 XMLPUBFUN xmlHashTablePtr XMLCALL
00109             xmlHashCreateDict(int size,
00110                      xmlDictPtr dict);
00111 XMLPUBFUN void XMLCALL          
00112             xmlHashFree (xmlHashTablePtr table,
00113                      xmlHashDeallocator f);
00114 
00115 /*
00116  * Add a new entry to the hash table.
00117  */
00118 XMLPUBFUN int XMLCALL           
00119             xmlHashAddEntry (xmlHashTablePtr table,
00120                                  const xmlChar *name,
00121                                  void *userdata);
00122 XMLPUBFUN int XMLCALL           
00123             xmlHashUpdateEntry(xmlHashTablePtr table,
00124                                  const xmlChar *name,
00125                                  void *userdata,
00126                      xmlHashDeallocator f);
00127 XMLPUBFUN int XMLCALL           
00128             xmlHashAddEntry2(xmlHashTablePtr table,
00129                                  const xmlChar *name,
00130                                  const xmlChar *name2,
00131                                  void *userdata);
00132 XMLPUBFUN int XMLCALL           
00133             xmlHashUpdateEntry2(xmlHashTablePtr table,
00134                                  const xmlChar *name,
00135                                  const xmlChar *name2,
00136                                  void *userdata,
00137                      xmlHashDeallocator f);
00138 XMLPUBFUN int XMLCALL           
00139             xmlHashAddEntry3(xmlHashTablePtr table,
00140                                  const xmlChar *name,
00141                                  const xmlChar *name2,
00142                                  const xmlChar *name3,
00143                                  void *userdata);
00144 XMLPUBFUN int XMLCALL           
00145             xmlHashUpdateEntry3(xmlHashTablePtr table,
00146                                  const xmlChar *name,
00147                                  const xmlChar *name2,
00148                                  const xmlChar *name3,
00149                                  void *userdata,
00150                      xmlHashDeallocator f);
00151 
00152 /*
00153  * Remove an entry from the hash table.
00154  */
00155 XMLPUBFUN int XMLCALL     
00156             xmlHashRemoveEntry(xmlHashTablePtr table, const xmlChar *name,
00157                            xmlHashDeallocator f);
00158 XMLPUBFUN int XMLCALL     
00159             xmlHashRemoveEntry2(xmlHashTablePtr table, const xmlChar *name,
00160                             const xmlChar *name2, xmlHashDeallocator f);
00161 XMLPUBFUN int  XMLCALL    
00162             xmlHashRemoveEntry3(xmlHashTablePtr table, const xmlChar *name,
00163                             const xmlChar *name2, const xmlChar *name3,
00164                             xmlHashDeallocator f);
00165 
00166 /*
00167  * Retrieve the userdata.
00168  */
00169 XMLPUBFUN void * XMLCALL            
00170             xmlHashLookup   (xmlHashTablePtr table,
00171                      const xmlChar *name);
00172 XMLPUBFUN void * XMLCALL            
00173             xmlHashLookup2  (xmlHashTablePtr table,
00174                      const xmlChar *name,
00175                      const xmlChar *name2);
00176 XMLPUBFUN void * XMLCALL            
00177             xmlHashLookup3  (xmlHashTablePtr table,
00178                      const xmlChar *name,
00179                      const xmlChar *name2,
00180                      const xmlChar *name3);
00181 XMLPUBFUN void * XMLCALL            
00182             xmlHashQLookup  (xmlHashTablePtr table,
00183                      const xmlChar *name,
00184                      const xmlChar *prefix);
00185 XMLPUBFUN void * XMLCALL            
00186             xmlHashQLookup2 (xmlHashTablePtr table,
00187                      const xmlChar *name,
00188                      const xmlChar *prefix,
00189                      const xmlChar *name2,
00190                      const xmlChar *prefix2);
00191 XMLPUBFUN void * XMLCALL            
00192             xmlHashQLookup3 (xmlHashTablePtr table,
00193                      const xmlChar *name,
00194                      const xmlChar *prefix,
00195                      const xmlChar *name2,
00196                      const xmlChar *prefix2,
00197                      const xmlChar *name3,
00198                      const xmlChar *prefix3);
00199 
00200 /*
00201  * Helpers.
00202  */
00203 XMLPUBFUN xmlHashTablePtr XMLCALL       
00204             xmlHashCopy (xmlHashTablePtr table,
00205                      xmlHashCopier f);
00206 XMLPUBFUN int XMLCALL           
00207             xmlHashSize (xmlHashTablePtr table);
00208 XMLPUBFUN void XMLCALL          
00209             xmlHashScan (xmlHashTablePtr table,
00210                      xmlHashScanner f,
00211                      void *data);
00212 XMLPUBFUN void XMLCALL          
00213             xmlHashScan3    (xmlHashTablePtr table,
00214                      const xmlChar *name,
00215                      const xmlChar *name2,
00216                      const xmlChar *name3,
00217                      xmlHashScanner f,
00218                      void *data);
00219 XMLPUBFUN void XMLCALL          
00220             xmlHashScanFull (xmlHashTablePtr table,
00221                      xmlHashScannerFull f,
00222                      void *data);
00223 XMLPUBFUN void XMLCALL          
00224             xmlHashScanFull3(xmlHashTablePtr table,
00225                      const xmlChar *name,
00226                      const xmlChar *name2,
00227                      const xmlChar *name3,
00228                      xmlHashScannerFull f,
00229                      void *data);
00230 #ifdef __cplusplus
00231 }
00232 #endif
00233 #endif /* ! __XML_HASH_H__ */
footer
 SourceForge.net Logo