Main Page   Modules   Data Structures   File List   Data Fields   Related Pages  

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 1.2
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 
00032 /* The iterator is on the stack, but its real fields are
00033  * hidden privately.
00034  */
00035 struct DBusHashIter
00036 {
00037   void *dummy1;
00038   void *dummy2;
00039   void *dummy3;
00040   void *dummy4;
00041   int   dummy5;
00042   int   dummy6;
00043 };
00044 
00045 typedef struct DBusHashTable DBusHashTable;
00046 typedef struct DBusHashIter  DBusHashIter;
00047 
00048 /* Allowing an arbitrary function as with GLib
00049  * would be nicer for a public API, but for
00050  * an internal API this saves typing, we can add
00051  * more whenever we feel like it.
00052  */
00053 typedef enum
00054 {
00055   DBUS_HASH_STRING,  
00056   DBUS_HASH_INT,     
00057   DBUS_HASH_POINTER, 
00058   DBUS_HASH_ULONG    
00059 } DBusHashType;
00060 
00061 DBusHashTable* _dbus_hash_table_new            (DBusHashType      type,
00062                                                 DBusFreeFunction  key_free_function,
00063                                                 DBusFreeFunction  value_free_function);
00064 void           _dbus_hash_table_ref            (DBusHashTable    *table);
00065 void           _dbus_hash_table_unref          (DBusHashTable    *table);
00066 void           _dbus_hash_iter_init            (DBusHashTable    *table,
00067                                                 DBusHashIter     *iter);
00068 dbus_bool_t    _dbus_hash_iter_next            (DBusHashIter     *iter);
00069 void           _dbus_hash_iter_remove_entry    (DBusHashIter     *iter);
00070 void*          _dbus_hash_iter_get_value       (DBusHashIter     *iter);
00071 void           _dbus_hash_iter_set_value       (DBusHashIter     *iter,
00072                                                 void             *value);
00073 int            _dbus_hash_iter_get_int_key     (DBusHashIter     *iter);
00074 const char*    _dbus_hash_iter_get_string_key  (DBusHashIter     *iter);
00075 unsigned long  _dbus_hash_iter_get_ulong_key   (DBusHashIter     *iter);
00076 dbus_bool_t    _dbus_hash_iter_lookup          (DBusHashTable    *table,
00077                                                 void             *key,
00078                                                 dbus_bool_t       create_if_not_found,
00079                                                 DBusHashIter     *iter);
00080 void*          _dbus_hash_table_lookup_string  (DBusHashTable    *table,
00081                                                 const char       *key);
00082 void*          _dbus_hash_table_lookup_int     (DBusHashTable    *table,
00083                                                 int               key);
00084 void*          _dbus_hash_table_lookup_pointer (DBusHashTable    *table,
00085                                                 void             *key);
00086 void*          _dbus_hash_table_lookup_ulong   (DBusHashTable    *table,
00087                                                 unsigned long     key);
00088 dbus_bool_t    _dbus_hash_table_remove_string  (DBusHashTable    *table,
00089                                                 const char       *key);
00090 dbus_bool_t    _dbus_hash_table_remove_int     (DBusHashTable    *table,
00091                                                 int               key);
00092 dbus_bool_t    _dbus_hash_table_remove_pointer (DBusHashTable    *table,
00093                                                 void             *key);
00094 dbus_bool_t    _dbus_hash_table_remove_ulong   (DBusHashTable    *table,
00095                                                 unsigned long     key);
00096 dbus_bool_t    _dbus_hash_table_insert_string  (DBusHashTable    *table,
00097                                                 char             *key,
00098                                                 void             *value);
00099 dbus_bool_t    _dbus_hash_table_insert_int     (DBusHashTable    *table,
00100                                                 int               key,
00101                                                 void             *value);
00102 dbus_bool_t    _dbus_hash_table_insert_pointer (DBusHashTable    *table,
00103                                                 void             *key,
00104                                                 void             *value);
00105 dbus_bool_t    _dbus_hash_table_insert_ulong   (DBusHashTable    *table,
00106                                                 unsigned long     key,
00107                                                 void             *value);
00108 int            _dbus_hash_table_get_n_entries  (DBusHashTable    *table);
00109 
00110 
00111 /* Preallocation */
00112 typedef struct DBusPreallocatedHash DBusPreallocatedHash;
00113 
00114 DBusPreallocatedHash *_dbus_hash_table_preallocate_entry          (DBusHashTable        *table);
00115 void                  _dbus_hash_table_free_preallocated_entry    (DBusHashTable        *table,
00116                                                                    DBusPreallocatedHash *preallocated);
00117 void                  _dbus_hash_table_insert_string_preallocated (DBusHashTable        *table,
00118                                                                    DBusPreallocatedHash *preallocated,
00119                                                                    char                 *key,
00120                                                                    void                 *value);
00121 
00122 
00123 DBUS_END_DECLS;
00124 
00125 #endif /* DBUS_HASH_H */

Generated on Wed Oct 22 14:05:01 2003 for D-BUS by doxygen1.3-rc3