/app/libxml2-2.4.28/include/libxml2/libxml/hash.h


    1 /*
    2  * hash.h: 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  * The hash table.
   29  */
   30 typedef struct _xmlHashTable xmlHashTable;
   31 typedef xmlHashTable *xmlHashTablePtr;
   32 
   33 /*
   34  * function types:
   35  */
   36 /**
   37  * xmlHashDeallocator:
   38  * @payload:  the data in the hash
   39  * @name:  the name associated
   40  *
   41  * Callback to free data from a hash.
   42  */
   43 typedef void (*xmlHashDeallocator)(void *payload, xmlChar *name);
   44 /**
   45  * xmlHashCopier:
   46  * @payload:  the data in the hash
   47  * @name:  the name associated
   48  *
   49  * Callback to copy data from a hash.
   50  *
   51  * Returns a copy of the data or NULL in case of error.
   52  */
   53 typedef void *(*xmlHashCopier)(void *payload, xmlChar *name);
   54 /**
   55  * xmlHashScanner:
   56  * @payload:  the data in the hash
   57  * @data:  extra scannner data
   58  * @name:  the name associated
   59  *
   60  * Callback when scanning data in a hash with the simple scanner.
   61  */
   62 typedef void (*xmlHashScanner)(void *payload, void *data, xmlChar *name);
   63 /**
   64  * xmlHashScannerFull:
   65  * @payload:  the data in the hash
   66  * @data:  extra scannner data
   67  * @name:  the name associated
   68  * @name2:  the second name associated
   69  * @name3:  the third name associated
   70  *
   71  * Callback when scanning data in a hash with the full scanner.
   72  */
   73 typedef void (*xmlHashScannerFull)(void *payload, void *data,
   74 				   const xmlChar *name, const xmlChar *name2,
   75 				   const xmlChar *name3);
   76 
   77 /*
   78  * Constructor and destructor.
   79  */
   80 xmlHashTablePtr		xmlHashCreate	(int size);
   81 void			xmlHashFree	(xmlHashTablePtr table,
   82 					 xmlHashDeallocator f);
   83 
   84 /*
   85  * Add a new entry to the hash table.
   86  */
   87 int			xmlHashAddEntry	(xmlHashTablePtr table,
   88 		                         const xmlChar *name,
   89 		                         void *userdata);
   90 int			xmlHashUpdateEntry(xmlHashTablePtr table,
   91 		                         const xmlChar *name,
   92 		                         void *userdata,
   93 					 xmlHashDeallocator f);
   94 int			xmlHashAddEntry2(xmlHashTablePtr table,
   95 		                         const xmlChar *name,
   96 		                         const xmlChar *name2,
   97 		                         void *userdata);
   98 int			xmlHashUpdateEntry2(xmlHashTablePtr table,
   99 		                         const xmlChar *name,
  100 		                         const xmlChar *name2,
  101 		                         void *userdata,
  102 					 xmlHashDeallocator f);
  103 int			xmlHashAddEntry3(xmlHashTablePtr table,
  104 		                         const xmlChar *name,
  105 		                         const xmlChar *name2,
  106 		                         const xmlChar *name3,
  107 		                         void *userdata);
  108 int			xmlHashUpdateEntry3(xmlHashTablePtr table,
  109 		                         const xmlChar *name,
  110 		                         const xmlChar *name2,
  111 		                         const xmlChar *name3,
  112 		                         void *userdata,
  113 					 xmlHashDeallocator f);
  114 
  115 /*
  116  * Remove an entry from the hash table.
  117  */
  118 int     xmlHashRemoveEntry(xmlHashTablePtr table, const xmlChar *name,
  119                            xmlHashDeallocator f);
  120 int     xmlHashRemoveEntry2(xmlHashTablePtr table, const xmlChar *name,
  121                             const xmlChar *name2, xmlHashDeallocator f);
  122 int     xmlHashRemoveEntry3(xmlHashTablePtr table, const xmlChar *name,
  123                             const xmlChar *name2, const xmlChar *name3,
  124                             xmlHashDeallocator f);
  125 
  126 /*
  127  * Retrieve the userdata.
  128  */
  129 void *			xmlHashLookup	(xmlHashTablePtr table,
  130 					 const xmlChar *name);
  131 void *			xmlHashLookup2	(xmlHashTablePtr table,
  132 					 const xmlChar *name,
  133 					 const xmlChar *name2);
  134 void *			xmlHashLookup3	(xmlHashTablePtr table,
  135 					 const xmlChar *name,
  136 					 const xmlChar *name2,
  137 					 const xmlChar *name3);
  138 
  139 /*
  140  * Helpers.
  141  */
  142 xmlHashTablePtr		xmlHashCopy	(xmlHashTablePtr table,
  143 					 xmlHashCopier f);
  144 int			xmlHashSize	(xmlHashTablePtr table);
  145 void			xmlHashScan	(xmlHashTablePtr table,
  146 					 xmlHashScanner f,
  147 					 void *data);
  148 void			xmlHashScan3	(xmlHashTablePtr table,
  149 					 const xmlChar *name,
  150 					 const xmlChar *name2,
  151 					 const xmlChar *name3,
  152 					 xmlHashScanner f,
  153 					 void *data);
  154 void			xmlHashScanFull	(xmlHashTablePtr table,
  155 					 xmlHashScannerFull f,
  156 					 void *data);
  157 void			xmlHashScanFull3(xmlHashTablePtr table,
  158 					 const xmlChar *name,
  159 					 const xmlChar *name2,
  160 					 const xmlChar *name3,
  161 					 xmlHashScannerFull f,
  162 					 void *data);
  163 #ifdef __cplusplus
  164 }
  165 #endif
  166 #endif /* ! __XML_HASH_H__ */