libcomps  ..
Functions
comps dictionary functions

Functions

void comps_objdict_set (COMPS_ObjDict *rt, char *key, COMPS_Object *data)
 
void comps_objdict_set_x (COMPS_ObjDict *rt, char *key, COMPS_Object *data)
 
void comps_objdict_set_n (COMPS_ObjDict *rt, char *key, unsigned int len, COMPS_Object *data)
 
COMPS_Objectcomps_objdict_get (COMPS_ObjDict *rt, const char *key)
 
COMPS_Objectcomps_objdict_get_x (COMPS_ObjRTree *rt, const char *key)
 
void comps_objdict_unset (COMPS_ObjDict *rt, const char *key)
 
void comps_objdict_clear (COMPS_ObjDict *rt)
 
COMPS_HSList * comps_objdict_values (COMPS_ObjDict *rt)
 
void comps_objdict_values_walk (COMPS_ObjRTree *rt, void *udata, void(*walk_f)(void *, COMPS_Object *))
 
COMPS_ObjDict * comps_objdict_clone (COMPS_ObjDict *rt)
 
COMPS_HSList * comps_objdict_keys (COMPS_ObjDict *rt)
 
COMPS_HSList * comps_objdict_pairs (COMPS_ObjDict *rt)
 
COMPS_ObjDict * comps_objdict_union (COMPS_ObjDict *d1, COMPS_ObjDict *d2)
 

Detailed Description

Function Documentation

void comps_objdict_clear ( COMPS_ObjDict *  rt)

remove all items from dictionary

Parameters
rtCOMPS_ObjDict object
COMPS_ObjDict* comps_objdict_clone ( COMPS_ObjDict *  rt)

Makes copy of dictionary

Items in new dictionary is same items with incremented reference counter only

Parameters
rtCOMPS_ObjDict object
Returns
new COMPS_ObjDict object
COMPS_Object* comps_objdict_get ( COMPS_ObjDict *  rt,
const char *  key 
)

get item from dictionary for specified key

if there's no such item, return NULL. Item's reference counter will be incremented.

Parameters
rtCOMPS_ObjDict object
specifiedkey
Returns
item for key
COMPS_Object* comps_objdict_get_x ( COMPS_ObjRTree *  rt,
const char *  key 
)

get item from dictionary for specified key

if there's no such item, return NULL. Item's reference counter WON'T be incremented.

Parameters
rtCOMPS_ObjDict object
specifiedkey
Returns
item for key
COMPS_HSList* comps_objdict_keys ( COMPS_ObjDict *  rt)

Return list of keys in dictionary

Parameters
rtCOMPS_ObjDict object
Returns
COMPS_HSList of key in dictionary
COMPS_HSList* comps_objdict_pairs ( COMPS_ObjDict *  rt)

Return list of pairs(key-value) in dictionary

Parameters
rtCOMPS_ObjDict object
Returns
COMPS_HSList of pairs in dictionary
void comps_objdict_set ( COMPS_ObjDict *  rt,
char *  key,
COMPS_Object data 
)

set new item to dictionary

if there's already item for specified key in dictionary, old item will be replaced with new item and its reference counter will be decremented. Reference counter of new item will be incremented

Parameters
rtCOMPS_ObjDict object
keykey for new item
datanew item
void comps_objdict_set_n ( COMPS_ObjDict *  rt,
char *  key,
unsigned int  len,
COMPS_Object data 
)

same as comps_objdict_set but with key length limited by argument

Parameters
rtCOMPS_ObjDict object
keykey for new item
lenkey length limiter
datanew item
void comps_objdict_set_x ( COMPS_ObjDict *  rt,
char *  key,
COMPS_Object data 
)

set new item to dictionary

if there's already item for specified key in dictionary, old item will be replaced with new item and its reference counter will be decremented. Reference counter of new items won't be incremented

Parameters
rtCOMPS_ObjDict object
keykey for new item
datanew item
COMPS_ObjDict* comps_objdict_union ( COMPS_ObjDict *  d1,
COMPS_ObjDict *  d2 
)

Join two dictionries into one

New dictionary is filled with pairs of first dictionary and then with pairs of second dictionary with skipped items whose keys are already in dictionary

Parameters
d1COMPS_ObjDict object
d2COMPS_ObjDict object
Returns
new COMPS_ObjDict object
void comps_objdict_unset ( COMPS_ObjDict *  rt,
const char *  key 
)

remove item from dictionary for specified key

item's reference counter will be decremented

Parameters
rtCOMPS_ObjDict object
keyitem's key
COMPS_HSList* comps_objdict_values ( COMPS_ObjDict *  rt)

Return list of all values(items) in dictionary

Parameters
rtCOMPS_ObjDict objecti
Returns
COMPS_HSList of values
void comps_objdict_values_walk ( COMPS_ObjRTree *  rt,
void *  udata,
void(*)(void *, COMPS_Object *)  walk_f 
)

Apply function for each item in dictionary

Applied function takes user data (udata param) and item as arguments

Parameters
rtCOMPS_ObjDict object
udatauser data
walk_fapplied function