(root)/
libxml2-2.12.3/
include/
libxml/
hash.h
       1  /*
       2   * Summary: Chained hash tables
       3   * Description: This module implements the hash table support used in
       4   *		various places in the library.
       5   *
       6   * Copy: See Copyright for the status of this software.
       7   *
       8   * Author: Bjorn Reese <bjorn.reese@systematic.dk>
       9   */
      10  
      11  #ifndef __XML_HASH_H__
      12  #define __XML_HASH_H__
      13  
      14  #include <libxml/xmlversion.h>
      15  #include <libxml/dict.h>
      16  #include <libxml/xmlstring.h>
      17  
      18  #ifdef __cplusplus
      19  extern "C" {
      20  #endif
      21  
      22  /*
      23   * The hash table.
      24   */
      25  typedef struct _xmlHashTable xmlHashTable;
      26  typedef xmlHashTable *xmlHashTablePtr;
      27  
      28  /*
      29   * Recent version of gcc produce a warning when a function pointer is assigned
      30   * to an object pointer, or vice versa.  The following macro is a dirty hack
      31   * to allow suppression of the warning.  If your architecture has function
      32   * pointers which are a different size than a void pointer, there may be some
      33   * serious trouble within the library.
      34   */
      35  /**
      36   * XML_CAST_FPTR:
      37   * @fptr:  pointer to a function
      38   *
      39   * Macro to do a casting from an object pointer to a
      40   * function pointer without encountering a warning from
      41   * gcc
      42   *
      43   * #define XML_CAST_FPTR(fptr) (*(void **)(&fptr))
      44   * This macro violated ISO C aliasing rules (gcc4 on s390 broke)
      45   * so it is disabled now
      46   */
      47  
      48  #define XML_CAST_FPTR(fptr) fptr
      49  
      50  /*
      51   * function types:
      52   */
      53  /**
      54   * xmlHashDeallocator:
      55   * @payload:  the data in the hash
      56   * @name:  the name associated
      57   *
      58   * Callback to free data from a hash.
      59   */
      60  typedef void (*xmlHashDeallocator)(void *payload, const xmlChar *name);
      61  /**
      62   * xmlHashCopier:
      63   * @payload:  the data in the hash
      64   * @name:  the name associated
      65   *
      66   * Callback to copy data from a hash.
      67   *
      68   * Returns a copy of the data or NULL in case of error.
      69   */
      70  typedef void *(*xmlHashCopier)(void *payload, const xmlChar *name);
      71  /**
      72   * xmlHashScanner:
      73   * @payload:  the data in the hash
      74   * @data:  extra scanner data
      75   * @name:  the name associated
      76   *
      77   * Callback when scanning data in a hash with the simple scanner.
      78   */
      79  typedef void (*xmlHashScanner)(void *payload, void *data, const xmlChar *name);
      80  /**
      81   * xmlHashScannerFull:
      82   * @payload:  the data in the hash
      83   * @data:  extra scanner data
      84   * @name:  the name associated
      85   * @name2:  the second name associated
      86   * @name3:  the third name associated
      87   *
      88   * Callback when scanning data in a hash with the full scanner.
      89   */
      90  typedef void (*xmlHashScannerFull)(void *payload, void *data,
      91  				   const xmlChar *name, const xmlChar *name2,
      92  				   const xmlChar *name3);
      93  
      94  /*
      95   * Constructor and destructor.
      96   */
      97  XMLPUBFUN xmlHashTablePtr
      98  		xmlHashCreate		(int size);
      99  XMLPUBFUN xmlHashTablePtr
     100  		xmlHashCreateDict	(int size,
     101  					 xmlDictPtr dict);
     102  XMLPUBFUN void
     103  		xmlHashFree		(xmlHashTablePtr hash,
     104  					 xmlHashDeallocator dealloc);
     105  XMLPUBFUN void
     106  		xmlHashDefaultDeallocator(void *entry,
     107  					 const xmlChar *name);
     108  
     109  /*
     110   * Add a new entry to the hash table.
     111   */
     112  XMLPUBFUN int
     113  		xmlHashAddEntry		(xmlHashTablePtr hash,
     114  		                         const xmlChar *name,
     115  		                         void *userdata);
     116  XMLPUBFUN int
     117  		xmlHashUpdateEntry	(xmlHashTablePtr hash,
     118  		                         const xmlChar *name,
     119  		                         void *userdata,
     120  					 xmlHashDeallocator dealloc);
     121  XMLPUBFUN int
     122  		xmlHashAddEntry2	(xmlHashTablePtr hash,
     123  		                         const xmlChar *name,
     124  		                         const xmlChar *name2,
     125  		                         void *userdata);
     126  XMLPUBFUN int
     127  		xmlHashUpdateEntry2	(xmlHashTablePtr hash,
     128  		                         const xmlChar *name,
     129  		                         const xmlChar *name2,
     130  		                         void *userdata,
     131  					 xmlHashDeallocator dealloc);
     132  XMLPUBFUN int
     133  		xmlHashAddEntry3	(xmlHashTablePtr hash,
     134  		                         const xmlChar *name,
     135  		                         const xmlChar *name2,
     136  		                         const xmlChar *name3,
     137  		                         void *userdata);
     138  XMLPUBFUN int
     139  		xmlHashUpdateEntry3	(xmlHashTablePtr hash,
     140  		                         const xmlChar *name,
     141  		                         const xmlChar *name2,
     142  		                         const xmlChar *name3,
     143  		                         void *userdata,
     144  					 xmlHashDeallocator dealloc);
     145  
     146  /*
     147   * Remove an entry from the hash table.
     148   */
     149  XMLPUBFUN int
     150  		xmlHashRemoveEntry	(xmlHashTablePtr hash,
     151  					 const xmlChar *name,
     152  					 xmlHashDeallocator dealloc);
     153  XMLPUBFUN int
     154  		xmlHashRemoveEntry2	(xmlHashTablePtr hash,
     155  					 const xmlChar *name,
     156  					 const xmlChar *name2,
     157  					 xmlHashDeallocator dealloc);
     158  XMLPUBFUN int 
     159  		xmlHashRemoveEntry3	(xmlHashTablePtr hash,
     160  					 const xmlChar *name,
     161  					 const xmlChar *name2,
     162  					 const xmlChar *name3,
     163  					 xmlHashDeallocator dealloc);
     164  
     165  /*
     166   * Retrieve the payload.
     167   */
     168  XMLPUBFUN void *
     169  		xmlHashLookup		(xmlHashTablePtr hash,
     170  					 const xmlChar *name);
     171  XMLPUBFUN void *
     172  		xmlHashLookup2		(xmlHashTablePtr hash,
     173  					 const xmlChar *name,
     174  					 const xmlChar *name2);
     175  XMLPUBFUN void *
     176  		xmlHashLookup3		(xmlHashTablePtr hash,
     177  					 const xmlChar *name,
     178  					 const xmlChar *name2,
     179  					 const xmlChar *name3);
     180  XMLPUBFUN void *
     181  		xmlHashQLookup		(xmlHashTablePtr hash,
     182  					 const xmlChar *prefix,
     183  					 const xmlChar *name);
     184  XMLPUBFUN void *
     185  		xmlHashQLookup2		(xmlHashTablePtr hash,
     186  					 const xmlChar *prefix,
     187  					 const xmlChar *name,
     188  					 const xmlChar *prefix2,
     189  					 const xmlChar *name2);
     190  XMLPUBFUN void *
     191  		xmlHashQLookup3		(xmlHashTablePtr hash,
     192  					 const xmlChar *prefix,
     193  					 const xmlChar *name,
     194  					 const xmlChar *prefix2,
     195  					 const xmlChar *name2,
     196  					 const xmlChar *prefix3,
     197  					 const xmlChar *name3);
     198  
     199  /*
     200   * Helpers.
     201   */
     202  XMLPUBFUN xmlHashTablePtr
     203  		xmlHashCopy		(xmlHashTablePtr hash,
     204  					 xmlHashCopier copy);
     205  XMLPUBFUN int
     206  		xmlHashSize		(xmlHashTablePtr hash);
     207  XMLPUBFUN void
     208  		xmlHashScan		(xmlHashTablePtr hash,
     209  					 xmlHashScanner scan,
     210  					 void *data);
     211  XMLPUBFUN void
     212  		xmlHashScan3		(xmlHashTablePtr hash,
     213  					 const xmlChar *name,
     214  					 const xmlChar *name2,
     215  					 const xmlChar *name3,
     216  					 xmlHashScanner scan,
     217  					 void *data);
     218  XMLPUBFUN void
     219  		xmlHashScanFull		(xmlHashTablePtr hash,
     220  					 xmlHashScannerFull scan,
     221  					 void *data);
     222  XMLPUBFUN void
     223  		xmlHashScanFull3	(xmlHashTablePtr hash,
     224  					 const xmlChar *name,
     225  					 const xmlChar *name2,
     226  					 const xmlChar *name3,
     227  					 xmlHashScannerFull scan,
     228  					 void *data);
     229  #ifdef __cplusplus
     230  }
     231  #endif
     232  #endif /* ! __XML_HASH_H__ */