C Configuration Space and Tuning Library (CCS)
Loading...
Searching...
No Matches
Functions
map.h File Reference

CCS map defines a key-value store. More...

This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

ccs_result_t ccs_create_map (ccs_map_t *map_ret)
 Create a new map.
 
ccs_result_t ccs_map_set (ccs_map_t map, ccs_datum_t key, ccs_datum_t value)
 Associate a key to a value in a map.
 
ccs_result_t ccs_map_exist (ccs_map_t map, ccs_datum_t key, ccs_bool_t *exist)
 Check if a key exists in a map.
 
ccs_result_t ccs_map_get (ccs_map_t map, ccs_datum_t key, ccs_datum_t *value_ret)
 Get the value associated with a key.
 
ccs_result_t ccs_map_del (ccs_map_t map, ccs_datum_t key)
 Delete a key in a map.
 
ccs_result_t ccs_map_get_keys (ccs_map_t map, size_t num_keys, ccs_datum_t *keys, size_t *num_keys_ret)
 Get the keys contained in a map.
 
ccs_result_t ccs_map_get_values (ccs_map_t map, size_t num_values, ccs_datum_t *values, size_t *num_values_ret)
 Get the values contained in a map.
 
ccs_result_t ccs_map_get_pairs (ccs_map_t map, size_t num_pairs, ccs_datum_t *keys, ccs_datum_t *values, size_t *num_pairs_ret)
 Get the keys and values contained in a map.
 
ccs_result_t ccs_map_clear (ccs_map_t map)
 Remove all pairs from a map.
 

Detailed Description

CCS map defines a key-value store.

Function Documentation

◆ ccs_create_map()

ccs_result_t ccs_create_map ( ccs_map_t map_ret)
extern

Create a new map.

Parameters
[out]map_reta pointer to the variable that will contain the returned map
Returns
CCS_RESULT_SUCCESS on success
CCS_RESULT_ERROR_INVALID_VALUE if map_ret is NULL
CCS_RESULT_ERROR_OUT_OF_MEMORY if there was not enough memory to allocate the new map
Remarks
This function is thread-safe

◆ ccs_map_clear()

ccs_result_t ccs_map_clear ( ccs_map_t  map)
extern

Remove all pairs from a map.

Parameters
[in,out]map
Returns
CCS_RESULT_SUCCESS on success
CCS_RESULT_ERROR_INVALID_OBJECT if map is not a valid CCS map
Remarks
This function is thread-safe

◆ ccs_map_del()

ccs_result_t ccs_map_del ( ccs_map_t  map,
ccs_datum_t  key 
)
extern

Delete a key in a map.

Parameters
[in,out]map
[in]key
Returns
CCS_RESULT_SUCCESS on success
CCS_RESULT_ERROR_INVALID_OBJECT if map is not a valid CCS map
CCS_RESULT_ERROR_INVALID_VALUE if key does not exist in map
Remarks
This function is thread-safe

◆ ccs_map_exist()

ccs_result_t ccs_map_exist ( ccs_map_t  map,
ccs_datum_t  key,
ccs_bool_t exist 
)
extern

Check if a key exists in a map.

Parameters
[in]map
[in]key
[out]exista pointer to a variable that will hold the result of the search
Returns
CCS_RESULT_SUCCESS on success
CCS_RESULT_ERROR_INVALID_OBJECT if map is not a valid CCS map
CCS_RESULT_ERROR_INVALID_VALUE if exist is NULL
Remarks
This function is thread-safe

◆ ccs_map_get()

ccs_result_t ccs_map_get ( ccs_map_t  map,
ccs_datum_t  key,
ccs_datum_t value_ret 
)
extern

Get the value associated with a key.

Parameters
[in]map
[in]key
[out]value_reta pointer to a variable that will hold the returned value or ccs_none if not found
Returns
CCS_RESULT_SUCCESS on success
CCS_RESULT_ERROR_INVALID_OBJECT if map is not a valid CCS map
CCS_RESULT_ERROR_INVALID_VALUE if value_ret is NULL
Remarks
This function is thread-safe

◆ ccs_map_get_keys()

ccs_result_t ccs_map_get_keys ( ccs_map_t  map,
size_t  num_keys,
ccs_datum_t keys,
size_t *  num_keys_ret 
)
extern

Get the keys contained in a map.

Parameters
[in]map
[in]num_keysthe number of keys that can be added to keys. If keys is not NULL, num_keys must be greater than 0
[out]keysan array of num_keys ccs_datum_t that will contain the returned keys of NULL. If the array is too big, extra values will be set to ccs_none
[out]num_keys_reta pointer to a variable that will contain the number of keys that are or would be returned. Can be NULL
Returns
CCS_RESULT_SUCCESS on success
CCS_RESULT_ERROR_INVALID_OBJECT if map is not a valid CCS map
CCS_RESULT_ERROR_INVALID_VALUE if keys is NULL and num_keys is greater than 0; or if keys is NULL and num_keys_ret is NULL; or if num_keys is less than the number of keys that would be returned
Remarks
This function is thread-safe

◆ ccs_map_get_pairs()

ccs_result_t ccs_map_get_pairs ( ccs_map_t  map,
size_t  num_pairs,
ccs_datum_t keys,
ccs_datum_t values,
size_t *  num_pairs_ret 
)
extern

Get the keys and values contained in a map.

Parameters
[in]map
[in]num_pairsthe number of keys that can be added to keys. If keys is not NULL, num_pairs must be greater than 0
[out]keysan array of num_pairs ccs_datum_t that will contain the returned keys of NULL. If the array is too big, extra values will be set to ccs_none
[out]valuesan array of num_pairs ccs_datum_t that will contain the returned values of NULL. If the array is too big, extra values will be set to ccs_none
[out]num_pairs_reta pointer to a variable that will contain the number of keys that are or would be returned. Can be NULL
Returns
CCS_RESULT_SUCCESS on success
CCS_RESULT_ERROR_INVALID_OBJECT if map is not a valid CCS map
CCS_RESULT_ERROR_INVALID_VALUE if keys is NULL and num_pairs is greater than 0; or if keys is NULL and num_pairs_ret is NULL; or if num_pairs is less than the number of values that would be returned; if values is NULL and num_pairs is greater than 0; or if values is NULL and num_pairs_ret is NULL; or if num_pairs is less than the number of values that would be returned
Remarks
This function is thread-safe

◆ ccs_map_get_values()

ccs_result_t ccs_map_get_values ( ccs_map_t  map,
size_t  num_values,
ccs_datum_t values,
size_t *  num_values_ret 
)
extern

Get the values contained in a map.

Parameters
[in]map
[in]num_valuesthe number of values that can be added to values. If values is not NULL, num_values must be greater than 0
[out]valuesan array of num_values ccs_datum_t that will contain the returned values of NULL. If the array is too big, extra values will be set to ccs_none
[out]num_values_reta pointer to a variable that will contain the number of values that are or would be returned. Can be NULL
Returns
CCS_RESULT_SUCCESS on success
CCS_RESULT_ERROR_INVALID_OBJECT if map is not a valid CCS map
CCS_RESULT_ERROR_INVALID_VALUE if values is NULL and num_values is greater than 0; or if values is NULL and num_values_ret is NULL; or if num_values is less than the number of values that would be returned
Remarks
This function is thread-safe

◆ ccs_map_set()

ccs_result_t ccs_map_set ( ccs_map_t  map,
ccs_datum_t  key,
ccs_datum_t  value 
)
extern

Associate a key to a value in a map.

Parameters
[in,out]map
[in]keyif a transient string it will be memoized, if a CCS object it will be retained unless CCS_DATUM_FLAG_ID is used.
[in]valueif a transient string it will be memoized, if a CCS object it will be retained unless CCS_DATUM_FLAG_ID is used.
Returns
CCS_RESULT_SUCCESS on success
CCS_RESULT_ERROR_INVALID_OBJECT if map is not a valid CCS map
CCS_RESULT_ERROR_OUT_OF_MEMORY if there was not enough memory to allocate data structures
Remarks
This function is thread-safe