2547
2716
weechat.list_free(list)
2548
2717
----------------------------------------
2723
Funzioni per le tabelle hash.
2725
weechat_hashtable_new
2726
^^^^^^^^^^^^^^^^^^^^^
2728
_Novità nella versione 0.3.3._
2730
Crea una nuova tabella hash.
2735
----------------------------------------
2736
struct t_hashtable *weechat_hashtable_new (int size,
2737
const char *type_keys,
2738
const char *type_values,
2739
unsigned int (*callback_hash_key)(struct t_hashtable *hashtable,
2741
int (*callback_keycmp)(struct t_hashtable *hashtable,
2744
----------------------------------------
2748
* 'size': dimensione dell'array interno per memorizzare le chiavi con hash, un
2749
valore più alto usa più memoria, ma ha migliori performance. (questo *non* è
2750
un limite per il numero di elementi nella tabella hash)
2751
* 'type_keys': tipo per le chiavi nella tabella hash:
2752
** 'WEECHAT_HASHTABLE_INTEGER'
2753
** 'WEECHAT_HASHTABLE_STRING'
2754
** 'WEECHAT_HASHTABLE_POINTER'
2755
** 'WEECHAT_HASHTABLE_BUFFER'
2756
** 'WEECHAT_HASHTABLE_TIME'
2757
* 'type_values': tipo per i valori nella tabella hash:
2758
** 'WEECHAT_HASHTABLE_INTEGER'
2759
** 'WEECHAT_HASHTABLE_STRING'
2760
** 'WEECHAT_HASHTABLE_POINTER'
2761
** 'WEECHAT_HASHTABLE_BUFFER'
2762
** 'WEECHAT_HASHTABLE_TIME'
2763
* 'callback_hash_key': callback utilizzata per effettuare un "hash" di una
2764
chiave (chiave come valore intero), può essere NULL se il tipo della chiave è
2765
"string" (viene usata una funzione predefinita per le stringhe, e solo per le
2767
* 'callback_keycmp': callback utilizzata per comparare due chiavi, può essere
2768
NULL se il tipo di valore è "string" (una funzione di confronto predefinita è
2769
usata per le stringhe e solo per le stringhe)
2773
* puntatore alla nuova tabella hash, NULL in caso di errore
2778
----------------------------------------
2779
struct t_hashtable *hashtable = weechat_hashtable_new (8,
2780
WEECHAT_HASHTABLE_STRING,
2781
WEECHAT_HASHTABLE_STRING,
2784
----------------------------------------
2786
weechat_hashtable_set_with_size
2787
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2789
_Novità nella versione 0.3.3._
2791
Aggiunge o aggiorna un elemento nella tabella hash con la dimensione per la
2792
chiave ed il valore.
2797
----------------------------------------
2798
int weechat_hashtable_set_with_size (struct t_hashtable *hashtable,
2799
void *key, int key_size,
2800
void *value, int value_size);
2801
----------------------------------------
2805
* 'hashtable': puntatore alla tabella hash
2806
* 'key': puntatore alla chiave
2807
* 'key_size': dimensione della chiave (in byte), usata solo se il tipo delle
2808
chiavi nella tabella hash è "buffer"
2809
* 'value': puntatore al valore
2810
* 'value_size': dimensione del valore (in byte), utilizzata solo se il tipo dei
2811
valori nella tabella è "buffer"
2815
* 1 se ok, 0 in caso di errore
2820
----------------------------------------
2821
weechat_hashtable_set_with_size (hashtable, "my_key", 0,
2822
my_buffer, sizeof (my_buffer_struct));
2823
----------------------------------------
2825
weechat_hashtable_set
2826
^^^^^^^^^^^^^^^^^^^^^
2828
_Novità nella versione 0.3.3._
2830
Aggiunge o aggiorna un elemento nella tabella hash.
2835
----------------------------------------
2836
int weechat_hashtable_set (struct t_hashtable *hashtable,
2837
void *key, void *value);
2838
----------------------------------------
2842
* 'hashtable': puntatore alla tabella hash
2843
* 'key': puntatore alla chiave
2844
* 'value': puntatore al valore
2848
* 1 se ok, 0 in caso di errore
2853
----------------------------------------
2854
weechat_hashtable_set (hashtable, "my_key", "my_value");
2855
----------------------------------------
2857
weechat_hashtable_get
2858
^^^^^^^^^^^^^^^^^^^^^
2860
_Novità nella versione 0.3.3._
2862
Ottiene il valore associato ad una chiave in una tabella hash.
2867
----------------------------------------
2868
void *weechat_hashtable_get (struct t_hashtable *hashtable, void *key);
2869
----------------------------------------
2873
* 'hashtable': puntatore alla tabella hash
2874
* 'key': puntatore alla chiave
2878
* valore per la chiave, NULL se non trovata
2883
----------------------------------------
2884
void *value = weechat_hashtable_get (hashtable, "my_key");
2885
----------------------------------------
2887
weechat_hashtable_map
2888
^^^^^^^^^^^^^^^^^^^^^
2890
_Novità nella versione 0.3.3._
2892
Chiama una funzione su tutte le voci della tabella hash.
2897
----------------------------------------
2898
void hashtable_map (struct t_hashlist *hashlist,
2899
int (*callback_map)(void *data,
2900
struct t_hashtable *hashtable,
2903
void *callback_map_data);
2904
----------------------------------------
2908
* 'hashtable': puntatore alla tabella hash
2909
* 'callback_map': funzione chiamata per ogni voce nella tabella hash
2910
* 'callback_map_data': puntatore fornito alla mappa di callback quando chiamata
2915
----------------------------------------
2917
map_cb (void *data, struct t_hashtable *hashtable,
2918
const void *key, const void *value)
2920
/* display key and value (they are both strings here) */
2921
weechat_printf (NULL, "key: '%s', value: '%s'",
2923
(const char *)value);
2926
weechat_hashtable_map (hashtable, &map_cb, NULL);
2927
----------------------------------------
2929
weechat_hashtable_get_integer
2930
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2932
_Novità nella versione 0.3.3._
2934
Restituisce un valore intero per la proprietà di una tabella hash.
2939
----------------------------------------
2940
int weechat_hashtable_get_integer (struct t_hashtable *hashtable,
2942
----------------------------------------
2946
* 'hashtable': puntatore alla tabella hash
2947
* 'property': nome della proprietà:
2948
** 'size': dimensione dell'array interno "htable" nella tabella hash
2949
** 'items_count': numero di elementi nella tabella hash
2953
* valore intero della proprietà
2958
----------------------------------------
2959
int items_count = weechat_hashtable_get_integer (hashtable, "items_count");
2960
----------------------------------------
2962
weechat_hashtable_add_to_infolist
2963
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2965
_Novità nella versione 0.3.3._
2967
Aggiunge elementi della tabella hash ad un elemento della lista info.
2972
----------------------------------------
2973
int weechat_hashtable_add_to_infolist (struct t_hashtable *hashtable,
2974
struct t_infolist_item *infolist_item,
2975
const char *prefix);
2976
----------------------------------------
2980
* 'hashtable': puntatore alla tabella hash
2981
* 'infolist_item': puntatore all'elemento della lista info
2982
* 'prefix': stringa usata come prefisso per i nomi nella lista info
2986
* 1 se ok, 0 in caso di errore
2991
----------------------------------------
2992
weechat_hashtable_add_to_infolist (hashtable, infolist_item, "testhash");
2994
/* se la tabella hash contiene:
2997
allora le seguenti variabili verranno aggiunti all'elemento della lista info:
2998
"testhash_name_00001" = "key1"
2999
"testhash_value_00001" = "value 1"
3000
"testhash_name_00002" = "key2"
3001
"testhash_value_00002" = "value 2"
3003
----------------------------------------
3005
weechat_hashtable_remove
3006
^^^^^^^^^^^^^^^^^^^^^^^^
3008
_Novità nella versione 0.3.3._
3010
Rimuove un elemento in una tabella hash.
3015
----------------------------------------
3016
void weechat_hashtable_remove (struct t_hashtable *hashtable, const void *key);
3017
----------------------------------------
3021
* 'hashtable': puntatore alla tabella hash
3022
* 'key': puntatore alla chiave
3027
----------------------------------------
3028
weechat_hashtable_remove (hashtable, "my_key");
3029
----------------------------------------
3031
weechat_hashtable_remove_all
3032
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
3034
_Novità nella versione 0.3.3._
3036
Rimuove tutti gli elementi in una tabella hash.
3041
----------------------------------------
3042
void weechat_hashtable_remove_all (struct t_hashtable *hashtable);
3043
----------------------------------------
3047
* 'hashtable': puntatore alla tabella hash
3052
----------------------------------------
3053
weechat_hashtable_remove_all (hashtable);
3054
----------------------------------------
3056
weechat_hashtable_free
3057
^^^^^^^^^^^^^^^^^^^^^^
3059
_Novità nella versione 0.3.3._
3061
Libera una tabella hash.
3066
----------------------------------------
3067
void weechat_hashtable_free (struct t_hashtable *hashtable);
3068
----------------------------------------
3072
* 'hashtable': puntatore alla tabella hash
3077
----------------------------------------
3078
weechat_hashtable_free (hashtable);
3079
----------------------------------------
2550
3081
[[configuration_files]]
2551
3082
File di configurazione
2552
3083
~~~~~~~~~~~~~~~~~~~~~~