Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: azure_umqtt_c iothub_mqtt_transport mbed-rtos mbed wolfSSL Socket lwip-eth lwip-sys lwip
map.h File Reference
Map is a module that implements a dictionary of STRING_HANDLE keys to STRING_HANDLE values.
More...
Go to the source code of this file.
Functions | |
| DEFINE_ENUM (MAP_RESULT, MAP_RESULT_VALUES) | |
| Enumeration specifying the status of calls to various APIs in this module. | |
| MOCKABLE_FUNCTION (, MAP_HANDLE, Map_Create, MAP_FILTER_CALLBACK, mapFilterFunc) | |
| Creates a new, empty map. | |
| MOCKABLE_FUNCTION (, void, Map_Destroy, MAP_HANDLE, handle) | |
| Release all resources associated with the map. | |
| MOCKABLE_FUNCTION (, MAP_HANDLE, Map_Clone, MAP_HANDLE, handle) | |
Creates a copy of the map indicated by handle and returns a handle to it. | |
| MOCKABLE_FUNCTION (, MAP_RESULT, Map_Add, MAP_HANDLE, handle, const char *, key, const char *, value) | |
| Adds a key/value pair to the map. | |
| MOCKABLE_FUNCTION (, MAP_RESULT, Map_AddOrUpdate, MAP_HANDLE, handle, const char *, key, const char *, value) | |
| Adds/updates a key/value pair to the map. | |
| MOCKABLE_FUNCTION (, MAP_RESULT, Map_Delete, MAP_HANDLE, handle, const char *, key) | |
| Removes a key and its associated value from the map. | |
| MOCKABLE_FUNCTION (, MAP_RESULT, Map_ContainsKey, MAP_HANDLE, handle, const char *, key, bool *, keyExists) | |
This function returns a boolean value in keyExists if the map contains a key with the same value the parameter key. | |
| MOCKABLE_FUNCTION (, MAP_RESULT, Map_ContainsValue, MAP_HANDLE, handle, const char *, value, bool *, valueExists) | |
This function returns true in valueExists 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 *, Map_GetValueFromKey, MAP_HANDLE, handle, const char *, key) | |
| Retrieves the value of a stored key. | |
| MOCKABLE_FUNCTION (, MAP_RESULT, Map_GetInternals, MAP_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
Map is a module that implements a dictionary of STRING_HANDLE keys to STRING_HANDLE values.
Definition in file map.h.
Function Documentation
| DEFINE_ENUM | ( | MAP_RESULT | , |
| MAP_RESULT_VALUES | |||
| ) |
Enumeration specifying the status of calls to various APIs in this module.
| MOCKABLE_FUNCTION | ( | MAP_RESULT | , |
| Map_GetInternals | , | ||
| MAP_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:
-
handle The handle to an existing map. keys The location where the list of keys is to be written. values The location where the list of values is to be written. count The number of stored keys and values is written at the location indicated by this pointer.
- Returns:
- Returns
MAP_OKif the keys and values are retrieved and written successfully or an error code otherwise.
| MOCKABLE_FUNCTION | ( | const char * | , |
| Map_GetValueFromKey | , | ||
| MAP_HANDLE | , | ||
| handle | , | ||
| const char * | , | ||
| key | |||
| ) |
Retrieves the value of a stored key.
- Parameters:
-
handle The handle to an existing map. key The key to be looked up in the map.
- Returns:
- Returns
NULLin case the input arguments areNULLor if the requested key is not found in the map. Returns a pointer to the key's value otherwise.
| MOCKABLE_FUNCTION | ( | MAP_RESULT | , |
| Map_ContainsValue | , | ||
| MAP_HANDLE | , | ||
| handle | , | ||
| const char * | , | ||
| value | , | ||
| bool * | , | ||
| valueExists | |||
| ) |
This function returns true in valueExists if at least one <key,value> pair exists in the map where the entry's value is equal to the parameter value.
- Parameters:
-
handle The handle to an existing map. value The value that the caller wants checked. valueExists The function writes trueat the address pointed at by this parameter if the value exists in the map andfalseotherwise.
- Returns:
- Returns
MAP_OKif the check was performed successfully or an error code otherwise.
| MOCKABLE_FUNCTION | ( | MAP_RESULT | , |
| Map_ContainsKey | , | ||
| MAP_HANDLE | , | ||
| handle | , | ||
| const char * | , | ||
| key | , | ||
| bool * | , | ||
| keyExists | |||
| ) |
This function returns a boolean value in keyExists if the map contains a key with the same value the parameter key.
- Parameters:
-
handle The handle to an existing map. key The key that the caller wants checked. keyExists The function writes trueat the address pointed at by this parameter if the key exists in the map andfalseotherwise.
- Returns:
- Returns
MAP_OKif the check was performed successfully or an error code otherwise.
| MOCKABLE_FUNCTION | ( | MAP_RESULT | , |
| Map_Delete | , | ||
| MAP_HANDLE | , | ||
| handle | , | ||
| const char * | , | ||
| key | |||
| ) |
Removes a key and its associated value from the map.
- Parameters:
-
handle The handle to an existing map. key The keyof the item to be deleted.
- Returns:
- Returns
MAP_OKif the key was deleted successfully or an error code otherwise.
| MOCKABLE_FUNCTION | ( | MAP_RESULT | , |
| Map_AddOrUpdate | , | ||
| MAP_HANDLE | , | ||
| handle | , | ||
| const char * | , | ||
| key | , | ||
| const char * | , | ||
| value | |||
| ) |
Adds/updates a key/value pair to the map.
- Parameters:
-
handle The handle to an existing map. key The keyto be used for this map entry.value The valueto be associated withkey.
This function behaves exactly like Map_Add except that if the key already exists in the map then it overwrites the value with the supplied value instead of returning an error. If a non-NULL pointer to a callback function was supplied via the mapFilterFunc parameter when Map_Create was called then that callback is invoked when a new entry is added or when an existing entry is updated and if the callback returns a non-zero value then the function cancels the add/update operation and returns MAP_FILTER_REJECT.
- Returns:
- If any of the input parameters are
NULLthen this function returnsMAP_INVALID_ARG. If the filter function associated with the map rejects the entry thenMAP_FILTER_REJECTis returned. In case an error occurs when the new key is added/updated in the map the function returnsMAP_ERROR. If everything goes well thenMAP_OKis returned.
| MOCKABLE_FUNCTION | ( | MAP_RESULT | , |
| Map_Add | , | ||
| MAP_HANDLE | , | ||
| handle | , | ||
| const char * | , | ||
| key | , | ||
| const char * | , | ||
| value | |||
| ) |
Adds a key/value pair to the map.
- Parameters:
-
handle The handle to an existing map. key The keyto be used for this map entry.value The valueto be associated withkey.
If a non-NULL pointer to a callback function was supplied via the mapFilterFunc parameter when Map_Create was called then that callback is invoked when a new entry is added and if the callback returns a non-zero value then the function cancels the add operation and returns MAP_FILTER_REJECT.
- Returns:
- If any of the input parameters are
NULLthen this function returnsMAP_INVALID_ARG. If the key already exists in the map thenMAP_KEYEXISTSis returned. If the filter function associated with the map rejects the entry thenMAP_FILTER_REJECTis returned. In case an error occurs when the new key is added to the map the function returnsMAP_ERROR. If everything goes well thenMAP_OKis returned.
| MOCKABLE_FUNCTION | ( | MAP_HANDLE | , |
| Map_Clone | , | ||
| MAP_HANDLE | , | ||
| handle | |||
| ) |
Creates a copy of the map indicated by handle and returns a handle to it.
- Parameters:
-
handle The handle to an existing map.
- Returns:
- A valid
MAP_HANDLEto the cloned copy of the map orNULLin case an error occurs.
| MOCKABLE_FUNCTION | ( | void | , |
| Map_Destroy | , | ||
| MAP_HANDLE | , | ||
| handle | |||
| ) |
Release all resources associated with the map.
- Parameters:
-
handle The handle to an existing map.
| MOCKABLE_FUNCTION | ( | MAP_HANDLE | , |
| Map_Create | , | ||
| MAP_FILTER_CALLBACK | , | ||
| mapFilterFunc | |||
| ) |
Creates a new, empty map.
- Parameters:
-
mapFilterFunc A callback function supplied by the caller that is invoked during calls to Map_Add and Map_AddOrUpdate to provide the caller an opportunity to indicate whether the new entry or the update to an existing entry can be made or not. The callback function can request that the operation be canceled by returning a non-zero value from the callback.
- Returns:
- A valid
MAP_HANDLEorNULLin case an error occurs.
Generated on Wed Jul 13 2022 07:19:04 by
1.7.2