dbus-hash.h

00001 /* -*- mode: C; c-file-style: "gnu" -*- */
00002 /* dbus-hash.h Generic hash table utility (internal to D-Bus implementation)
00003  * 
00004  * Copyright (C) 2002  Red Hat, Inc.
00005  *
00006  * Licensed under the Academic Free License version 2.1
00007  * 
00008  * This program is free software; you can redistribute it and/or modify
00009  * it under the terms of the GNU General Public License as published by
00010  * the Free Software Foundation; either version 2 of the License, or
00011  * (at your option) any later version.
00012  *
00013  * This program is distributed in the hope that it will be useful,
00014  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00015  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00016  * GNU General Public License for more details.
00017  * 
00018  * You should have received a copy of the GNU General Public License
00019  * along with this program; if not, write to the Free Software
00020  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00021  *
00022  */
00023 
00024 #ifndef DBUS_HASH_H
00025 #define DBUS_HASH_H
00026 
00027 #include <dbus/dbus-memory.h>
00028 #include <dbus/dbus-types.h>
00029 
00030 DBUS_BEGIN_DECLS
00031 
00040 struct DBusHashIter
00041 {
00042   void *dummy1; 
00043   void *dummy2; 
00044   void *dummy3; 
00045   void *dummy4; 
00046   int   dummy5; 
00047   int   dummy6; 
00048 };
00049 
00050 typedef struct DBusHashTable DBusHashTable;
00051 typedef struct DBusHashIter  DBusHashIter;
00052 
00053 /* Allowing an arbitrary function as with GLib
00054  * would be nicer for a public API, but for
00055  * an internal API this saves typing, we can add
00056  * more whenever we feel like it.
00057  */
00058 typedef enum
00059 {
00060   DBUS_HASH_STRING,        
00061   DBUS_HASH_TWO_STRINGS,   
00062   DBUS_HASH_INT,           
00063   DBUS_HASH_POINTER,       
00064   DBUS_HASH_ULONG          
00065 } DBusHashType;
00066 
00067 DBusHashTable* _dbus_hash_table_new                (DBusHashType      type,
00068                                                     DBusFreeFunction  key_free_function,
00069                                                     DBusFreeFunction  value_free_function);
00070 DBusHashTable* _dbus_hash_table_ref                (DBusHashTable    *table);
00071 void           _dbus_hash_table_unref              (DBusHashTable    *table);
00072 void           _dbus_hash_table_remove_all         (DBusHashTable    *table);
00073 void           _dbus_hash_iter_init                (DBusHashTable    *table,
00074                                                     DBusHashIter     *iter);
00075 dbus_bool_t    _dbus_hash_iter_next                (DBusHashIter     *iter);
00076 void           _dbus_hash_iter_remove_entry        (DBusHashIter     *iter);
00077 void*          _dbus_hash_iter_get_value           (DBusHashIter     *iter);
00078 void           _dbus_hash_iter_set_value           (DBusHashIter     *iter,
00079                                                     void             *value);
00080 int            _dbus_hash_iter_get_int_key         (DBusHashIter     *iter);
00081 const char*    _dbus_hash_iter_get_string_key      (DBusHashIter     *iter);
00082 const char*    _dbus_hash_iter_get_two_strings_key (DBusHashIter     *iter);
00083 unsigned long  _dbus_hash_iter_get_ulong_key       (DBusHashIter     *iter);
00084 dbus_bool_t    _dbus_hash_iter_lookup              (DBusHashTable    *table,
00085                                                     void             *key,
00086                                                     dbus_bool_t       create_if_not_found,
00087                                                     DBusHashIter     *iter);
00088 void*          _dbus_hash_table_lookup_string      (DBusHashTable    *table,
00089                                                     const char       *key);
00090 void*          _dbus_hash_table_lookup_two_strings (DBusHashTable    *table,
00091                                                     const char       *key);
00092 void*          _dbus_hash_table_lookup_int         (DBusHashTable    *table,
00093                                                     int               key);
00094 void*          _dbus_hash_table_lookup_pointer     (DBusHashTable    *table,
00095                                                     void             *key);
00096 void*          _dbus_hash_table_lookup_ulong       (DBusHashTable    *table,
00097                                                     unsigned long     key);
00098 dbus_bool_t    _dbus_hash_table_remove_string      (DBusHashTable    *table,
00099                                                     const char       *key);
00100 dbus_bool_t    _dbus_hash_table_remove_two_strings (DBusHashTable    *table,
00101                                                     const char       *key);
00102 dbus_bool_t    _dbus_hash_table_remove_int         (DBusHashTable    *table,
00103                                                     int               key);
00104 dbus_bool_t    _dbus_hash_table_remove_pointer     (DBusHashTable    *table,
00105                                                     void             *key);
00106 dbus_bool_t    _dbus_hash_table_remove_ulong       (DBusHashTable    *table,
00107                                                     unsigned long     key);
00108 dbus_bool_t    _dbus_hash_table_insert_string      (DBusHashTable    *table,
00109                                                     char             *key,
00110                                                     void             *value);
00111 dbus_bool_t    _dbus_hash_table_insert_two_strings (DBusHashTable    *table,
00112                                                     char             *key,
00113                                                     void             *value);
00114 dbus_bool_t    _dbus_hash_table_insert_int         (DBusHashTable    *table,
00115                                                     int               key,
00116                                                     void             *value);
00117 dbus_bool_t    _dbus_hash_table_insert_pointer     (DBusHashTable    *table,
00118                                                     void             *key,
00119                                                     void             *value);
00120 dbus_bool_t    _dbus_hash_table_insert_ulong       (DBusHashTable    *table,
00121                                                     unsigned long     key,
00122                                                     void             *value);
00123 int            _dbus_hash_table_get_n_entries      (DBusHashTable    *table);
00124 
00125 /* Preallocation */
00126 
00128 typedef struct DBusPreallocatedHash DBusPreallocatedHash;
00129 
00130 DBusPreallocatedHash *_dbus_hash_table_preallocate_entry          (DBusHashTable        *table);
00131 void                  _dbus_hash_table_free_preallocated_entry    (DBusHashTable        *table,
00132                                                                    DBusPreallocatedHash *preallocated);
00133 void                  _dbus_hash_table_insert_string_preallocated (DBusHashTable        *table,
00134                                                                    DBusPreallocatedHash *preallocated,
00135                                                                    char                 *key,
00136                                                                    void                 *value);
00137 
00140 DBUS_END_DECLS
00141 
00142 #endif /* DBUS_HASH_H */

Generated on Fri Sep 21 18:12:11 2007 for D-Bus by  doxygen 1.5.1