Azure IoT / azure_c_shared_utility

Dependents:   STM32F746_iothub_client_sample_mqtt f767zi_mqtt iothub_client_sample_amqp iothub_client_sample_http ... more

Committer:
AzureIoTClient
Date:
Mon Sep 25 13:39:31 2017 -0700
Revision:
33:810f9cff537a
Parent:
2:20b88da3e604
Child:
48:81866008bba4
1.1.24

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Azure.IoT Build 0:fa2de1b79154 1 // Copyright (c) Microsoft. All rights reserved.
Azure.IoT Build 0:fa2de1b79154 2 // Licensed under the MIT license. See LICENSE file in the project root for full license information.
Azure.IoT Build 0:fa2de1b79154 3
Azure.IoT Build 0:fa2de1b79154 4 /** @file constmap.h
Azure.IoT Build 0:fa2de1b79154 5 * @brief ConstMap is a module that implements a read-only dictionary
Azure.IoT Build 0:fa2de1b79154 6 * of @c const char* keys to @c const char* values.
Azure.IoT Build 0:fa2de1b79154 7 */
Azure.IoT Build 0:fa2de1b79154 8
Azure.IoT Build 0:fa2de1b79154 9 #ifndef CONSTMAP_H
Azure.IoT Build 0:fa2de1b79154 10 #define CONSTMAP_H
Azure.IoT Build 0:fa2de1b79154 11
AzureIoTClient 33:810f9cff537a 12 #include "azure_c_shared_utility/macro_utils.h"
AzureIoTClient 33:810f9cff537a 13 #include "azure_c_shared_utility/crt_abstractions.h"
AzureIoTClient 33:810f9cff537a 14 #include "azure_c_shared_utility/map.h"
AzureIoTClient 33:810f9cff537a 15 #include "azure_c_shared_utility/umock_c_prod.h"
AzureIoTClient 33:810f9cff537a 16
Azure.IoT Build 0:fa2de1b79154 17 #ifdef __cplusplus
Azure.IoT Build 0:fa2de1b79154 18 #include <cstddef>
Azure.IoT Build 0:fa2de1b79154 19 extern "C"
Azure.IoT Build 0:fa2de1b79154 20 {
Azure.IoT Build 0:fa2de1b79154 21 #else
Azure.IoT Build 0:fa2de1b79154 22 #include <stddef.h>
Azure.IoT Build 0:fa2de1b79154 23 #endif
Azure.IoT Build 0:fa2de1b79154 24
Azure.IoT Build 0:fa2de1b79154 25
Azure.IoT Build 0:fa2de1b79154 26 #define CONSTMAP_RESULT_VALUES \
Azure.IoT Build 0:fa2de1b79154 27 CONSTMAP_OK, \
Azure.IoT Build 0:fa2de1b79154 28 CONSTMAP_ERROR, \
Azure.IoT Build 0:fa2de1b79154 29 CONSTMAP_INVALIDARG, \
Azure.IoT Build 0:fa2de1b79154 30 CONSTMAP_KEYNOTFOUND
Azure.IoT Build 0:fa2de1b79154 31
Azure.IoT Build 0:fa2de1b79154 32 /** @brief Enumeration specifying the status of calls to various APIs in this
Azure.IoT Build 0:fa2de1b79154 33 * module.
Azure.IoT Build 0:fa2de1b79154 34 */
Azure.IoT Build 0:fa2de1b79154 35 DEFINE_ENUM(CONSTMAP_RESULT, CONSTMAP_RESULT_VALUES);
Azure.IoT Build 0:fa2de1b79154 36
Azure.IoT Build 0:fa2de1b79154 37 typedef struct CONSTMAP_HANDLE_DATA_TAG* CONSTMAP_HANDLE;
Azure.IoT Build 0:fa2de1b79154 38
Azure.IoT Build 0:fa2de1b79154 39
Azure.IoT Build 0:fa2de1b79154 40 /**
Azure.IoT Build 0:fa2de1b79154 41 * @brief Creates a new read-only map from a map handle.
Azure.IoT Build 0:fa2de1b79154 42 *
Azure.IoT Build 0:fa2de1b79154 43 * @param sourceMap The map from which we will populate key,value
Azure.IoT Build 0:fa2de1b79154 44 * into the read-only map.
Azure.IoT Build 0:fa2de1b79154 45 *
Azure.IoT Build 0:fa2de1b79154 46 * @return A valid @c CONSTMAP_HANDLE or @c NULL in case an error occurs.
Azure.IoT Build 0:fa2de1b79154 47 */
AzureIoTClient 2:20b88da3e604 48 MOCKABLE_FUNCTION(, CONSTMAP_HANDLE, ConstMap_Create, MAP_HANDLE, sourceMap);
Azure.IoT Build 0:fa2de1b79154 49
Azure.IoT Build 0:fa2de1b79154 50 /**
Azure.IoT Build 0:fa2de1b79154 51 * @brief Destroy a read-only map. Deallocate memory associated with handle.
Azure.IoT Build 0:fa2de1b79154 52 * @param handle Handle to a read-only map.
Azure.IoT Build 0:fa2de1b79154 53 */
AzureIoTClient 2:20b88da3e604 54 MOCKABLE_FUNCTION(, void, ConstMap_Destroy, CONSTMAP_HANDLE, handle);
Azure.IoT Build 0:fa2de1b79154 55
Azure.IoT Build 0:fa2de1b79154 56 /**
Azure.IoT Build 0:fa2de1b79154 57 * @brief Clone a read-only map from another read-only map.
Azure.IoT Build 0:fa2de1b79154 58 * @param handle Handle to a read-only map.
Azure.IoT Build 0:fa2de1b79154 59 * @return A valid @c CONSTMAP_HANDLE or @c NULL in case an error occurs.
Azure.IoT Build 0:fa2de1b79154 60 */
AzureIoTClient 2:20b88da3e604 61 MOCKABLE_FUNCTION(, CONSTMAP_HANDLE, ConstMap_Clone, CONSTMAP_HANDLE, handle);
Azure.IoT Build 0:fa2de1b79154 62
Azure.IoT Build 0:fa2de1b79154 63 /**
Azure.IoT Build 0:fa2de1b79154 64 * @brief Create a map handle populated from the read-only map.
Azure.IoT Build 0:fa2de1b79154 65 * @param handle Handle to a read-only map.
Azure.IoT Build 0:fa2de1b79154 66 * @return A valid @c MAP_HANDLE or @c NULL in case an error occurs.
Azure.IoT Build 0:fa2de1b79154 67 *
Azure.IoT Build 0:fa2de1b79154 68 * The new MAP_HANDLE needs to be destroyed when it is no longer needed.
Azure.IoT Build 0:fa2de1b79154 69 */
AzureIoTClient 2:20b88da3e604 70 MOCKABLE_FUNCTION(, MAP_HANDLE, ConstMap_CloneWriteable, CONSTMAP_HANDLE, handle);
Azure.IoT Build 0:fa2de1b79154 71
Azure.IoT Build 0:fa2de1b79154 72 /**
Azure.IoT Build 0:fa2de1b79154 73 * @brief This function returns a true if the map contains a key
Azure.IoT Build 0:fa2de1b79154 74 * with the same value the parameter @p key.
Azure.IoT Build 0:fa2de1b79154 75 *
Azure.IoT Build 0:fa2de1b79154 76 * @param handle The handle to an existing map.
Azure.IoT Build 0:fa2de1b79154 77 * @param key The key that the caller wants checked.
Azure.IoT Build 0:fa2de1b79154 78 *
Azure.IoT Build 0:fa2de1b79154 79 * @return The function returns @c true if the key exists
Azure.IoT Build 0:fa2de1b79154 80 * in the map and @c false if key is not found or
Azure.IoT Build 0:fa2de1b79154 81 * parameters are invalid.
Azure.IoT Build 0:fa2de1b79154 82 */
AzureIoTClient 2:20b88da3e604 83 MOCKABLE_FUNCTION(, bool, ConstMap_ContainsKey, CONSTMAP_HANDLE, handle, const char*, key);
Azure.IoT Build 0:fa2de1b79154 84
Azure.IoT Build 0:fa2de1b79154 85 /**
Azure.IoT Build 0:fa2de1b79154 86 * @brief This function returns @c true if at least one <key,value> pair
Azure.IoT Build 0:fa2de1b79154 87 * exists in the map where the entry's value is equal to the
Azure.IoT Build 0:fa2de1b79154 88 * parameter @c value.
Azure.IoT Build 0:fa2de1b79154 89 *
Azure.IoT Build 0:fa2de1b79154 90 * @param handle The handle to an existing map.
Azure.IoT Build 0:fa2de1b79154 91 * @param value The value that the caller wants checked.
Azure.IoT Build 0:fa2de1b79154 92 *
Azure.IoT Build 0:fa2de1b79154 93 * @return The function returns @c true if the value exists
Azure.IoT Build 0:fa2de1b79154 94 * in the map and @c false if value is not found or
Azure.IoT Build 0:fa2de1b79154 95 * parameters are invalid.
Azure.IoT Build 0:fa2de1b79154 96 */
AzureIoTClient 2:20b88da3e604 97 MOCKABLE_FUNCTION(, bool, ConstMap_ContainsValue, CONSTMAP_HANDLE, handle, const char*, value);
Azure.IoT Build 0:fa2de1b79154 98
Azure.IoT Build 0:fa2de1b79154 99 /**
Azure.IoT Build 0:fa2de1b79154 100 * @brief Retrieves the value of a stored key.
Azure.IoT Build 0:fa2de1b79154 101 *
Azure.IoT Build 0:fa2de1b79154 102 * @param handle The handle to an existing map.
Azure.IoT Build 0:fa2de1b79154 103 * @param key The key to be looked up in the map.
Azure.IoT Build 0:fa2de1b79154 104 *
Azure.IoT Build 0:fa2de1b79154 105 * @return Returns @c NULL in case the input arguments are @c NULL or if the
Azure.IoT Build 0:fa2de1b79154 106 * requested key is not found in the map. Returns a pointer to the
Azure.IoT Build 0:fa2de1b79154 107 * key's value otherwise.
Azure.IoT Build 0:fa2de1b79154 108 */
AzureIoTClient 2:20b88da3e604 109 MOCKABLE_FUNCTION(, const char*, ConstMap_GetValue, CONSTMAP_HANDLE, handle, const char*, key);
Azure.IoT Build 0:fa2de1b79154 110
Azure.IoT Build 0:fa2de1b79154 111 /**
Azure.IoT Build 0:fa2de1b79154 112 * @brief Retrieves the complete list of keys and values from the map
Azure.IoT Build 0:fa2de1b79154 113 * in @p values and @p keys. Also writes the size of the list
Azure.IoT Build 0:fa2de1b79154 114 * in @p count.
Azure.IoT Build 0:fa2de1b79154 115 *
Azure.IoT Build 0:fa2de1b79154 116 * @param handle The handle to an existing map.
Azure.IoT Build 0:fa2de1b79154 117 * @param keys The location where the list of keys is to be written.
Azure.IoT Build 0:fa2de1b79154 118 * @param values The location where the list of values is to be written.
Azure.IoT Build 0:fa2de1b79154 119 * @param count The number of stored keys and values is written at the
Azure.IoT Build 0:fa2de1b79154 120 * location indicated by this pointer.
Azure.IoT Build 0:fa2de1b79154 121 *
Azure.IoT Build 0:fa2de1b79154 122 * @return Returns @c CONSTMAP_OK if the keys and values are retrieved
Azure.IoT Build 0:fa2de1b79154 123 * and written successfully or an error code otherwise.
Azure.IoT Build 0:fa2de1b79154 124 */
AzureIoTClient 2:20b88da3e604 125 MOCKABLE_FUNCTION(, CONSTMAP_RESULT, ConstMap_GetInternals, CONSTMAP_HANDLE, handle, const char*const**, keys, const char*const**, values, size_t*, count);
Azure.IoT Build 0:fa2de1b79154 126
Azure.IoT Build 0:fa2de1b79154 127
Azure.IoT Build 0:fa2de1b79154 128 #ifdef __cplusplus
Azure.IoT Build 0:fa2de1b79154 129 }
Azure.IoT Build 0:fa2de1b79154 130 #endif
Azure.IoT Build 0:fa2de1b79154 131
Azure.IoT Build 0:fa2de1b79154 132 #endif /* CONSTMAP_H */