Main Page | Class List | File List | Class Members | File Members | Related Pages

gi_dataset.h

Go to the documentation of this file.
00001 /* 00002 * $Id: gi_dataset.h,v 1.1.2.1 2004/04/08 09:27:31 jasta Exp $ 00003 * 00004 * Copyright (C) 2001-2003 giFT project (gift.sourceforge.net) 00005 * 00006 * This program is free software; you can redistribute it and/or modify it 00007 * under the terms of the GNU General Public License as published by the 00008 * Free Software Foundation; either version 2, or (at your option) any 00009 * later version. 00010 * 00011 * This program is distributed in the hope that it will be useful, but 00012 * WITHOUT ANY WARRANTY; without even the implied warranty of 00013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00014 * General Public License for more details. 00015 */ 00016 00017 #ifndef __GI_DATASET_H 00018 #define __GI_DATASET_H 00019 00020 /*****************************************************************************/ 00021 00032 /*****************************************************************************/ 00033 00034 #include "gi_list.h" 00035 #include "array.h" 00036 00037 /*****************************************************************************/ 00038 00039 /* ds_data_t flags */ 00040 #define DS_NOCOPY 0x01 00041 00046 typedef struct 00047 { 00048 void *data; 00049 size_t len; 00050 uint8_t flags; 00051 } ds_data_t; 00052 00053 /*****************************************************************************/ 00054 00058 typedef struct gi_dataset_node 00059 { 00060 ds_data_t *key; 00061 ds_data_t *value; 00062 00063 union 00064 { 00065 struct gi_dataset_node *hash_next; 00066 size_t array_offs; 00067 GiListLink *list_link; 00068 } tdata; 00069 } GiDatasetNode; 00070 00071 /*****************************************************************************/ 00072 00076 typedef enum 00077 { 00078 GI_DATASET_LIST, 00079 GI_DATASET_ARRAY, 00080 GI_DATASET_HASH, 00081 GI_DATASET_DEFAULT = GI_DATASET_HASH 00082 } GiDatasetType; 00083 00084 /* define the GiDataset as an opaque type as it contains sensitive data that 00085 * should not be exported to the caller */ 00086 struct gi_dataset; 00087 typedef struct gi_dataset GiDataset; 00088 00089 /*****************************************************************************/ 00090 00091 #define DS_NOTFOUND 0x00 00092 #define DS_FOUND 0x02 00094 #define DS_CONTINUE 0x01 00095 #define DS_BREAK 0x02 00096 #define DS_REMOVE 0x04 00098 #define DS_RETURN(ret) ((ret) & 0x03) 00099 00104 typedef void (*GiDatasetForeachFn) (ds_data_t *key, ds_data_t *value, 00105 void *udata); 00106 00114 typedef int (*GiDatasetForeachExFn) (ds_data_t *key, ds_data_t *value, 00115 void *udata); 00116 00120 #define DS_FOREACH(func) ((GiDatasetForeachFn)func) 00121 #define DS_FOREACH_EX(func) ((GiDatasetForeachExFn)func) 00122 00123 typedef GiDatasetForeachExFn GiDatasetFindFn; 00124 #define DS_FIND(func) ((GiDatasetFindFn)func) 00125 00126 /*****************************************************************************/ 00127 00128 EXTERN_C_BEGIN 00129 00130 /*****************************************************************************/ 00131 00138 LIBGIFT_EXPORT 00139 GiDataset *gi_dataset_new (GiDatasetType type); 00140 00145 LIBGIFT_EXPORT 00146 void gi_dataset_clear (GiDataset *d); 00147 00151 LIBGIFT_EXPORT 00152 void gi_dataset_destroy (GiDataset **d); 00153 00154 /*****************************************************************************/ 00155 00180 LIBGIFT_EXPORT 00181 void ds_data_init (ds_data_t *dsdata, const void *data, size_t len, 00182 int flags); 00183 00184 /*****************************************************************************/ 00185 00189 LIBGIFT_EXPORT 00190 GiDatasetNode *gi_dataset_insert_ex (GiDataset **d, ds_data_t *key, ds_data_t *value); 00191 00212 LIBGIFT_EXPORT 00213 GiDatasetNode *gi_dataset_insert (GiDataset **d, 00214 const void *key, size_t key_len, 00215 const void *value, size_t value_len); 00216 00221 LIBGIFT_EXPORT 00222 GiDatasetNode *gi_dataset_insertstr (GiDataset **d, const char *key, 00223 const char *value); 00224 00225 /*****************************************************************************/ 00226 00230 LIBGIFT_EXPORT 00231 void gi_dataset_remove_ex (GiDataset *d, ds_data_t *key); 00232 00236 LIBGIFT_EXPORT 00237 void gi_dataset_remove (GiDataset *d, const void *key, size_t key_len); 00238 00242 LIBGIFT_EXPORT 00243 void gi_dataset_removestr (GiDataset *d, const char *key); 00244 00249 LIBGIFT_EXPORT 00250 void gi_dataset_remove_node (GiDataset *d, GiDatasetNode *node); 00251 00252 /*****************************************************************************/ 00253 00257 LIBGIFT_EXPORT 00258 ds_data_t *gi_dataset_lookup_ex (GiDataset *d, ds_data_t *key); 00259 00264 LIBGIFT_EXPORT 00265 void *gi_dataset_lookup (GiDataset *d, const void *key, size_t key_len); 00266 00270 LIBGIFT_EXPORT 00271 void *gi_dataset_lookupstr (GiDataset *d, const char *key); 00272 00276 LIBGIFT_EXPORT 00277 GiDatasetNode *gi_dataset_lookup_node_ex (GiDataset *d, ds_data_t *key); 00278 00283 LIBGIFT_EXPORT 00284 GiDatasetNode *gi_dataset_lookup_node (GiDataset *d, const void *key, 00285 size_t key_len); 00286 00287 /*****************************************************************************/ 00288 00298 LIBGIFT_EXPORT 00299 void gi_dataset_foreach (GiDataset *d, GiDatasetForeachFn func, void *udata); 00300 00306 LIBGIFT_EXPORT 00307 void gi_dataset_foreach_ex (GiDataset *d, GiDatasetForeachExFn func, 00308 void *udata); 00309 00310 /*****************************************************************************/ 00311 00317 LIBGIFT_EXPORT 00318 void *gi_dataset_find (GiDataset *d, GiDatasetFindFn func, void *udata); 00319 00324 LIBGIFT_EXPORT 00325 GiDatasetNode *gi_dataset_find_node (GiDataset *d, GiDatasetFindFn func, 00326 void *udata); 00327 00328 /*****************************************************************************/ 00329 00337 LIBGIFT_EXPORT 00338 unsigned int gi_dataset_length (GiDataset *d); 00339 00340 /*****************************************************************************/ 00341 00345 LIBGIFT_EXPORT 00346 GiList *gi_dataset_flatten (GiDataset *d); 00347 00348 /*****************************************************************************/ 00349 00362 LIBGIFT_EXPORT 00363 uint32_t gi_dataset_uniq32 (GiDataset *d, uint32_t *counter); 00364 00365 /*****************************************************************************/ 00366 00367 EXTERN_C_END 00368 00369 /*****************************************************************************/ 00370 00371 #endif /* __GI_DATASET_H */

Generated on Sun Aug 22 07:56:40 2004 by doxygen 1.3.7