#include "ks_array.h"
Go to the source code of this file.
Data Structures | |
| struct | _ks_bucket_t |
| bucket used to hold keys & values in ks_assoc_t associative arrays. More... | |
| struct | _ks_assoc_t |
| libkarmaclient associative array type. More... | |
Typedefs | |
| typedef _ks_bucket_t | ks_bucket_t |
| bucket used to hold keys & values in ks_assoc_t associative arrays. | |
| typedef _ks_assoc_t | ks_assoc_t |
| libkarmaclient associative array type. | |
Functions | |
| ks_type_t * | ks_assoc_type (void) |
| ks_assoc_t * | ks_assoc_new (void) |
| void | ks_assoc_init (ks_assoc_t *) |
| void | ks_assoc_free (ks_assoc_t *) |
| void | ks_assoc_fini (ks_assoc_t *) |
| void | ks_assoc_put (ks_assoc_t *, const char *, size_t klen, ks_base_t *) |
| ks_base_t * | ks_assoc_get (ks_assoc_t *, const char *, size_t klen) |
| int | ks_assoc_size (ks_assoc_t *) |
| ks_array_t * | ks_assoc_keys (ks_assoc_t *) |
Type and function declarations for the functions defined in ks_assoc.c. Do not include this file directly in your client. Instead, include the application header, ks.h, which will include all the libkarmaclient header files for you.
Definition in file ks_assoc.h.
| typedef struct _ks_assoc_t ks_assoc_t |
libkarmaclient associative array type.
| typedef struct _ks_bucket_t ks_bucket_t |
bucket used to hold keys & values in ks_assoc_t associative arrays.
| void ks_assoc_fini | ( | ks_assoc_t * | s | ) |
Clear the state of a ks_assoc_t, leaving in the ks_assoc_t in a suitable state for ks_assoc_init() to reinitialise.
| s | a pointer to the ks_assoc_t to be reset |
Definition at line 238 of file ks_assoc.c.
References _ks_assoc_t::array, and ks_array_fini().
Referenced by ks_assoc_free().
| void ks_assoc_free | ( | ks_assoc_t * | s | ) |
Destroy a ks_assoc_t, freeing all memory used by it.
| s | a poingter to the ks_assoc_t to be destroyed |
Definition at line 251 of file ks_assoc.c.
References ks_assoc_fini(), and ks_free().
Referenced by ks_response_free().
| ks_base_t* ks_assoc_get | ( | ks_assoc_t * | s, | |
| const char * | key, | |||
| size_t | len | |||
| ) |
Retrieve the data associated with a given key from a ks_assoc_t.
| s | a pointer to the ks_asssoc_t to be searched | |
| key | the hte key to search the ks_assoc_t for | |
| len | the length of the key string |
Definition at line 319 of file ks_assoc.c.
References _ks_bucket_t::data.
Referenced by ks_combination_data(), ks_combination_score(), ks_fact_data(), ks_fact_feed(), ks_fact_identity(), ks_fact_value(), ks_response_combination(), ks_response_combinations(), ks_response_error(), ks_response_id(), ks_response_message(), and ks_response_time().
| void ks_assoc_init | ( | ks_assoc_t * | s | ) |
Initialise a ks_assoc_t. This will have been done for you by ks_assoc_new() for each new ks_assoc_t. If you need to reinitialise a ks_assoc_t, then you should first clear its state using ks_assoc_fini(), or your application could leak memory.
| s | a pointer to the ks_assoc_t to be initialised |
Definition at line 210 of file ks_assoc.c.
References _ks_assoc_t::array, _ks_assoc_t::base, ks_array_init(), and _ks_base_t::type.
Referenced by ks_assoc_new().
| ks_array_t* ks_assoc_keys | ( | ks_assoc_t * | s | ) |
Return the list of keys stored in a ks_assoc_t
| s | a pointer to the ks_assoc_t whose keys are to be returned |
Definition at line 350 of file ks_assoc.c.
References _ks_assoc_t::array, _ks_bucket_t::key, _ks_bucket_t::klen, ks_array_add(), ks_array_get(), ks_array_length(), ks_array_new(), KS_CAST, and ks_string_new().
| ks_assoc_t* ks_assoc_new | ( | void | ) |
Create a new, initialised ks_assoc_t.
Definition at line 222 of file ks_assoc.c.
References ks_assoc_init(), and ks_malloc().
| void ks_assoc_put | ( | ks_assoc_t * | s, | |
| const char * | key, | |||
| size_t | len, | |||
| ks_base_t * | ptr | |||
| ) |
Put new data in a ks_assoc_t, and associate it with a given key. If the key already exists, the existing data associated with that key is destroyed and the new data inserted in its place, otherwise a new bucket is created for the key and data.
| s | a pointer to the ks_assoc_t into which the data is to be put | |
| key | a string with which the data is to be associated | |
| len | the length of the key string | |
| ptr | a spointer to the data to be put in the ks_assoc_t |
Definition at line 295 of file ks_assoc.c.
References _ks_assoc_t::array, _ks_bucket_t::data, and ks_array_add().
Referenced by ks_fact_feed().
| int ks_assoc_size | ( | ks_assoc_t * | s | ) |
Find the number of entries in a ks_assoc_t
| s | a pointer to the ks_assoc_t whose size is to be determined |
Definition at line 335 of file ks_assoc.c.
References _ks_assoc_t::array, and ks_array_length().
Referenced by ks_response_combinations_size().
| ks_type_t* ks_assoc_type | ( | void | ) |
Retrieve the metaclass for ks_assoc_t objects.
Definition at line 172 of file ks_assoc.c.
Referenced by ks_response_bparse().
1.5.1