Nigel Rantor / azure_c_shared_utility

Fork of azure_c_shared_utility by Azure IoT

Embed: (wiki syntax)

« Back to documentation index

constmap.h File Reference

constmap.h File Reference

ConstMap is a module that implements a read-only dictionary of const char* keys to const char* values. More...

Go to the source code of this file.

Functions

 DEFINE_ENUM (CONSTMAP_RESULT, CONSTMAP_RESULT_VALUES)
 Enumeration specifying the status of calls to various APIs in this module.
 MOCKABLE_FUNCTION (, CONSTMAP_HANDLE, ConstMap_Create, MAP_HANDLE, sourceMap)
 Creates a new read-only map from a map handle.
 MOCKABLE_FUNCTION (, void, ConstMap_Destroy, CONSTMAP_HANDLE, handle)
 Destroy a read-only map.
 MOCKABLE_FUNCTION (, CONSTMAP_HANDLE, ConstMap_Clone, CONSTMAP_HANDLE, handle)
 Clone a read-only map from another read-only map.
 MOCKABLE_FUNCTION (, MAP_HANDLE, ConstMap_CloneWriteable, CONSTMAP_HANDLE, handle)
 Create a map handle populated from the read-only map.
 MOCKABLE_FUNCTION (, bool, ConstMap_ContainsKey, CONSTMAP_HANDLE, handle, const char *, key)
 This function returns a true if the map contains a key with the same value the parameter key.
 MOCKABLE_FUNCTION (, bool, ConstMap_ContainsValue, CONSTMAP_HANDLE, handle, const char *, value)
 This function returns true if at least one <key,value> pair exists in the map where the entry's value is equal to the parameter value.
 MOCKABLE_FUNCTION (, const char *, ConstMap_GetValue, CONSTMAP_HANDLE, handle, const char *, key)
 Retrieves the value of a stored key.
 MOCKABLE_FUNCTION (, CONSTMAP_RESULT, ConstMap_GetInternals, CONSTMAP_HANDLE, handle, const char *const **, keys, const char *const **, values, size_t *, count)
 Retrieves the complete list of keys and values from the map in values and keys.

Detailed Description

ConstMap is a module that implements a read-only dictionary of const char* keys to const char* values.

Definition in file constmap.h.


Function Documentation

DEFINE_ENUM ( CONSTMAP_RESULT  ,
CONSTMAP_RESULT_VALUES   
)

Enumeration specifying the status of calls to various APIs in this module.

MOCKABLE_FUNCTION ( CONSTMAP_RESULT  ,
ConstMap_GetInternals  ,
CONSTMAP_HANDLE  ,
handle  ,
const char *const **  ,
keys  ,
const char *const **  ,
values  ,
size_t *  ,
count   
)

Retrieves the complete list of keys and values from the map in values and keys.

Also writes the size of the list in count.

Parameters:
handleThe handle to an existing map.
keysThe location where the list of keys is to be written.
valuesThe location where the list of values is to be written.
countThe number of stored keys and values is written at the location indicated by this pointer.
Returns:
Returns CONSTMAP_OK if the keys and values are retrieved and written successfully or an error code otherwise.
MOCKABLE_FUNCTION ( const char *  ,
ConstMap_GetValue  ,
CONSTMAP_HANDLE  ,
handle  ,
const char *  ,
key   
)

Retrieves the value of a stored key.

Parameters:
handleThe handle to an existing map.
keyThe key to be looked up in the map.
Returns:
Returns NULL in case the input arguments are NULL or if the requested key is not found in the map. Returns a pointer to the key's value otherwise.
MOCKABLE_FUNCTION ( bool  ,
ConstMap_ContainsValue  ,
CONSTMAP_HANDLE  ,
handle  ,
const char *  ,
value   
)

This function returns true if at least one <key,value> pair exists in the map where the entry's value is equal to the parameter value.

Parameters:
handleThe handle to an existing map.
valueThe value that the caller wants checked.
Returns:
The function returns true if the value exists in the map and false if value is not found or parameters are invalid.
MOCKABLE_FUNCTION ( bool  ,
ConstMap_ContainsKey  ,
CONSTMAP_HANDLE  ,
handle  ,
const char *  ,
key   
)

This function returns a true if the map contains a key with the same value the parameter key.

Parameters:
handleThe handle to an existing map.
keyThe key that the caller wants checked.
Returns:
The function returns true if the key exists in the map and false if key is not found or parameters are invalid.
MOCKABLE_FUNCTION ( MAP_HANDLE  ,
ConstMap_CloneWriteable  ,
CONSTMAP_HANDLE  ,
handle   
)

Create a map handle populated from the read-only map.

Parameters:
handleHandle to a read-only map.
Returns:
A valid MAP_HANDLE or NULL in case an error occurs.

The new MAP_HANDLE needs to be destroyed when it is no longer needed.

MOCKABLE_FUNCTION ( CONSTMAP_HANDLE  ,
ConstMap_Clone  ,
CONSTMAP_HANDLE  ,
handle   
)

Clone a read-only map from another read-only map.

Parameters:
handleHandle to a read-only map.
Returns:
A valid CONSTMAP_HANDLE or NULL in case an error occurs.
MOCKABLE_FUNCTION ( void  ,
ConstMap_Destroy  ,
CONSTMAP_HANDLE  ,
handle   
)

Destroy a read-only map.

Deallocate memory associated with handle.

Parameters:
handleHandle to a read-only map.
MOCKABLE_FUNCTION ( CONSTMAP_HANDLE  ,
ConstMap_Create  ,
MAP_HANDLE  ,
sourceMap   
)

Creates a new read-only map from a map handle.

Parameters:
sourceMapThe map from which we will populate key,value into the read-only map.
Returns:
A valid CONSTMAP_HANDLE or NULL in case an error occurs.