A modelling and serializer library for Microsoft Azure IoTHub client applications

Dependents:   sht15_remote_monitoring f767zi_mqtt remote_monitoring simplesample_amqp ... more

This library implements a serializer library to be used in projects involving Microsoft Azure IoT Hub connectivity. The code is replicated from https://github.com/Azure/azure-iot-sdks

Committer:
AzureIoTClient
Date:
Thu Oct 22 18:33:28 2015 -0700
Revision:
4:233dd7616d73
Child:
10:c2aee3965a83
v1.0.0-preview.4

Who changed what in which revision?

UserRevisionLine numberNew contents of line
AzureIoTClient 4:233dd7616d73 1 // Copyright (c) Microsoft. All rights reserved.
AzureIoTClient 4:233dd7616d73 2 // Licensed under the MIT license. See LICENSE file in the project root for full license information.
AzureIoTClient 4:233dd7616d73 3
AzureIoTClient 4:233dd7616d73 4 /** @file serializer.h
AzureIoTClient 4:233dd7616d73 5 * @brief The IoT Hub Serializer APIs allows developers to define models for
AzureIoTClient 4:233dd7616d73 6 * their devices
AzureIoTClient 4:233dd7616d73 7 *
AzureIoTClient 4:233dd7616d73 8 * @details The IoT Hub Serializer APIs allows developers to quickly and easily define
AzureIoTClient 4:233dd7616d73 9 * models for their devices directly as code, while supporting the required
AzureIoTClient 4:233dd7616d73 10 * features for modeling devices (including multiple models and multiple
AzureIoTClient 4:233dd7616d73 11 * devices within the same application). For example:
AzureIoTClient 4:233dd7616d73 12 *
AzureIoTClient 4:233dd7616d73 13 * <pre>
AzureIoTClient 4:233dd7616d73 14 * BEGIN_NAMESPACE(Contoso);
AzureIoTClient 4:233dd7616d73 15 *
AzureIoTClient 4:233dd7616d73 16 * DECLARE_STRUCT(SystemProperties,
AzureIoTClient 4:233dd7616d73 17 * ascii_char_ptr, DeviceID,
AzureIoTClient 4:233dd7616d73 18 * _Bool, Enabled
AzureIoTClient 4:233dd7616d73 19 * );
AzureIoTClient 4:233dd7616d73 20 *
AzureIoTClient 4:233dd7616d73 21 * DECLARE_MODEL(VendingMachine,
AzureIoTClient 4:233dd7616d73 22 *
AzureIoTClient 4:233dd7616d73 23 * WITH_DATA(int, SensorValue),
AzureIoTClient 4:233dd7616d73 24 *
AzureIoTClient 4:233dd7616d73 25 * WITH_DATA(ascii_char_ptr, ObjectName),
AzureIoTClient 4:233dd7616d73 26 * WITH_DATA(ascii_char_ptr, ObjectType),
AzureIoTClient 4:233dd7616d73 27 * WITH_DATA(ascii_char_ptr, Version),
AzureIoTClient 4:233dd7616d73 28 * WITH_DATA(SystemProperties, SystemProperties),
AzureIoTClient 4:233dd7616d73 29 * WITH_DATA(ascii_char_ptr_no_quotes, Commands),
AzureIoTClient 4:233dd7616d73 30 *
AzureIoTClient 4:233dd7616d73 31 * WITH_ACTION(SetItemPrice, ascii_char_ptr, itemId, ascii_char_ptr, price)
AzureIoTClient 4:233dd7616d73 32 * );
AzureIoTClient 4:233dd7616d73 33 *
AzureIoTClient 4:233dd7616d73 34 * END_NAMESPACE(Contoso);
AzureIoTClient 4:233dd7616d73 35 * </pre>
AzureIoTClient 4:233dd7616d73 36 */
AzureIoTClient 4:233dd7616d73 37
AzureIoTClient 4:233dd7616d73 38 #ifndef SERIALIZER_H
AzureIoTClient 4:233dd7616d73 39 #define SERIALIZER_H
AzureIoTClient 4:233dd7616d73 40
AzureIoTClient 4:233dd7616d73 41 #ifdef __cplusplus
AzureIoTClient 4:233dd7616d73 42 #include <cstdlib>
AzureIoTClient 4:233dd7616d73 43 #include <cstdarg>
AzureIoTClient 4:233dd7616d73 44
AzureIoTClient 4:233dd7616d73 45 #else
AzureIoTClient 4:233dd7616d73 46 #include <stdlib.h>
AzureIoTClient 4:233dd7616d73 47 #include <stdarg.h>
AzureIoTClient 4:233dd7616d73 48 #endif
AzureIoTClient 4:233dd7616d73 49
AzureIoTClient 4:233dd7616d73 50 #ifdef _CRTDBG_MAP_ALLOC
AzureIoTClient 4:233dd7616d73 51 #include <crtdbg.h>
AzureIoTClient 4:233dd7616d73 52 #endif
AzureIoTClient 4:233dd7616d73 53
AzureIoTClient 4:233dd7616d73 54 #include "gballoc.h"
AzureIoTClient 4:233dd7616d73 55 #include "macro_utils.h"
AzureIoTClient 4:233dd7616d73 56 #include "iotdevice.h"
AzureIoTClient 4:233dd7616d73 57 #include "crt_abstractions.h"
AzureIoTClient 4:233dd7616d73 58 #include "iot_logging.h"
AzureIoTClient 4:233dd7616d73 59 #include "schemalib.h"
AzureIoTClient 4:233dd7616d73 60 #include "codefirst.h"
AzureIoTClient 4:233dd7616d73 61 #include "agenttypesystem.h"
AzureIoTClient 4:233dd7616d73 62 #include "schema.h"
AzureIoTClient 4:233dd7616d73 63
AzureIoTClient 4:233dd7616d73 64
AzureIoTClient 4:233dd7616d73 65 #ifdef __cplusplus
AzureIoTClient 4:233dd7616d73 66 extern "C"
AzureIoTClient 4:233dd7616d73 67 {
AzureIoTClient 4:233dd7616d73 68 #endif
AzureIoTClient 4:233dd7616d73 69
AzureIoTClient 4:233dd7616d73 70 #define IOT_AGENT_RESULT_ENUM_VALUES \
AzureIoTClient 4:233dd7616d73 71 IOT_AGENT_OK, \
AzureIoTClient 4:233dd7616d73 72 IOT_AGENT_AGENT_DATA_TYPES_ERROR, \
AzureIoTClient 4:233dd7616d73 73 IOT_AGENT_COMMAND_EXECUTION_ERROR, \
AzureIoTClient 4:233dd7616d73 74 IOT_AGENT_ERROR, \
AzureIoTClient 4:233dd7616d73 75 IOT_AGENT_SERIALIZE_FAILED, \
AzureIoTClient 4:233dd7616d73 76 IOT_AGENT_INVALID_ARG
AzureIoTClient 4:233dd7616d73 77
AzureIoTClient 4:233dd7616d73 78 DEFINE_ENUM(IOT_AGENT_RESULT, IOT_AGENT_RESULT_ENUM_VALUES);
AzureIoTClient 4:233dd7616d73 79
AzureIoTClient 4:233dd7616d73 80
AzureIoTClient 4:233dd7616d73 81 /* IOT Agent Macros */
AzureIoTClient 4:233dd7616d73 82
AzureIoTClient 4:233dd7616d73 83 /**
AzureIoTClient 4:233dd7616d73 84 * @def BEGIN_NAMESPACE(schemaNamespace)
AzureIoTClient 4:233dd7616d73 85 * This macro marks the start of a section that declares IOT model
AzureIoTClient 4:233dd7616d73 86 * elements (like complex types, etc.). Declarations are typically
AzureIoTClient 4:233dd7616d73 87 * placed in header files, so that they can be shared between
AzureIoTClient 4:233dd7616d73 88 * translation units.
AzureIoTClient 4:233dd7616d73 89 */
AzureIoTClient 4:233dd7616d73 90 /* Codes_SRS_SERIALIZER_99_001:[For each completed schema declaration block, a unique storage container for schema metadata shall be available in the translation unit at runtime.] */
AzureIoTClient 4:233dd7616d73 91 #define BEGIN_NAMESPACE(schemaNamespace) \
AzureIoTClient 4:233dd7616d73 92 REFLECTED_END_OF_LIST
AzureIoTClient 4:233dd7616d73 93
AzureIoTClient 4:233dd7616d73 94 /**
AzureIoTClient 4:233dd7616d73 95 * @def END_NAMESPACE(schemaNamespace)
AzureIoTClient 4:233dd7616d73 96 * This macro marks the end of a section that declares IOT model
AzureIoTClient 4:233dd7616d73 97 * elements.
AzureIoTClient 4:233dd7616d73 98 */
AzureIoTClient 4:233dd7616d73 99 #define END_NAMESPACE(schemaNamespace) \
AzureIoTClient 4:233dd7616d73 100 REFLECTED_LIST_HEAD(schemaNamespace)
AzureIoTClient 4:233dd7616d73 101
AzureIoTClient 4:233dd7616d73 102 /**
AzureIoTClient 4:233dd7616d73 103 * @def DECLARE_STRUCT(name, ...)
AzureIoTClient 4:233dd7616d73 104 * This macro allows the definition of a struct type that can then be used as
AzureIoTClient 4:233dd7616d73 105 * part of a model definition.
AzureIoTClient 4:233dd7616d73 106 *
AzureIoTClient 4:233dd7616d73 107 * @param name Name of the struct
AzureIoTClient 4:233dd7616d73 108 * @param element1, element2... Specifies a list of struct members
AzureIoTClient 4:233dd7616d73 109 */
AzureIoTClient 4:233dd7616d73 110 /* Codes_SRS_SERIALIZER_99_080:[ The DECLARE_STRUCT declaration shall insert metadata describing a complex data type.] */
AzureIoTClient 4:233dd7616d73 111 #define DECLARE_STRUCT(name, ...) \
AzureIoTClient 4:233dd7616d73 112 /* Codes_SRS_SERIALIZER_99_096:[ DECLARE_STRUCT shall declare a matching C struct data type named name, which can be referenced from any code that can access the declaration.] */ \
AzureIoTClient 4:233dd7616d73 113 typedef struct name##_TAG { \
AzureIoTClient 4:233dd7616d73 114 FOR_EACH_2(INSERT_FIELD_INTO_STRUCT, __VA_ARGS__) \
AzureIoTClient 4:233dd7616d73 115 } name; \
AzureIoTClient 4:233dd7616d73 116 /* Codes_SRS_SERIALIZER_99_081:[ DECLARE_STRUCT's name argument shall uniquely identify the struct within the schema.] */ \
AzureIoTClient 4:233dd7616d73 117 REFLECTED_STRUCT(name) \
AzureIoTClient 4:233dd7616d73 118 /* Codes_SRS_SERIALIZER_99_082:[ DECLARE_STRUCT's field<n>Name argument shall uniquely name a field within the struct.] */ \
AzureIoTClient 4:233dd7616d73 119 FOR_EACH_2_KEEP_1(REFLECTED_FIELD, name, __VA_ARGS__) \
AzureIoTClient 4:233dd7616d73 120 TO_AGENT_DATA_TYPE(name, __VA_ARGS__) \
AzureIoTClient 4:233dd7616d73 121 /*Codes_SRS_SERIALIZER_99_042:[ The parameter types are either predefined parameter types (specs SRS_SERIALIZER_99_004-SRS_SERIALIZER_99_014) or a type introduced by DECLARE_STRUCT.]*/ \
AzureIoTClient 4:233dd7616d73 122 static AGENT_DATA_TYPES_RESULT FromAGENT_DATA_TYPE_##name(const AGENT_DATA_TYPE* source, name* destination) \
AzureIoTClient 4:233dd7616d73 123 { \
AzureIoTClient 4:233dd7616d73 124 AGENT_DATA_TYPES_RESULT result; \
AzureIoTClient 4:233dd7616d73 125 if(source->type != EDM_COMPLEX_TYPE_TYPE) \
AzureIoTClient 4:233dd7616d73 126 { \
AzureIoTClient 4:233dd7616d73 127 result = AGENT_DATA_TYPES_INVALID_ARG; \
AzureIoTClient 4:233dd7616d73 128 } \
AzureIoTClient 4:233dd7616d73 129 else if(DIV2(COUNT_ARG(__VA_ARGS__)) != source->value.edmComplexType.nMembers) \
AzureIoTClient 4:233dd7616d73 130 { \
AzureIoTClient 4:233dd7616d73 131 /*too many or too few fields*/ \
AzureIoTClient 4:233dd7616d73 132 result = AGENT_DATA_TYPES_INVALID_ARG; \
AzureIoTClient 4:233dd7616d73 133 } \
AzureIoTClient 4:233dd7616d73 134 else \
AzureIoTClient 4:233dd7616d73 135 { \
AzureIoTClient 4:233dd7616d73 136 result = AGENT_DATA_TYPES_OK; \
AzureIoTClient 4:233dd7616d73 137 FOR_EACH_2(BUILD_DESTINATION_FIELD, __VA_ARGS__); \
AzureIoTClient 4:233dd7616d73 138 } \
AzureIoTClient 4:233dd7616d73 139 return result; \
AzureIoTClient 4:233dd7616d73 140 } \
AzureIoTClient 4:233dd7616d73 141 static void C2(destroyLocalParameter, name)(name * value) \
AzureIoTClient 4:233dd7616d73 142 { \
AzureIoTClient 4:233dd7616d73 143 FOR_EACH_2_KEEP_1(UNBUILD_DESTINATION_FIELD, value, __VA_ARGS__); \
AzureIoTClient 4:233dd7616d73 144 }
AzureIoTClient 4:233dd7616d73 145
AzureIoTClient 4:233dd7616d73 146 /**
AzureIoTClient 4:233dd7616d73 147 * @def DECLARE_MODEL(name, ...)
AzureIoTClient 4:233dd7616d73 148 * This macro allows declaring a model that can be later used to instantiate
AzureIoTClient 4:233dd7616d73 149 * a device.
AzureIoTClient 4:233dd7616d73 150 *
AzureIoTClient 4:233dd7616d73 151 * @param name Specifies the model name
AzureIoTClient 4:233dd7616d73 152 * @param element1, element2... Specifies a model element which can be
AzureIoTClient 4:233dd7616d73 153 * a property or an action.
AzureIoTClient 4:233dd7616d73 154 * - A property is described in a
AzureIoTClient 4:233dd7616d73 155 * model by using the WITH_DATA
AzureIoTClient 4:233dd7616d73 156 * - An action is described in a
AzureIoTClient 4:233dd7616d73 157 * model by using the ::WITH_ACTION
AzureIoTClient 4:233dd7616d73 158 * macro.
AzureIoTClient 4:233dd7616d73 159 *
AzureIoTClient 4:233dd7616d73 160 */
AzureIoTClient 4:233dd7616d73 161 /* WITH_DATA's name argument shall be one of the following data types: */
AzureIoTClient 4:233dd7616d73 162 /* Codes_SRS_SERIALIZER_99_133:[a model type introduced previously by DECLARE_MODEL] */
AzureIoTClient 4:233dd7616d73 163 #define DECLARE_MODEL(name, ...) \
AzureIoTClient 4:233dd7616d73 164 REFLECTED_MODEL(name) \
AzureIoTClient 4:233dd7616d73 165 typedef struct name { int :1; FOR_EACH_1(BUILD_MODEL_STRUCT, __VA_ARGS__) } name; \
AzureIoTClient 4:233dd7616d73 166 FOR_EACH_1_KEEP_1(CREATE_MODEL_ELEMENT, name, __VA_ARGS__) \
AzureIoTClient 4:233dd7616d73 167 TO_AGENT_DATA_TYPE(name, DROP_FIRST_COMMA_FROM_ARGS(EXPAND_MODEL_ARGS(__VA_ARGS__)))
AzureIoTClient 4:233dd7616d73 168
AzureIoTClient 4:233dd7616d73 169 /**
AzureIoTClient 4:233dd7616d73 170 * @def WITH_DATA(type, name)
AzureIoTClient 4:233dd7616d73 171 * The ::WITH_DATA macro allows declaring a model property in a model. A
AzureIoTClient 4:233dd7616d73 172 * property can be published by using the ::SERIALIZE macro.
AzureIoTClient 4:233dd7616d73 173 *
AzureIoTClient 4:233dd7616d73 174 * @param type Specifies the property type. Can be any of the following
AzureIoTClient 4:233dd7616d73 175 * types:
AzureIoTClient 4:233dd7616d73 176 * - int
AzureIoTClient 4:233dd7616d73 177 * - double
AzureIoTClient 4:233dd7616d73 178 * - float
AzureIoTClient 4:233dd7616d73 179 * - long
AzureIoTClient 4:233dd7616d73 180 * - int8_t
AzureIoTClient 4:233dd7616d73 181 * - uint8_t
AzureIoTClient 4:233dd7616d73 182 * - int16_t
AzureIoTClient 4:233dd7616d73 183 * - int32_t
AzureIoTClient 4:233dd7616d73 184 * - int64_t
AzureIoTClient 4:233dd7616d73 185 * - bool
AzureIoTClient 4:233dd7616d73 186 * - ascii_char_ptr
AzureIoTClient 4:233dd7616d73 187 * - EDM_DATE_TIME_OFFSET
AzureIoTClient 4:233dd7616d73 188 * - EDM_GUID
AzureIoTClient 4:233dd7616d73 189 * - EDM_BINARY
AzureIoTClient 4:233dd7616d73 190 * - Any struct type previously introduced by another ::DECLARE_STRUCT.
AzureIoTClient 4:233dd7616d73 191 *
AzureIoTClient 4:233dd7616d73 192 * @param name Specifies the property name
AzureIoTClient 4:233dd7616d73 193 */
AzureIoTClient 4:233dd7616d73 194 #define WITH_DATA(type, name) MODEL_PROPERTY(type, name)
AzureIoTClient 4:233dd7616d73 195
AzureIoTClient 4:233dd7616d73 196 /**
AzureIoTClient 4:233dd7616d73 197 * @def WITH_ACTION(name, ...)
AzureIoTClient 4:233dd7616d73 198 * The ::WITH_ACTION macro allows declaring a model action.
AzureIoTClient 4:233dd7616d73 199 *
AzureIoTClient 4:233dd7616d73 200 * @param name Specifies the action name.
AzureIoTClient 4:233dd7616d73 201 * @param argXtype, argXName... Defines the type and name for the X<sup>th</sup>
AzureIoTClient 4:233dd7616d73 202 * argument of the action. The type can be any of
AzureIoTClient 4:233dd7616d73 203 * the primitive types or a struct type.
AzureIoTClient 4:233dd7616d73 204 */
AzureIoTClient 4:233dd7616d73 205 /*Codes_SRS_SERIALIZER_99_039:[WITH_ACTION shall declare an action of the current data provider called as the first macro parameter(name) and having the first parameter called parameter1Name of type parameter1Type, the second parameter named parameter2Name having the type parameter2Type and so on.]*/
AzureIoTClient 4:233dd7616d73 206 #define WITH_ACTION(name, ...) MODEL_ACTION(name, __VA_ARGS__)
AzureIoTClient 4:233dd7616d73 207
AzureIoTClient 4:233dd7616d73 208 /**
AzureIoTClient 4:233dd7616d73 209 * @def GET_MODEL_HANDLE(schemaNamespace, modelName)
AzureIoTClient 4:233dd7616d73 210 * The ::GET_MODEL_HANDLE macro returns a model handle that can be used in
AzureIoTClient 4:233dd7616d73 211 * subsequent operations like generating the CSDL schema for the model,
AzureIoTClient 4:233dd7616d73 212 * uploading the schema, creating a device, etc.
AzureIoTClient 4:233dd7616d73 213 *
AzureIoTClient 4:233dd7616d73 214 * @param schemaNamespace The namespace to which the model belongs.
AzureIoTClient 4:233dd7616d73 215 * @param modelName The name of the model.
AzureIoTClient 4:233dd7616d73 216 */
AzureIoTClient 4:233dd7616d73 217 /* Codes_SRS_SERIALIZER_99_110:[ The GET_MODEL_HANDLE function macro shall first register the schema by calling CodeFirst_RegisterSchema, passing schemaNamespace and a pointer to the metadata generated in the schema declaration block.] */
AzureIoTClient 4:233dd7616d73 218 /* Codes_SRS_SERIALIZER_99_094:[ GET_MODEL_HANDLE shall then call Schema_GetModelByName, passing the schemaHandle obtained from CodeFirst_RegisterSchema and modelName arguments, to retrieve the SCHEMA_MODEL_TYPE_HANDLE corresponding to the modelName argument.] */
AzureIoTClient 4:233dd7616d73 219 /* Codes_SRS_SERIALIZER_99_112:[ GET_MODEL_HANDLE will return the handle for the named model.] */
AzureIoTClient 4:233dd7616d73 220 #define GET_MODEL_HANDLE(schemaNamespace, modelName) \
AzureIoTClient 4:233dd7616d73 221 Schema_GetModelByName(CodeFirst_RegisterSchema(TOSTRING(schemaNamespace), &ALL_REFLECTED(schemaNamespace)), #modelName)
AzureIoTClient 4:233dd7616d73 222
AzureIoTClient 4:233dd7616d73 223 /* Codes_SRS_SERIALIZER_01_002: [If the argument serializerIncludePropertyPath is specified, its value shall be passed to CodeFirst_Create.] */
AzureIoTClient 4:233dd7616d73 224 #define CREATE_DEVICE_WITH_INCLUDE_PROPERTY_PATH(schemaNamespace, modelName, serializerIncludePropertyPath) \
AzureIoTClient 4:233dd7616d73 225 (modelName*)CodeFirst_CreateDevice(GET_MODEL_HANDLE(schemaNamespace, modelName), &ALL_REFLECTED(schemaNamespace), sizeof(modelName), serializerIncludePropertyPath)
AzureIoTClient 4:233dd7616d73 226
AzureIoTClient 4:233dd7616d73 227 /* Codes_SRS_SERIALIZER_01_003: [If the argument serializerIncludePropertyPath is not specified, CREATE_MODEL_INSTANCE shall pass false to CodeFirst_Create.] */
AzureIoTClient 4:233dd7616d73 228 #define CREATE_DEVICE_WITHOUT_INCLUDE_PROPERTY_PATH(schemaNamespace, modelName) \
AzureIoTClient 4:233dd7616d73 229 (modelName*)CodeFirst_CreateDevice(GET_MODEL_HANDLE(schemaNamespace, modelName), &ALL_REFLECTED(schemaNamespace), sizeof(modelName), false)
AzureIoTClient 4:233dd7616d73 230
AzureIoTClient 4:233dd7616d73 231 /* Codes_SRS_SERIALIZER_99_104:[ CREATE_MODEL_INSTANCE shall call GET_MODEL_HANDLE, passing schemaNamespace and modelName, to get a model handle representing the model defined in the corresponding schema declaration block.] */
AzureIoTClient 4:233dd7616d73 232 /* Codes_SRS_SERIALIZER_99_106:[ CREATE_MODEL_INSTANCE shall call CodeFirst_CreateDevice, passing the model handle (SCHEMA_MODEL_TYPE_HANDLE]*/
AzureIoTClient 4:233dd7616d73 233 /* Codes_SRS_SERIALIZER_99_107:[ If CodeFirst_CreateDevice fails, CREATE_MODEL_INSTANCE shall return NULL.] */
AzureIoTClient 4:233dd7616d73 234 /* Codes_SRS_SERIALIZER_99_108:[ If CodeFirst_CreateDevice succeeds, CREATE_MODEL_INSTANCE shall return a pointer to an instance of the C struct representing the model for the device.] */
AzureIoTClient 4:233dd7616d73 235 #define CREATE_MODEL_INSTANCE(schemaNamespace, ...) \
AzureIoTClient 4:233dd7616d73 236 IF(DIV2(COUNT_ARG(__VA_ARGS__)), CREATE_DEVICE_WITH_INCLUDE_PROPERTY_PATH, CREATE_DEVICE_WITHOUT_INCLUDE_PROPERTY_PATH) (schemaNamespace, __VA_ARGS__)
AzureIoTClient 4:233dd7616d73 237
AzureIoTClient 4:233dd7616d73 238 /* Codes_SRS_SERIALIZER_99_109:[ DESTROY_MODEL_INSTANCE shall call CodeFirst_DestroyDevice, passing the pointer returned from CREATE_MODEL_INSTANCE, to release all resources associated with the device.] */
AzureIoTClient 4:233dd7616d73 239 #define DESTROY_MODEL_INSTANCE(deviceData) \
AzureIoTClient 4:233dd7616d73 240 CodeFirst_DestroyDevice(deviceData)
AzureIoTClient 4:233dd7616d73 241
AzureIoTClient 4:233dd7616d73 242 /**
AzureIoTClient 4:233dd7616d73 243 * @def SERIALIZE(destination, destinationSize,...)
AzureIoTClient 4:233dd7616d73 244 * This macro produces JSON serialized representation of the properties.
AzureIoTClient 4:233dd7616d73 245 *
AzureIoTClient 4:233dd7616d73 246 * @param destination Pointer to an @c unsigned @c char* that
AzureIoTClient 4:233dd7616d73 247 * will receive the serialized data.
AzureIoTClient 4:233dd7616d73 248 * @param destinationSize Pointer to a @c size_t that gets
AzureIoTClient 4:233dd7616d73 249 * written with the size in bytes of the
AzureIoTClient 4:233dd7616d73 250 * serialized data
AzureIoTClient 4:233dd7616d73 251 * @param property1, property2... A list of property values to send. The
AzureIoTClient 4:233dd7616d73 252 * order in which the properties appear in
AzureIoTClient 4:233dd7616d73 253 * the list does not matter, all values
AzureIoTClient 4:233dd7616d73 254 * will be sent together.
AzureIoTClient 4:233dd7616d73 255 *
AzureIoTClient 4:233dd7616d73 256 */
AzureIoTClient 4:233dd7616d73 257 /*Codes_SRS_SERIALIZER_99_113:[ SERIALIZE shall call CodeFirst_SendAsync, passing a destination, destinationSize, the number of properties to publish, and pointers to the values for each property.] */
AzureIoTClient 4:233dd7616d73 258 /*Codes_SRS_SERIALIZER_99_117:[ If CodeFirst_SendAsync succeeds, SEND will return IOT_AGENT_OK.] */
AzureIoTClient 4:233dd7616d73 259 /*Codes_SRS_SERIALIZER_99_114:[ If CodeFirst_SendAsync fails, SEND shall return IOT_AGENT_SERIALIZE_FAILED.] */
AzureIoTClient 4:233dd7616d73 260 #define SERIALIZE(destination, destinationSize,...) ((CodeFirst_SendAsync(destination, destinationSize, COUNT_ARG(__VA_ARGS__) FOR_EACH_1(ADDRESS_MACRO, __VA_ARGS__)) == CODEFIRST_OK) ? IOT_AGENT_OK : IOT_AGENT_SERIALIZE_FAILED)
AzureIoTClient 4:233dd7616d73 261
AzureIoTClient 4:233dd7616d73 262 /**
AzureIoTClient 4:233dd7616d73 263 * @def EXECUTE_COMMAND(device, command)
AzureIoTClient 4:233dd7616d73 264 * Any action that is declared in a model must also have an implementation as
AzureIoTClient 4:233dd7616d73 265 * a C function.
AzureIoTClient 4:233dd7616d73 266 *
AzureIoTClient 4:233dd7616d73 267 * @param device Pointer to device data.
AzureIoTClient 4:233dd7616d73 268 * @param command Values that match the arguments declared in the model
AzureIoTClient 4:233dd7616d73 269 * action.
AzureIoTClient 4:233dd7616d73 270 */
AzureIoTClient 4:233dd7616d73 271 /*Codes_SRS_SERIALIZER_02_018: [EXECUTE_COMMAND macro shall call CodeFirst_ExecuteCommand passing device, commandBuffer and commandBufferSize.]*/
AzureIoTClient 4:233dd7616d73 272 #define EXECUTE_COMMAND(device, command) (CodeFirst_ExecuteCommand(device, command))
AzureIoTClient 4:233dd7616d73 273
AzureIoTClient 4:233dd7616d73 274 /* Helper macros */
AzureIoTClient 4:233dd7616d73 275
AzureIoTClient 4:233dd7616d73 276 /* These macros remove a useless comma from the beginning of an argument list that looks like:
AzureIoTClient 4:233dd7616d73 277 ,x1,y1,x2,y2 */
AzureIoTClient 4:233dd7616d73 278 #ifdef _MSC_VER
AzureIoTClient 4:233dd7616d73 279
AzureIoTClient 4:233dd7616d73 280 #define DROP_FIRST_COMMA(N, x) \
AzureIoTClient 4:233dd7616d73 281 x IFCOMMA_NOFIRST(N)
AzureIoTClient 4:233dd7616d73 282
AzureIoTClient 4:233dd7616d73 283 #define DROP_IF_EMPTY(N, x) \
AzureIoTClient 4:233dd7616d73 284 IF(COUNT_ARG(x),DROP_FIRST_COMMA(N,x),x)
AzureIoTClient 4:233dd7616d73 285
AzureIoTClient 4:233dd7616d73 286 #define DROP_FIRST_COMMA_FROM_ARGS(...) \
AzureIoTClient 4:233dd7616d73 287 FOR_EACH_1_COUNTED(DROP_IF_EMPTY, C1(__VA_ARGS__))
AzureIoTClient 4:233dd7616d73 288
AzureIoTClient 4:233dd7616d73 289 #else
AzureIoTClient 4:233dd7616d73 290
AzureIoTClient 4:233dd7616d73 291 #define DROP_FIRST_COMMA_0(N, x) \
AzureIoTClient 4:233dd7616d73 292 x IFCOMMA_NOFIRST(N)
AzureIoTClient 4:233dd7616d73 293
AzureIoTClient 4:233dd7616d73 294 #define DROP_FIRST_COMMA_1(N, x) \
AzureIoTClient 4:233dd7616d73 295 x
AzureIoTClient 4:233dd7616d73 296
AzureIoTClient 4:233dd7616d73 297 #define DROP_FIRST_COMMA(empty, N, x) \
AzureIoTClient 4:233dd7616d73 298 C2(DROP_FIRST_COMMA_,empty)(N,x)
AzureIoTClient 4:233dd7616d73 299
AzureIoTClient 4:233dd7616d73 300 #define DROP_IF_EMPTY(N, x) \
AzureIoTClient 4:233dd7616d73 301 DROP_FIRST_COMMA(ISEMPTY(x),N,x)
AzureIoTClient 4:233dd7616d73 302
AzureIoTClient 4:233dd7616d73 303 #define DROP_FIRST_COMMA_FROM_ARGS(...) \
AzureIoTClient 4:233dd7616d73 304 FOR_EACH_1_COUNTED(DROP_IF_EMPTY, __VA_ARGS__)
AzureIoTClient 4:233dd7616d73 305
AzureIoTClient 4:233dd7616d73 306 #endif
AzureIoTClient 4:233dd7616d73 307
AzureIoTClient 4:233dd7616d73 308 /* These macros expand a sequence of arguments for DECLARE_MODEL that looks like
AzureIoTClient 4:233dd7616d73 309 WITH_DATA(x, y), WITH_DATA(x2, y2) to a list of arguments consumed by the macro that marshalls a struct, like:
AzureIoTClient 4:233dd7616d73 310 x, y, x2, y2
AzureIoTClient 4:233dd7616d73 311 Actions are discarded, since no marshalling will be done for those when sending state data */
AzureIoTClient 4:233dd7616d73 312 #define TO_AGENT_DT_EXPAND_MODEL_PROPERTY(x, y) ,x,y
AzureIoTClient 4:233dd7616d73 313 #define TO_AGENT_DT_EXPAND_MODEL_ACTION(...)
AzureIoTClient 4:233dd7616d73 314
AzureIoTClient 4:233dd7616d73 315 #define TO_AGENT_DT_EXPAND_ELEMENT_ARGS(N, ...) TO_AGENT_DT_EXPAND_##__VA_ARGS__
AzureIoTClient 4:233dd7616d73 316
AzureIoTClient 4:233dd7616d73 317 #define EXPAND_MODEL_ARGS(...) \
AzureIoTClient 4:233dd7616d73 318 FOR_EACH_1_COUNTED(TO_AGENT_DT_EXPAND_ELEMENT_ARGS, __VA_ARGS__)
AzureIoTClient 4:233dd7616d73 319
AzureIoTClient 4:233dd7616d73 320 #define TO_AGENT_DATA_TYPE(name, ...) \
AzureIoTClient 4:233dd7616d73 321 static AGENT_DATA_TYPES_RESULT ToAGENT_DATA_TYPE_##name(AGENT_DATA_TYPE *destination, const name value) \
AzureIoTClient 4:233dd7616d73 322 { \
AzureIoTClient 4:233dd7616d73 323 AGENT_DATA_TYPES_RESULT result = AGENT_DATA_TYPES_OK; \
AzureIoTClient 4:233dd7616d73 324 size_t iMember = 0; \
AzureIoTClient 4:233dd7616d73 325 DEFINITION_THAT_CAN_SUSTAIN_A_COMMA_STEAL(phantomName, 1); \
AzureIoTClient 4:233dd7616d73 326 const char* memberNames[IF(DIV2(C1(COUNT_ARG(__VA_ARGS__))), DIV2(C1(COUNT_ARG(__VA_ARGS__))), 1)] = { 0 }; \
AzureIoTClient 4:233dd7616d73 327 size_t memberCount = sizeof(memberNames) / sizeof(memberNames[0]); \
AzureIoTClient 4:233dd7616d73 328 (void)value; \
AzureIoTClient 4:233dd7616d73 329 if (memberCount == 0) \
AzureIoTClient 4:233dd7616d73 330 { \
AzureIoTClient 4:233dd7616d73 331 result = AGENT_DATA_TYPES_OK; \
AzureIoTClient 4:233dd7616d73 332 } \
AzureIoTClient 4:233dd7616d73 333 else \
AzureIoTClient 4:233dd7616d73 334 { \
AzureIoTClient 4:233dd7616d73 335 AGENT_DATA_TYPE members[sizeof(memberNames) / sizeof(memberNames[0])]; \
AzureIoTClient 4:233dd7616d73 336 DEFINITION_THAT_CAN_SUSTAIN_A_COMMA_STEAL(phantomName, 2); \
AzureIoTClient 4:233dd7616d73 337 FOR_EACH_2(FIELD_AS_STRING, EXPAND_TWICE(__VA_ARGS__)) \
AzureIoTClient 4:233dd7616d73 338 iMember = 0; \
AzureIoTClient 4:233dd7616d73 339 INSTRUCTION_THAT_CAN_SUSTAIN_A_COMMA_STEAL; \
AzureIoTClient 4:233dd7616d73 340 FOR_EACH_2(CREATE_AGENT_DATA_TYPE, EXPAND_TWICE(__VA_ARGS__)) \
AzureIoTClient 4:233dd7616d73 341 INSTRUCTION_THAT_CAN_SUSTAIN_A_COMMA_STEAL; \
AzureIoTClient 4:233dd7616d73 342 result = ((result == AGENT_DATA_TYPES_OK) && (Create_AGENT_DATA_TYPE_from_Members(destination, #name, sizeof(memberNames) / sizeof(memberNames[0]), memberNames, members) == AGENT_DATA_TYPES_OK)) \
AzureIoTClient 4:233dd7616d73 343 ? AGENT_DATA_TYPES_OK \
AzureIoTClient 4:233dd7616d73 344 : AGENT_DATA_TYPES_ERROR; \
AzureIoTClient 4:233dd7616d73 345 { \
AzureIoTClient 4:233dd7616d73 346 size_t jMember; \
AzureIoTClient 4:233dd7616d73 347 for (jMember = 0; jMember < iMember; jMember++) \
AzureIoTClient 4:233dd7616d73 348 { \
AzureIoTClient 4:233dd7616d73 349 Destroy_AGENT_DATA_TYPE(&members[jMember]); \
AzureIoTClient 4:233dd7616d73 350 } \
AzureIoTClient 4:233dd7616d73 351 } \
AzureIoTClient 4:233dd7616d73 352 } \
AzureIoTClient 4:233dd7616d73 353 return result; \
AzureIoTClient 4:233dd7616d73 354 }
AzureIoTClient 4:233dd7616d73 355
AzureIoTClient 4:233dd7616d73 356 #define FIELD_AS_STRING(x,y) memberNames[iMember++] = #y;
AzureIoTClient 4:233dd7616d73 357
AzureIoTClient 4:233dd7616d73 358 #define REFLECTED_LIST_HEAD(name) \
AzureIoTClient 4:233dd7616d73 359 static const REFLECTED_DATA_FROM_DATAPROVIDER ALL_REFLECTED(name) = { &C2(REFLECTED_, C1(DEC(__COUNTER__))) };
AzureIoTClient 4:233dd7616d73 360 #define REFLECTED_STRUCT(name) \
AzureIoTClient 4:233dd7616d73 361 static const REFLECTED_SOMETHING C2(REFLECTED_, C1(INC(__COUNTER__))) = { REFLECTION_STRUCT_TYPE, &C2(REFLECTED_, C1(DEC(DEC(__COUNTER__)))), { {TOSTRING(name)}, {0}, {0}, {0}, {0}} };
AzureIoTClient 4:233dd7616d73 362 #define REFLECTED_FIELD(XstructName, XfieldType, XfieldName) \
AzureIoTClient 4:233dd7616d73 363 static const REFLECTED_SOMETHING C2(REFLECTED_, C1(INC(__COUNTER__))) = { REFLECTION_FIELD_TYPE, &C2(REFLECTED_, C1(DEC(DEC(__COUNTER__)))), { {0}, {TOSTRING(XfieldName), TOSTRING(XfieldType), TOSTRING(XstructName)}, {0}, {0}, {0} } };
AzureIoTClient 4:233dd7616d73 364 #define REFLECTED_MODEL(name) \
AzureIoTClient 4:233dd7616d73 365 static const REFLECTED_SOMETHING C2(REFLECTED_, C1(INC(__COUNTER__))) = { REFLECTION_MODEL_TYPE, &C2(REFLECTED_, C1(DEC(DEC(__COUNTER__)))), { {0}, {0}, {0}, {0}, {TOSTRING(name)} } };
AzureIoTClient 4:233dd7616d73 366 #define REFLECTED_PROPERTY(type, name, modelName) \
AzureIoTClient 4:233dd7616d73 367 static const REFLECTED_SOMETHING C2(REFLECTED_, C1(INC(__COUNTER__))) = { REFLECTION_PROPERTY_TYPE, &C2(REFLECTED_, C1(DEC(DEC(__COUNTER__)))), { {0}, {0}, {TOSTRING(name), TOSTRING(type), Create_AGENT_DATA_TYPE_From_Ptr_##name, offsetof(modelName, name), sizeof(type), TOSTRING(modelName)}, {0}, {0}} };
AzureIoTClient 4:233dd7616d73 368 #define REFLECTED_ACTION(name, argc, argv, fn, modelName) \
AzureIoTClient 4:233dd7616d73 369 static const REFLECTED_SOMETHING C2(REFLECTED_, C1(INC(__COUNTER__))) = { REFLECTION_ACTION_TYPE, &C2(REFLECTED_, C1(DEC(DEC(__COUNTER__)))), { {0}, {0}, {0}, {TOSTRING(name), (0 ? (uintptr_t)("", "") : argc), argv, fn, TOSTRING(modelName)}, {0}} };
AzureIoTClient 4:233dd7616d73 370 #define REFLECTED_END_OF_LIST \
AzureIoTClient 4:233dd7616d73 371 static const REFLECTED_SOMETHING C2(REFLECTED_, __COUNTER__) = { REFLECTION_NOTHING, NULL, { {0}, {0}, {0}, {0}, {0}} };
AzureIoTClient 4:233dd7616d73 372
AzureIoTClient 4:233dd7616d73 373 #define EXPAND_MODEL_PROPERTY(type, name) EXPAND_ARGS(MODEL_PROPERTY, type, name)
AzureIoTClient 4:233dd7616d73 374 #define EXPAND_MODEL_ACTION(...) EXPAND_ARGS(MODEL_ACTION, __VA_ARGS__)
AzureIoTClient 4:233dd7616d73 375
AzureIoTClient 4:233dd7616d73 376 #define BUILD_MODEL_STRUCT(elem) INSERT_FIELD_FOR_##elem
AzureIoTClient 4:233dd7616d73 377
AzureIoTClient 4:233dd7616d73 378 #define CREATE_MODEL_ENTITY(modelName, callType, ...) EXPAND_ARGS(CREATE_##callType(modelName, __VA_ARGS__))
AzureIoTClient 4:233dd7616d73 379 #define CREATE_SOMETHING(modelName, ...) EXPAND_ARGS(CREATE_MODEL_ENTITY(modelName, __VA_ARGS__))
AzureIoTClient 4:233dd7616d73 380 #define CREATE_ELEMENT(modelName, elem) EXPAND_ARGS(CREATE_SOMETHING(modelName, EXPAND_ARGS(EXPAND_##elem)))
AzureIoTClient 4:233dd7616d73 381
AzureIoTClient 4:233dd7616d73 382 #define CREATE_MODEL_ELEMENT(modelName, elem) EXPAND_ARGS(CREATE_ELEMENT(modelName, elem))
AzureIoTClient 4:233dd7616d73 383
AzureIoTClient 4:233dd7616d73 384 #define INSERT_FIELD_INTO_STRUCT(x, y) x y;
AzureIoTClient 4:233dd7616d73 385 #define INSERT_FIELD_FOR_MODEL_PROPERTY(type, name) INSERT_FIELD_INTO_STRUCT(type, name)
AzureIoTClient 4:233dd7616d73 386 #define INSERT_FIELD_FOR_MODEL_ACTION(name, ...) /* action isn't a part of the model struct */
AzureIoTClient 4:233dd7616d73 387
AzureIoTClient 4:233dd7616d73 388 #define CREATE_MODEL_PROPERTY(modelName, type, name) \
AzureIoTClient 4:233dd7616d73 389 IMPL_PROPERTY(type, name, modelName)
AzureIoTClient 4:233dd7616d73 390
AzureIoTClient 4:233dd7616d73 391 #define IMPL_PROPERTY(propertyType, propertyName, modelName) \
AzureIoTClient 4:233dd7616d73 392 static int Create_AGENT_DATA_TYPE_From_Ptr_##propertyName(void* param, AGENT_DATA_TYPE* dest) \
AzureIoTClient 4:233dd7616d73 393 { \
AzureIoTClient 4:233dd7616d73 394 return C1(ToAGENT_DATA_TYPE_##propertyType)(dest, *(propertyType*)param); \
AzureIoTClient 4:233dd7616d73 395 } \
AzureIoTClient 4:233dd7616d73 396 REFLECTED_PROPERTY(propertyType, propertyName, modelName)
AzureIoTClient 4:233dd7616d73 397
AzureIoTClient 4:233dd7616d73 398 #define CREATE_MODEL_ACTION(modelName, actionName, ...) \
AzureIoTClient 4:233dd7616d73 399 DEFINITION_THAT_CAN_SUSTAIN_A_COMMA_STEAL(modelName##actionName, 1); \
AzureIoTClient 4:233dd7616d73 400 EXECUTE_COMMAND_RESULT actionName (modelName* device FOR_EACH_2(DEFINE_FUNCTION_PARAMETER, __VA_ARGS__)); \
AzureIoTClient 4:233dd7616d73 401 static EXECUTE_COMMAND_RESULT C2(actionName, WRAPPER)(void* device, size_t ParameterCount, const AGENT_DATA_TYPE* values); \
AzureIoTClient 4:233dd7616d73 402 /*for macro purposes, this array always has at least 1 element*/ \
AzureIoTClient 4:233dd7616d73 403 /*Codes_SRS_SERIALIZER_99_043:[ It is valid for a method not to have any parameters.]*/ \
AzureIoTClient 4:233dd7616d73 404 DEFINITION_THAT_CAN_SUSTAIN_A_COMMA_STEAL(actionName, 1); \
AzureIoTClient 4:233dd7616d73 405 static const WRAPPER_ARGUMENT C2(actionName, WRAPPERARGUMENTS)[DIV2(INC(INC(COUNT_ARG(__VA_ARGS__))))] = { FOR_EACH_2_COUNTED(MAKE_WRAPPER_ARGUMENT, __VA_ARGS__) IFCOMMA(INC(INC(COUNT_ARG(__VA_ARGS__)))) {0} }; \
AzureIoTClient 4:233dd7616d73 406 REFLECTED_ACTION(actionName, DIV2(COUNT_ARG(__VA_ARGS__)), C2(actionName, WRAPPERARGUMENTS), C2(actionName, WRAPPER), modelName) \
AzureIoTClient 4:233dd7616d73 407 /*Codes_SRS_SERIALIZER_99_040:[ In addition to declaring the function, DECLARE_IOT_METHOD shall provide a definition for a wrapper that takes as parameters a size_t parameterCount and const AGENT_DATA_TYPE*.] */ \
AzureIoTClient 4:233dd7616d73 408 /*Codes_SRS_SERIALIZER_99_041:[ This wrapper shall convert all the arguments to predefined types and then call the function written by the data provider developer.]*/ \
AzureIoTClient 4:233dd7616d73 409 static EXECUTE_COMMAND_RESULT C2(actionName, WRAPPER)(void* device, size_t ParameterCount, const AGENT_DATA_TYPE* values) \
AzureIoTClient 4:233dd7616d73 410 { \
AzureIoTClient 4:233dd7616d73 411 EXECUTE_COMMAND_RESULT result; \
AzureIoTClient 4:233dd7616d73 412 DEFINITION_THAT_CAN_SUSTAIN_A_COMMA_STEAL(actionName, 2); \
AzureIoTClient 4:233dd7616d73 413 /*Codes_SRS_SERIALIZER_99_045:[ If the number of passed parameters doesn't match the number of declared parameters, wrapper execution shall fail and return DATA_PROVIDER_INVALID_ARG;]*/ \
AzureIoTClient 4:233dd7616d73 414 if(ParameterCount != DIV2(COUNT_ARG(__VA_ARGS__))) \
AzureIoTClient 4:233dd7616d73 415 { \
AzureIoTClient 4:233dd7616d73 416 result = EXECUTE_COMMAND_ERROR; \
AzureIoTClient 4:233dd7616d73 417 } \
AzureIoTClient 4:233dd7616d73 418 else \
AzureIoTClient 4:233dd7616d73 419 { \
AzureIoTClient 4:233dd7616d73 420 /*the below line takes care of initialized but not referenced parameter warning*/ \
AzureIoTClient 4:233dd7616d73 421 DEFINITION_THAT_CAN_SUSTAIN_A_COMMA_STEAL(actionName, 3); \
AzureIoTClient 4:233dd7616d73 422 IF(DIV2(COUNT_ARG(__VA_ARGS__)), size_t iParameter = 0;, ) \
AzureIoTClient 4:233dd7616d73 423 DEFINITION_THAT_CAN_SUSTAIN_A_COMMA_STEAL(actionName, 4); \
AzureIoTClient 4:233dd7616d73 424 /*the below line takes care of an unused parameter when values is really never questioned*/ \
AzureIoTClient 4:233dd7616d73 425 DEFINITION_THAT_CAN_SUSTAIN_A_COMMA_STEAL(actionName, 5); \
AzureIoTClient 4:233dd7616d73 426 FOR_EACH_2(DEFINE_LOCAL_PARAMETER, __VA_ARGS__) \
AzureIoTClient 4:233dd7616d73 427 DEFINITION_THAT_CAN_SUSTAIN_A_COMMA_STEAL(actionName, 6); \
AzureIoTClient 4:233dd7616d73 428 IF(DIV2(COUNT_ARG(__VA_ARGS__)), , (void)values;) \
AzureIoTClient 4:233dd7616d73 429 INSTRUCTION_THAT_CAN_SUSTAIN_A_COMMA_STEAL; \
AzureIoTClient 4:233dd7616d73 430 FOR_EACH_2(START_BUILD_LOCAL_PARAMETER, __VA_ARGS__) \
AzureIoTClient 4:233dd7616d73 431 INSTRUCTION_THAT_CAN_SUSTAIN_A_COMMA_STEAL; \
AzureIoTClient 4:233dd7616d73 432 result = actionName((modelName*)device FOR_EACH_2(PUSH_LOCAL_PARAMETER, __VA_ARGS__)); \
AzureIoTClient 4:233dd7616d73 433 FOR_EACH_2(END_BUILD_LOCAL_PARAMETER, __VA_ARGS__) \
AzureIoTClient 4:233dd7616d73 434 } \
AzureIoTClient 4:233dd7616d73 435 return result; \
AzureIoTClient 4:233dd7616d73 436 }
AzureIoTClient 4:233dd7616d73 437
AzureIoTClient 4:233dd7616d73 438 #define CREATE_AGENT_DATA_TYPE(type, name) \
AzureIoTClient 4:233dd7616d73 439 result = (( result==AGENT_DATA_TYPES_OK) && (ToAGENT_DATA_TYPE_##type( &(members[iMember]), value.name) == AGENT_DATA_TYPES_OK))?AGENT_DATA_TYPES_OK:AGENT_DATA_TYPES_ERROR; \
AzureIoTClient 4:233dd7616d73 440 iMember+= ((result==AGENT_DATA_TYPES_OK)?1:0);
AzureIoTClient 4:233dd7616d73 441
AzureIoTClient 4:233dd7616d73 442 #define BUILD_DESTINATION_FIELD(type, name) \
AzureIoTClient 4:233dd7616d73 443 if(result == AGENT_DATA_TYPES_OK) \
AzureIoTClient 4:233dd7616d73 444 { \
AzureIoTClient 4:233dd7616d73 445 size_t i; \
AzureIoTClient 4:233dd7616d73 446 bool wasFieldConverted = false; \
AzureIoTClient 4:233dd7616d73 447 for (i = 0; i < source->value.edmComplexType.nMembers; i++) \
AzureIoTClient 4:233dd7616d73 448 { \
AzureIoTClient 4:233dd7616d73 449 /*the name of the field of the complex type must match the name of the field of the structure (parameter name here)*/ \
AzureIoTClient 4:233dd7616d73 450 if (strcmp(source->value.edmComplexType.fields[i].fieldName, TOSTRING(name)) == 0) \
AzureIoTClient 4:233dd7616d73 451 { /*Codes_SRS_SERIALIZER_99_017:[ These types can either be one of the types mentioned in WITH_DATA or it can be a type introduced by a previous DECLARE_STRUCT.]*/ \
AzureIoTClient 4:233dd7616d73 452 wasFieldConverted = (C2(FromAGENT_DATA_TYPE_, type)(source->value.edmComplexType.fields[i].value, &(destination->name)) == AGENT_DATA_TYPES_OK); \
AzureIoTClient 4:233dd7616d73 453 break; \
AzureIoTClient 4:233dd7616d73 454 } \
AzureIoTClient 4:233dd7616d73 455 } \
AzureIoTClient 4:233dd7616d73 456 result = (wasFieldConverted == true)? AGENT_DATA_TYPES_OK: AGENT_DATA_TYPES_INVALID_ARG; \
AzureIoTClient 4:233dd7616d73 457 } \
AzureIoTClient 4:233dd7616d73 458 else \
AzureIoTClient 4:233dd7616d73 459 { \
AzureIoTClient 4:233dd7616d73 460 /*fallthrough*/ \
AzureIoTClient 4:233dd7616d73 461 }
AzureIoTClient 4:233dd7616d73 462
AzureIoTClient 4:233dd7616d73 463 #define UNBUILD_DESTINATION_FIELD(value, type, name) \
AzureIoTClient 4:233dd7616d73 464 C2(destroyLocalParameter, type)(&(value->name));
AzureIoTClient 4:233dd7616d73 465
AzureIoTClient 4:233dd7616d73 466
AzureIoTClient 4:233dd7616d73 467 #define ADDRESS_MACRO(x) ,&x
AzureIoTClient 4:233dd7616d73 468
AzureIoTClient 4:233dd7616d73 469 #define KEEP_FIRST_(X, ...) X
AzureIoTClient 4:233dd7616d73 470 #ifdef _MSC_VER
AzureIoTClient 4:233dd7616d73 471 #define KEEP_FIRST(X) KEEP_FIRST_ LPAREN X)
AzureIoTClient 4:233dd7616d73 472 #else
AzureIoTClient 4:233dd7616d73 473 #define KEEP_FIRST(X) KEEP_FIRST_(X)
AzureIoTClient 4:233dd7616d73 474 #endif
AzureIoTClient 4:233dd7616d73 475
AzureIoTClient 4:233dd7616d73 476 #define PROMOTIONMAP_float double, double
AzureIoTClient 4:233dd7616d73 477 #define PROMOTIONMAP_int8_t int, int
AzureIoTClient 4:233dd7616d73 478 #define PROMOTIONMAP_uint8_t int, int
AzureIoTClient 4:233dd7616d73 479 #define PROMOTIONMAP_int16_t int, int
AzureIoTClient 4:233dd7616d73 480 #define PROMOTIONMAP__Bool int, int
AzureIoTClient 4:233dd7616d73 481 #define PROMOTIONMAP_bool int, int
AzureIoTClient 4:233dd7616d73 482
AzureIoTClient 4:233dd7616d73 483 #define CASTMAP_float (float), (float)
AzureIoTClient 4:233dd7616d73 484 #define CASTMAP_int8_t (int8_t), (int8_t)
AzureIoTClient 4:233dd7616d73 485 #define CASTMAP_uint8_t (uint8_t), (uint8_t)
AzureIoTClient 4:233dd7616d73 486 #define CASTMAP_int16_t (int16_t), (int16_t)
AzureIoTClient 4:233dd7616d73 487 #define CASTMAP__Bool 0!=, 0!=
AzureIoTClient 4:233dd7616d73 488 #define CASTMAP_bool 0!=, 0!=
AzureIoTClient 4:233dd7616d73 489
AzureIoTClient 4:233dd7616d73 490 #define EMPTY_TOKEN
AzureIoTClient 4:233dd7616d73 491
AzureIoTClient 4:233dd7616d73 492 #define ANOTHERIF(x) C2(ANOTHERIF,x)
AzureIoTClient 4:233dd7616d73 493 #define ANOTHERIF0(a,b) a
AzureIoTClient 4:233dd7616d73 494 #define ANOTHERIF1(a,b) b
AzureIoTClient 4:233dd7616d73 495 #define ANOTHERIF2(a,b) b
AzureIoTClient 4:233dd7616d73 496 #define ANOTHERIF3(a,b) b
AzureIoTClient 4:233dd7616d73 497 #define ANOTHERIF4(a,b) b
AzureIoTClient 4:233dd7616d73 498 #define ANOTHERIF5(a,b) b
AzureIoTClient 4:233dd7616d73 499 #define ANOTHERIF6(a,b) b
AzureIoTClient 4:233dd7616d73 500 #define ANOTHERIF7(a,b) b
AzureIoTClient 4:233dd7616d73 501 #define ANOTHERIF8(a,b) b
AzureIoTClient 4:233dd7616d73 502 #define ANOTHERIF9(a,b) b
AzureIoTClient 4:233dd7616d73 503 #define ANOTHERIF10(a,b) b
AzureIoTClient 4:233dd7616d73 504 #define ANOTHERIF11(a,b) b
AzureIoTClient 4:233dd7616d73 505 #define ANOTHERIF12(a,b) b
AzureIoTClient 4:233dd7616d73 506
AzureIoTClient 4:233dd7616d73 507 #define MAP_PROMOTED_TYPE(X) ANOTHERIF(DEC(COUNT_ARG(PROMOTIONMAP_##X))) (X, KEEP_FIRST(PROMOTIONMAP_##X))
AzureIoTClient 4:233dd7616d73 508 #define MAP_CAST_TYPE(X) ANOTHERIF(DEC(COUNT_ARG(CASTMAP_##X))) (EMPTY_TOKEN, KEEP_FIRST(CASTMAP_##X) )
AzureIoTClient 4:233dd7616d73 509
AzureIoTClient 4:233dd7616d73 510 #define IFCOMMA(N) C2(IFCOMMA_, N)
AzureIoTClient 4:233dd7616d73 511 #define IFCOMMA_0
AzureIoTClient 4:233dd7616d73 512 #define IFCOMMA_2
AzureIoTClient 4:233dd7616d73 513 #define IFCOMMA_4 ,
AzureIoTClient 4:233dd7616d73 514 #define IFCOMMA_6 ,
AzureIoTClient 4:233dd7616d73 515 #define IFCOMMA_8 ,
AzureIoTClient 4:233dd7616d73 516 #define IFCOMMA_10 ,
AzureIoTClient 4:233dd7616d73 517 #define IFCOMMA_12 ,
AzureIoTClient 4:233dd7616d73 518 #define IFCOMMA_14 ,
AzureIoTClient 4:233dd7616d73 519 #define IFCOMMA_16 ,
AzureIoTClient 4:233dd7616d73 520 #define IFCOMMA_18 ,
AzureIoTClient 4:233dd7616d73 521 #define IFCOMMA_20 ,
AzureIoTClient 4:233dd7616d73 522 #define IFCOMMA_22 ,
AzureIoTClient 4:233dd7616d73 523 #define IFCOMMA_24 ,
AzureIoTClient 4:233dd7616d73 524 #define IFCOMMA_26 ,
AzureIoTClient 4:233dd7616d73 525 #define IFCOMMA_28 ,
AzureIoTClient 4:233dd7616d73 526 #define IFCOMMA_30 ,
AzureIoTClient 4:233dd7616d73 527 #define IFCOMMA_32 ,
AzureIoTClient 4:233dd7616d73 528 #define IFCOMMA_34 ,
AzureIoTClient 4:233dd7616d73 529 #define IFCOMMA_36 ,
AzureIoTClient 4:233dd7616d73 530 #define IFCOMMA_38 ,
AzureIoTClient 4:233dd7616d73 531 #define IFCOMMA_40 ,
AzureIoTClient 4:233dd7616d73 532 #define IFCOMMA_42 ,
AzureIoTClient 4:233dd7616d73 533 #define IFCOMMA_44 ,
AzureIoTClient 4:233dd7616d73 534 #define IFCOMMA_46 ,
AzureIoTClient 4:233dd7616d73 535 #define IFCOMMA_48 ,
AzureIoTClient 4:233dd7616d73 536 #define IFCOMMA_50 ,
AzureIoTClient 4:233dd7616d73 537 #define IFCOMMA_52 ,
AzureIoTClient 4:233dd7616d73 538 #define IFCOMMA_54 ,
AzureIoTClient 4:233dd7616d73 539 #define IFCOMMA_56 ,
AzureIoTClient 4:233dd7616d73 540 #define IFCOMMA_58 ,
AzureIoTClient 4:233dd7616d73 541 #define IFCOMMA_60 ,
AzureIoTClient 4:233dd7616d73 542 #define IFCOMMA_62 ,
AzureIoTClient 4:233dd7616d73 543 #define IFCOMMA_64 ,
AzureIoTClient 4:233dd7616d73 544 #define IFCOMMA_66 ,
AzureIoTClient 4:233dd7616d73 545 #define IFCOMMA_68 ,
AzureIoTClient 4:233dd7616d73 546 #define IFCOMMA_70 ,
AzureIoTClient 4:233dd7616d73 547 #define IFCOMMA_72 ,
AzureIoTClient 4:233dd7616d73 548 #define IFCOMMA_74 ,
AzureIoTClient 4:233dd7616d73 549 #define IFCOMMA_76 ,
AzureIoTClient 4:233dd7616d73 550 #define IFCOMMA_78 ,
AzureIoTClient 4:233dd7616d73 551 #define IFCOMMA_80 ,
AzureIoTClient 4:233dd7616d73 552 #define IFCOMMA_82 ,
AzureIoTClient 4:233dd7616d73 553 #define IFCOMMA_84 ,
AzureIoTClient 4:233dd7616d73 554 #define IFCOMMA_86 ,
AzureIoTClient 4:233dd7616d73 555 #define IFCOMMA_88 ,
AzureIoTClient 4:233dd7616d73 556 #define IFCOMMA_90 ,
AzureIoTClient 4:233dd7616d73 557 #define IFCOMMA_92 ,
AzureIoTClient 4:233dd7616d73 558 #define IFCOMMA_94 ,
AzureIoTClient 4:233dd7616d73 559 #define IFCOMMA_96 ,
AzureIoTClient 4:233dd7616d73 560 #define IFCOMMA_98 ,
AzureIoTClient 4:233dd7616d73 561 #define IFCOMMA_100 ,
AzureIoTClient 4:233dd7616d73 562 #define IFCOMMA_102 ,
AzureIoTClient 4:233dd7616d73 563 #define IFCOMMA_104 ,
AzureIoTClient 4:233dd7616d73 564 #define IFCOMMA_106 ,
AzureIoTClient 4:233dd7616d73 565 #define IFCOMMA_108 ,
AzureIoTClient 4:233dd7616d73 566 #define IFCOMMA_110 ,
AzureIoTClient 4:233dd7616d73 567 #define IFCOMMA_112 ,
AzureIoTClient 4:233dd7616d73 568 #define IFCOMMA_114 ,
AzureIoTClient 4:233dd7616d73 569 #define IFCOMMA_116 ,
AzureIoTClient 4:233dd7616d73 570 #define IFCOMMA_118 ,
AzureIoTClient 4:233dd7616d73 571 #define IFCOMMA_120 ,
AzureIoTClient 4:233dd7616d73 572 #define IFCOMMA_122 ,
AzureIoTClient 4:233dd7616d73 573 #define IFCOMMA_124 ,
AzureIoTClient 4:233dd7616d73 574 #define IFCOMMA_126 ,
AzureIoTClient 4:233dd7616d73 575 #define IFCOMMA_128 ,
AzureIoTClient 4:233dd7616d73 576
AzureIoTClient 4:233dd7616d73 577 #define DEFINE_LOCAL_PARAMETER(type, name) type C2(name,_local);
AzureIoTClient 4:233dd7616d73 578
AzureIoTClient 4:233dd7616d73 579 #define START_BUILD_LOCAL_PARAMETER(type, name) \
AzureIoTClient 4:233dd7616d73 580 if (C2(FromAGENT_DATA_TYPE_, type)(&values[iParameter], &C2(name, _local)) != AGENT_DATA_TYPES_OK) \
AzureIoTClient 4:233dd7616d73 581 { \
AzureIoTClient 4:233dd7616d73 582 /*Codes_SRS_SERIALIZER_99_046:[ If the types of the parameters do not match the declared types, DATAPROVIDER_INVALID_ARG shall be returned.]*/ \
AzureIoTClient 4:233dd7616d73 583 result = EXECUTE_COMMAND_ERROR; \
AzureIoTClient 4:233dd7616d73 584 }\
AzureIoTClient 4:233dd7616d73 585 else \
AzureIoTClient 4:233dd7616d73 586 { \
AzureIoTClient 4:233dd7616d73 587 iParameter++;
AzureIoTClient 4:233dd7616d73 588
AzureIoTClient 4:233dd7616d73 589 #define END_BUILD_LOCAL_PARAMETER(type, name) \
AzureIoTClient 4:233dd7616d73 590 (void)C2(destroyLocalParameter, type)(&C2(name, _local)); \
AzureIoTClient 4:233dd7616d73 591 }
AzureIoTClient 4:233dd7616d73 592
AzureIoTClient 4:233dd7616d73 593 /*The following constructs have been devised to work around the precompiler bug of Visual Studio 2005, version 14.00.50727.42*/
AzureIoTClient 4:233dd7616d73 594 /* The bug is explained in https://connect.microsoft.com/VisualStudio/feedback/details/278752/comma-missing-when-using-va-args */
AzureIoTClient 4:233dd7616d73 595 /*A short description is: preprocessor is myteriously eating commas ','.
AzureIoTClient 4:233dd7616d73 596 In order to feed the appetite of the preprocessor, several constructs have
AzureIoTClient 4:233dd7616d73 597 been devised that can sustain a missing ',' while still compiling and while still doing nothing
AzureIoTClient 4:233dd7616d73 598 and while hopefully being eliminated from the code based on "doesn't do anything" so no code size penalty
AzureIoTClient 4:233dd7616d73 599 */
AzureIoTClient 4:233dd7616d73 600
AzureIoTClient 4:233dd7616d73 601 /*the reason why all these constructs work is:
AzureIoTClient 4:233dd7616d73 602 if two strings separated by a comma will lose the comma (myteriously) then they will become just one string:
AzureIoTClient 4:233dd7616d73 603 "a", "b" ------Preprocessor------> "a" "b" -----Compiler----> "ab"
AzureIoTClient 4:233dd7616d73 604 */
AzureIoTClient 4:233dd7616d73 605
AzureIoTClient 4:233dd7616d73 606 #define LOTS_OF_COMMA_TO_BE_EATEN /*there were witnesses where as many as THREE commas have been eaten!*/ \
AzureIoTClient 4:233dd7616d73 607 "0", "1", "2", "3", "4", "5", "6", "7", "8", "9"
AzureIoTClient 4:233dd7616d73 608 #define DEFINITION_THAT_CAN_SUSTAIN_A_COMMA_STEAL(name, instance) static const char* eatThese_COMMA_##name##instance[] = {LOTS_OF_COMMA_TO_BE_EATEN}
AzureIoTClient 4:233dd7616d73 609 #define INSTRUCTION_THAT_CAN_SUSTAIN_A_COMMA_STEAL 0?LOTS_OF_COMMA_TO_BE_EATEN:LOTS_OF_COMMA_TO_BE_EATEN
AzureIoTClient 4:233dd7616d73 610
AzureIoTClient 4:233dd7616d73 611 #define PUSH_LOCAL_PARAMETER(type, name) , C2(name, _local)
AzureIoTClient 4:233dd7616d73 612 #define DEFINE_FUNCTION_PARAMETER(type, name) , type name
AzureIoTClient 4:233dd7616d73 613 #define MAKE_WRAPPER_ARGUMENT(N, type, name) {TOSTRING(type), TOSTRING(name)} IFCOMMA(N)
AzureIoTClient 4:233dd7616d73 614
AzureIoTClient 4:233dd7616d73 615 /*Codes_SRS_SERIALIZER_99_019:[ Create_AGENT_DATA_TYPE_from_DOUBLE]*/
AzureIoTClient 4:233dd7616d73 616 /*Codes_SRS_SERIALIZER_99_004:[ The propertyType can be any of the following data types: double]*/
AzureIoTClient 4:233dd7616d73 617 static AGENT_DATA_TYPES_RESULT C2(ToAGENT_DATA_TYPE_, double)(AGENT_DATA_TYPE* dest, double source)
AzureIoTClient 4:233dd7616d73 618 {
AzureIoTClient 4:233dd7616d73 619 return Create_AGENT_DATA_TYPE_from_DOUBLE(dest, source);
AzureIoTClient 4:233dd7616d73 620 }
AzureIoTClient 4:233dd7616d73 621
AzureIoTClient 4:233dd7616d73 622 static AGENT_DATA_TYPES_RESULT C2(FromAGENT_DATA_TYPE_, double)(const AGENT_DATA_TYPE* agentData, double* dest)
AzureIoTClient 4:233dd7616d73 623 {
AzureIoTClient 4:233dd7616d73 624 AGENT_DATA_TYPES_RESULT result;
AzureIoTClient 4:233dd7616d73 625 if (agentData->type != EDM_DOUBLE_TYPE)
AzureIoTClient 4:233dd7616d73 626 {
AzureIoTClient 4:233dd7616d73 627 result = AGENT_DATA_TYPES_INVALID_ARG;
AzureIoTClient 4:233dd7616d73 628 }
AzureIoTClient 4:233dd7616d73 629 else
AzureIoTClient 4:233dd7616d73 630 {
AzureIoTClient 4:233dd7616d73 631 *dest = agentData->value.edmDouble.value;
AzureIoTClient 4:233dd7616d73 632 result = AGENT_DATA_TYPES_OK;
AzureIoTClient 4:233dd7616d73 633 }
AzureIoTClient 4:233dd7616d73 634 return result;
AzureIoTClient 4:233dd7616d73 635 }
AzureIoTClient 4:233dd7616d73 636
AzureIoTClient 4:233dd7616d73 637 /*Codes_SRS_SERIALIZER_99_021:[ Create_AGENT_DATA_TYPE_from_FLOAT]*/
AzureIoTClient 4:233dd7616d73 638 /*Codes_SRS_SERIALIZER_99_006:[ float]*/
AzureIoTClient 4:233dd7616d73 639 static AGENT_DATA_TYPES_RESULT C2(ToAGENT_DATA_TYPE_, float)(AGENT_DATA_TYPE* dest, float source)
AzureIoTClient 4:233dd7616d73 640 {
AzureIoTClient 4:233dd7616d73 641 return Create_AGENT_DATA_TYPE_from_FLOAT(dest, source);
AzureIoTClient 4:233dd7616d73 642 }
AzureIoTClient 4:233dd7616d73 643
AzureIoTClient 4:233dd7616d73 644 static AGENT_DATA_TYPES_RESULT C2(FromAGENT_DATA_TYPE_, float)(const AGENT_DATA_TYPE* agentData, float* dest)
AzureIoTClient 4:233dd7616d73 645 {
AzureIoTClient 4:233dd7616d73 646 AGENT_DATA_TYPES_RESULT result;
AzureIoTClient 4:233dd7616d73 647 if (agentData->type != EDM_SINGLE_TYPE)
AzureIoTClient 4:233dd7616d73 648 {
AzureIoTClient 4:233dd7616d73 649 result = AGENT_DATA_TYPES_INVALID_ARG;
AzureIoTClient 4:233dd7616d73 650 }
AzureIoTClient 4:233dd7616d73 651 else
AzureIoTClient 4:233dd7616d73 652 {
AzureIoTClient 4:233dd7616d73 653 *dest = agentData->value.edmSingle.value;
AzureIoTClient 4:233dd7616d73 654 result = AGENT_DATA_TYPES_OK;
AzureIoTClient 4:233dd7616d73 655 }
AzureIoTClient 4:233dd7616d73 656 return result;
AzureIoTClient 4:233dd7616d73 657 }
AzureIoTClient 4:233dd7616d73 658
AzureIoTClient 4:233dd7616d73 659
AzureIoTClient 4:233dd7616d73 660 /*Codes_SRS_SERIALIZER_99_020:[ Create_AGENT_DATA_TYPE_from_SINT32]*/
AzureIoTClient 4:233dd7616d73 661 /*Codes_SRS_SERIALIZER_99_005:[ int], */
AzureIoTClient 4:233dd7616d73 662 static AGENT_DATA_TYPES_RESULT C2(ToAGENT_DATA_TYPE_, int)(AGENT_DATA_TYPE* dest, int source)
AzureIoTClient 4:233dd7616d73 663 {
AzureIoTClient 4:233dd7616d73 664 return Create_AGENT_DATA_TYPE_from_SINT32(dest, source);
AzureIoTClient 4:233dd7616d73 665 }
AzureIoTClient 4:233dd7616d73 666
AzureIoTClient 4:233dd7616d73 667 static AGENT_DATA_TYPES_RESULT C2(FromAGENT_DATA_TYPE_, int)(const AGENT_DATA_TYPE* agentData, int* dest)
AzureIoTClient 4:233dd7616d73 668 {
AzureIoTClient 4:233dd7616d73 669 AGENT_DATA_TYPES_RESULT result;
AzureIoTClient 4:233dd7616d73 670 if (agentData->type != EDM_INT32_TYPE)
AzureIoTClient 4:233dd7616d73 671 {
AzureIoTClient 4:233dd7616d73 672 result = AGENT_DATA_TYPES_INVALID_ARG;
AzureIoTClient 4:233dd7616d73 673 }
AzureIoTClient 4:233dd7616d73 674 else
AzureIoTClient 4:233dd7616d73 675 {
AzureIoTClient 4:233dd7616d73 676 *dest = agentData->value.edmInt32.value;
AzureIoTClient 4:233dd7616d73 677 result = AGENT_DATA_TYPES_OK;
AzureIoTClient 4:233dd7616d73 678 }
AzureIoTClient 4:233dd7616d73 679 return result;
AzureIoTClient 4:233dd7616d73 680 }
AzureIoTClient 4:233dd7616d73 681
AzureIoTClient 4:233dd7616d73 682 /*Codes_SRS_SERIALIZER_99_022:[ Create_AGENT_DATA_TYPE_from_SINT64]*/
AzureIoTClient 4:233dd7616d73 683 /*Codes_SRS_SERIALIZER_99_007:[ long]*/
AzureIoTClient 4:233dd7616d73 684 static AGENT_DATA_TYPES_RESULT C2(ToAGENT_DATA_TYPE_, long)(AGENT_DATA_TYPE* dest, long source)
AzureIoTClient 4:233dd7616d73 685 {
AzureIoTClient 4:233dd7616d73 686 return Create_AGENT_DATA_TYPE_from_SINT64(dest, source);
AzureIoTClient 4:233dd7616d73 687 }
AzureIoTClient 4:233dd7616d73 688
AzureIoTClient 4:233dd7616d73 689 static AGENT_DATA_TYPES_RESULT C2(FromAGENT_DATA_TYPE_, long)(const AGENT_DATA_TYPE* agentData, long* dest)
AzureIoTClient 4:233dd7616d73 690 {
AzureIoTClient 4:233dd7616d73 691 AGENT_DATA_TYPES_RESULT result;
AzureIoTClient 4:233dd7616d73 692 if (agentData->type != EDM_INT64_TYPE)
AzureIoTClient 4:233dd7616d73 693 {
AzureIoTClient 4:233dd7616d73 694 result = AGENT_DATA_TYPES_INVALID_ARG;
AzureIoTClient 4:233dd7616d73 695 }
AzureIoTClient 4:233dd7616d73 696 else
AzureIoTClient 4:233dd7616d73 697 {
AzureIoTClient 4:233dd7616d73 698 *dest = (long)agentData->value.edmInt64.value;
AzureIoTClient 4:233dd7616d73 699 result = AGENT_DATA_TYPES_OK;
AzureIoTClient 4:233dd7616d73 700 }
AzureIoTClient 4:233dd7616d73 701 return result;
AzureIoTClient 4:233dd7616d73 702 }
AzureIoTClient 4:233dd7616d73 703
AzureIoTClient 4:233dd7616d73 704 /*Codes_SRS_SERIALIZER_99_023:[ Create_AGENT_DATA_TYPE_from_SINT8]*/
AzureIoTClient 4:233dd7616d73 705 /*Codes_SRS_SERIALIZER_99_008:[ int8_t]*/
AzureIoTClient 4:233dd7616d73 706 static AGENT_DATA_TYPES_RESULT C2(ToAGENT_DATA_TYPE_, int8_t)(AGENT_DATA_TYPE* dest, int8_t source)
AzureIoTClient 4:233dd7616d73 707 {
AzureIoTClient 4:233dd7616d73 708 return Create_AGENT_DATA_TYPE_from_SINT8(dest, source);
AzureIoTClient 4:233dd7616d73 709 }
AzureIoTClient 4:233dd7616d73 710
AzureIoTClient 4:233dd7616d73 711 static AGENT_DATA_TYPES_RESULT C2(FromAGENT_DATA_TYPE_, int8_t)(const AGENT_DATA_TYPE* agentData, int8_t* dest)
AzureIoTClient 4:233dd7616d73 712 {
AzureIoTClient 4:233dd7616d73 713 AGENT_DATA_TYPES_RESULT result;
AzureIoTClient 4:233dd7616d73 714 if (agentData->type != EDM_SBYTE_TYPE)
AzureIoTClient 4:233dd7616d73 715 {
AzureIoTClient 4:233dd7616d73 716 result = AGENT_DATA_TYPES_INVALID_ARG;
AzureIoTClient 4:233dd7616d73 717 }
AzureIoTClient 4:233dd7616d73 718 else
AzureIoTClient 4:233dd7616d73 719 {
AzureIoTClient 4:233dd7616d73 720 *dest = agentData->value.edmSbyte.value;
AzureIoTClient 4:233dd7616d73 721 result = AGENT_DATA_TYPES_OK;
AzureIoTClient 4:233dd7616d73 722 }
AzureIoTClient 4:233dd7616d73 723 return result;
AzureIoTClient 4:233dd7616d73 724 }
AzureIoTClient 4:233dd7616d73 725
AzureIoTClient 4:233dd7616d73 726 /*Codes_SRS_SERIALIZER_99_024:[ Create_AGENT_DATA_TYPE_from_UINT8]*/
AzureIoTClient 4:233dd7616d73 727 /*Codes_SRS_SERIALIZER_99_009:[ uint8_t]*/
AzureIoTClient 4:233dd7616d73 728 static AGENT_DATA_TYPES_RESULT C2(ToAGENT_DATA_TYPE_, uint8_t)(AGENT_DATA_TYPE* dest, uint8_t source)
AzureIoTClient 4:233dd7616d73 729 {
AzureIoTClient 4:233dd7616d73 730 return Create_AGENT_DATA_TYPE_from_UINT8(dest, source);
AzureIoTClient 4:233dd7616d73 731 }
AzureIoTClient 4:233dd7616d73 732
AzureIoTClient 4:233dd7616d73 733 static AGENT_DATA_TYPES_RESULT C2(FromAGENT_DATA_TYPE_, uint8_t)(const AGENT_DATA_TYPE* agentData, uint8_t* dest)
AzureIoTClient 4:233dd7616d73 734 {
AzureIoTClient 4:233dd7616d73 735 AGENT_DATA_TYPES_RESULT result;
AzureIoTClient 4:233dd7616d73 736 if (agentData->type != EDM_BYTE_TYPE)
AzureIoTClient 4:233dd7616d73 737 {
AzureIoTClient 4:233dd7616d73 738 result = AGENT_DATA_TYPES_INVALID_ARG;
AzureIoTClient 4:233dd7616d73 739 }
AzureIoTClient 4:233dd7616d73 740 else
AzureIoTClient 4:233dd7616d73 741 {
AzureIoTClient 4:233dd7616d73 742 *dest = agentData->value.edmByte.value;
AzureIoTClient 4:233dd7616d73 743 result = AGENT_DATA_TYPES_OK;
AzureIoTClient 4:233dd7616d73 744 }
AzureIoTClient 4:233dd7616d73 745 return result;
AzureIoTClient 4:233dd7616d73 746 }
AzureIoTClient 4:233dd7616d73 747
AzureIoTClient 4:233dd7616d73 748 /*Codes_SRS_SERIALIZER_99_025:[ Create_AGENT_DATA_TYPE_from_SINT16]*/
AzureIoTClient 4:233dd7616d73 749 /*Codes_SRS_SERIALIZER_99_010:[ int16_t]*/
AzureIoTClient 4:233dd7616d73 750 static AGENT_DATA_TYPES_RESULT C2(ToAGENT_DATA_TYPE_, int16_t)(AGENT_DATA_TYPE* dest, int16_t source)
AzureIoTClient 4:233dd7616d73 751 {
AzureIoTClient 4:233dd7616d73 752 return Create_AGENT_DATA_TYPE_from_SINT16(dest, source);
AzureIoTClient 4:233dd7616d73 753 }
AzureIoTClient 4:233dd7616d73 754
AzureIoTClient 4:233dd7616d73 755 static AGENT_DATA_TYPES_RESULT C2(FromAGENT_DATA_TYPE_, int16_t)(const AGENT_DATA_TYPE* agentData, int16_t* dest)
AzureIoTClient 4:233dd7616d73 756 {
AzureIoTClient 4:233dd7616d73 757 AGENT_DATA_TYPES_RESULT result;
AzureIoTClient 4:233dd7616d73 758 if (agentData->type != EDM_INT16_TYPE)
AzureIoTClient 4:233dd7616d73 759 {
AzureIoTClient 4:233dd7616d73 760 result = AGENT_DATA_TYPES_INVALID_ARG;
AzureIoTClient 4:233dd7616d73 761 }
AzureIoTClient 4:233dd7616d73 762 else
AzureIoTClient 4:233dd7616d73 763 {
AzureIoTClient 4:233dd7616d73 764 *dest = agentData->value.edmInt16.value;
AzureIoTClient 4:233dd7616d73 765 result = AGENT_DATA_TYPES_OK;
AzureIoTClient 4:233dd7616d73 766 }
AzureIoTClient 4:233dd7616d73 767 return result;
AzureIoTClient 4:233dd7616d73 768 }
AzureIoTClient 4:233dd7616d73 769
AzureIoTClient 4:233dd7616d73 770 /*Codes_SRS_SERIALIZER_99_026:[ Create_AGENT_DATA_TYPE_from_SINT32]*/
AzureIoTClient 4:233dd7616d73 771 /*Codes_SRS_SERIALIZER_99_011:[ int32_t]*/
AzureIoTClient 4:233dd7616d73 772 static AGENT_DATA_TYPES_RESULT C2(ToAGENT_DATA_TYPE_, int32_t)(AGENT_DATA_TYPE* dest, int32_t source)
AzureIoTClient 4:233dd7616d73 773 {
AzureIoTClient 4:233dd7616d73 774 return Create_AGENT_DATA_TYPE_from_SINT32(dest, source);
AzureIoTClient 4:233dd7616d73 775 }
AzureIoTClient 4:233dd7616d73 776
AzureIoTClient 4:233dd7616d73 777 static AGENT_DATA_TYPES_RESULT C2(FromAGENT_DATA_TYPE_, int32_t)(const AGENT_DATA_TYPE* agentData, int32_t* dest)
AzureIoTClient 4:233dd7616d73 778 {
AzureIoTClient 4:233dd7616d73 779 AGENT_DATA_TYPES_RESULT result;
AzureIoTClient 4:233dd7616d73 780 if (agentData->type != EDM_INT32_TYPE)
AzureIoTClient 4:233dd7616d73 781 {
AzureIoTClient 4:233dd7616d73 782 result = AGENT_DATA_TYPES_INVALID_ARG;
AzureIoTClient 4:233dd7616d73 783 }
AzureIoTClient 4:233dd7616d73 784 else
AzureIoTClient 4:233dd7616d73 785 {
AzureIoTClient 4:233dd7616d73 786 *dest = agentData->value.edmInt32.value;
AzureIoTClient 4:233dd7616d73 787 result = AGENT_DATA_TYPES_OK;
AzureIoTClient 4:233dd7616d73 788 }
AzureIoTClient 4:233dd7616d73 789 return result;
AzureIoTClient 4:233dd7616d73 790 }
AzureIoTClient 4:233dd7616d73 791
AzureIoTClient 4:233dd7616d73 792 /*Codes_SRS_SERIALIZER_99_027:[ Create_AGENT_DATA_TYPE_from_SINT64]*/
AzureIoTClient 4:233dd7616d73 793 /*Codes_SRS_SERIALIZER_99_012:[ int64_t]*/
AzureIoTClient 4:233dd7616d73 794 static AGENT_DATA_TYPES_RESULT C2(ToAGENT_DATA_TYPE_, int64_t)(AGENT_DATA_TYPE* dest, int64_t source)
AzureIoTClient 4:233dd7616d73 795 {
AzureIoTClient 4:233dd7616d73 796 return Create_AGENT_DATA_TYPE_from_SINT64(dest, source);
AzureIoTClient 4:233dd7616d73 797 }
AzureIoTClient 4:233dd7616d73 798
AzureIoTClient 4:233dd7616d73 799 static AGENT_DATA_TYPES_RESULT C2(FromAGENT_DATA_TYPE_, int64_t)(const AGENT_DATA_TYPE* agentData, int64_t* dest)
AzureIoTClient 4:233dd7616d73 800 {
AzureIoTClient 4:233dd7616d73 801 AGENT_DATA_TYPES_RESULT result;
AzureIoTClient 4:233dd7616d73 802 if (agentData->type != EDM_INT64_TYPE)
AzureIoTClient 4:233dd7616d73 803 {
AzureIoTClient 4:233dd7616d73 804 result = AGENT_DATA_TYPES_INVALID_ARG;
AzureIoTClient 4:233dd7616d73 805 }
AzureIoTClient 4:233dd7616d73 806 else
AzureIoTClient 4:233dd7616d73 807 {
AzureIoTClient 4:233dd7616d73 808 *dest = agentData->value.edmInt64.value;
AzureIoTClient 4:233dd7616d73 809 result = AGENT_DATA_TYPES_OK;
AzureIoTClient 4:233dd7616d73 810 }
AzureIoTClient 4:233dd7616d73 811 return result;
AzureIoTClient 4:233dd7616d73 812 }
AzureIoTClient 4:233dd7616d73 813
AzureIoTClient 4:233dd7616d73 814 /*Codes_SRS_SERIALIZER_99_013:[ bool]*/
AzureIoTClient 4:233dd7616d73 815 static AGENT_DATA_TYPES_RESULT C2(ToAGENT_DATA_TYPE_, bool)(AGENT_DATA_TYPE* dest, bool source)
AzureIoTClient 4:233dd7616d73 816 {
AzureIoTClient 4:233dd7616d73 817 return Create_EDM_BOOLEAN_from_int(dest, source == true);
AzureIoTClient 4:233dd7616d73 818 }
AzureIoTClient 4:233dd7616d73 819
AzureIoTClient 4:233dd7616d73 820 static AGENT_DATA_TYPES_RESULT C2(FromAGENT_DATA_TYPE_, bool)(const AGENT_DATA_TYPE* agentData, bool* dest)
AzureIoTClient 4:233dd7616d73 821 {
AzureIoTClient 4:233dd7616d73 822 AGENT_DATA_TYPES_RESULT result;
AzureIoTClient 4:233dd7616d73 823 if (agentData->type != EDM_BOOLEAN_TYPE)
AzureIoTClient 4:233dd7616d73 824 {
AzureIoTClient 4:233dd7616d73 825 result = AGENT_DATA_TYPES_INVALID_ARG;
AzureIoTClient 4:233dd7616d73 826 }
AzureIoTClient 4:233dd7616d73 827 else
AzureIoTClient 4:233dd7616d73 828 {
AzureIoTClient 4:233dd7616d73 829 *dest = (agentData->value.edmBoolean.value == EDM_TRUE) ? true : false;
AzureIoTClient 4:233dd7616d73 830 result = AGENT_DATA_TYPES_OK;
AzureIoTClient 4:233dd7616d73 831 }
AzureIoTClient 4:233dd7616d73 832 return result;
AzureIoTClient 4:233dd7616d73 833 }
AzureIoTClient 4:233dd7616d73 834
AzureIoTClient 4:233dd7616d73 835 /*Codes_SRS_SERIALIZER_99_014:[ ascii_char_ptr]*/
AzureIoTClient 4:233dd7616d73 836 static AGENT_DATA_TYPES_RESULT C2(ToAGENT_DATA_TYPE_, ascii_char_ptr)(AGENT_DATA_TYPE* dest, ascii_char_ptr source)
AzureIoTClient 4:233dd7616d73 837 {
AzureIoTClient 4:233dd7616d73 838 return Create_AGENT_DATA_TYPE_from_charz(dest, source);
AzureIoTClient 4:233dd7616d73 839 }
AzureIoTClient 4:233dd7616d73 840
AzureIoTClient 4:233dd7616d73 841 static AGENT_DATA_TYPES_RESULT C2(FromAGENT_DATA_TYPE_, ascii_char_ptr)(const AGENT_DATA_TYPE* agentData, ascii_char_ptr* dest)
AzureIoTClient 4:233dd7616d73 842 {
AzureIoTClient 4:233dd7616d73 843 AGENT_DATA_TYPES_RESULT result;
AzureIoTClient 4:233dd7616d73 844 if (agentData->type != EDM_STRING_TYPE)
AzureIoTClient 4:233dd7616d73 845 {
AzureIoTClient 4:233dd7616d73 846 result = AGENT_DATA_TYPES_INVALID_ARG;
AzureIoTClient 4:233dd7616d73 847 }
AzureIoTClient 4:233dd7616d73 848 else
AzureIoTClient 4:233dd7616d73 849 {
AzureIoTClient 4:233dd7616d73 850 *dest = agentData->value.edmString.chars;
AzureIoTClient 4:233dd7616d73 851 result = AGENT_DATA_TYPES_OK;
AzureIoTClient 4:233dd7616d73 852 }
AzureIoTClient 4:233dd7616d73 853 return result;
AzureIoTClient 4:233dd7616d73 854 }
AzureIoTClient 4:233dd7616d73 855
AzureIoTClient 4:233dd7616d73 856 static AGENT_DATA_TYPES_RESULT C2(ToAGENT_DATA_TYPE_, ascii_char_ptr_no_quotes)(AGENT_DATA_TYPE* dest, ascii_char_ptr_no_quotes source)
AzureIoTClient 4:233dd7616d73 857 {
AzureIoTClient 4:233dd7616d73 858 return Create_AGENT_DATA_TYPE_from_charz_no_quotes(dest, source);
AzureIoTClient 4:233dd7616d73 859 }
AzureIoTClient 4:233dd7616d73 860
AzureIoTClient 4:233dd7616d73 861 static AGENT_DATA_TYPES_RESULT C2(FromAGENT_DATA_TYPE_, ascii_char_ptr_no_quotes)(const AGENT_DATA_TYPE* agentData, ascii_char_ptr_no_quotes* dest)
AzureIoTClient 4:233dd7616d73 862 {
AzureIoTClient 4:233dd7616d73 863 AGENT_DATA_TYPES_RESULT result;
AzureIoTClient 4:233dd7616d73 864 if (agentData->type != EDM_STRING_NO_QUOTES_TYPE)
AzureIoTClient 4:233dd7616d73 865 {
AzureIoTClient 4:233dd7616d73 866 result = AGENT_DATA_TYPES_INVALID_ARG;
AzureIoTClient 4:233dd7616d73 867 }
AzureIoTClient 4:233dd7616d73 868 else
AzureIoTClient 4:233dd7616d73 869 {
AzureIoTClient 4:233dd7616d73 870 *dest = agentData->value.edmStringNoQuotes.chars;
AzureIoTClient 4:233dd7616d73 871 result = AGENT_DATA_TYPES_OK;
AzureIoTClient 4:233dd7616d73 872 }
AzureIoTClient 4:233dd7616d73 873 return result;
AzureIoTClient 4:233dd7616d73 874 }
AzureIoTClient 4:233dd7616d73 875
AzureIoTClient 4:233dd7616d73 876 /*Codes_SRS_SERIALIZER_99_051:[ EDM_DATE_TIME_OFFSET*/
AzureIoTClient 4:233dd7616d73 877 /*Codes_SRS_SERIALIZER_99_053:[Create_AGENT_DATA_TYPE_from_EDM_DATE_TIME_OFFSET]*/
AzureIoTClient 4:233dd7616d73 878 static AGENT_DATA_TYPES_RESULT C2(ToAGENT_DATA_TYPE_, EDM_DATE_TIME_OFFSET)(AGENT_DATA_TYPE* dest, EDM_DATE_TIME_OFFSET source)
AzureIoTClient 4:233dd7616d73 879 {
AzureIoTClient 4:233dd7616d73 880 return Create_AGENT_DATA_TYPE_from_EDM_DATE_TIME_OFFSET(dest, source);
AzureIoTClient 4:233dd7616d73 881 }
AzureIoTClient 4:233dd7616d73 882
AzureIoTClient 4:233dd7616d73 883 static AGENT_DATA_TYPES_RESULT C2(FromAGENT_DATA_TYPE_, EDM_DATE_TIME_OFFSET)(const AGENT_DATA_TYPE* agentData, EDM_DATE_TIME_OFFSET* dest)
AzureIoTClient 4:233dd7616d73 884 {
AzureIoTClient 4:233dd7616d73 885 AGENT_DATA_TYPES_RESULT result;
AzureIoTClient 4:233dd7616d73 886 if (agentData->type != EDM_DATE_TIME_OFFSET_TYPE)
AzureIoTClient 4:233dd7616d73 887 {
AzureIoTClient 4:233dd7616d73 888 result = AGENT_DATA_TYPES_INVALID_ARG;
AzureIoTClient 4:233dd7616d73 889 }
AzureIoTClient 4:233dd7616d73 890 else
AzureIoTClient 4:233dd7616d73 891 {
AzureIoTClient 4:233dd7616d73 892 *dest = agentData->value.edmDateTimeOffset;
AzureIoTClient 4:233dd7616d73 893 result = AGENT_DATA_TYPES_OK;
AzureIoTClient 4:233dd7616d73 894 }
AzureIoTClient 4:233dd7616d73 895 return result;
AzureIoTClient 4:233dd7616d73 896 }
AzureIoTClient 4:233dd7616d73 897
AzureIoTClient 4:233dd7616d73 898 /*Codes_SRS_SERIALIZER_99_072:[ EDM_GUID]*/
AzureIoTClient 4:233dd7616d73 899 /*Codes_SRS_SERIALIZER_99_073:[ Create_AGENT_DATA_TYPE_from_EDM_GUID]*/
AzureIoTClient 4:233dd7616d73 900 static AGENT_DATA_TYPES_RESULT C2(ToAGENT_DATA_TYPE_, EDM_GUID)(AGENT_DATA_TYPE* dest, EDM_GUID guid)
AzureIoTClient 4:233dd7616d73 901 {
AzureIoTClient 4:233dd7616d73 902 return Create_AGENT_DATA_TYPE_from_EDM_GUID(dest, guid);
AzureIoTClient 4:233dd7616d73 903 }
AzureIoTClient 4:233dd7616d73 904
AzureIoTClient 4:233dd7616d73 905 static AGENT_DATA_TYPES_RESULT C2(FromAGENT_DATA_TYPE_, EDM_GUID)(const AGENT_DATA_TYPE* agentData, EDM_GUID* dest)
AzureIoTClient 4:233dd7616d73 906 {
AzureIoTClient 4:233dd7616d73 907 AGENT_DATA_TYPES_RESULT result;
AzureIoTClient 4:233dd7616d73 908 if (agentData->type != EDM_GUID_TYPE)
AzureIoTClient 4:233dd7616d73 909 {
AzureIoTClient 4:233dd7616d73 910 result = AGENT_DATA_TYPES_INVALID_ARG;
AzureIoTClient 4:233dd7616d73 911 }
AzureIoTClient 4:233dd7616d73 912 else
AzureIoTClient 4:233dd7616d73 913 {
AzureIoTClient 4:233dd7616d73 914 memcpy(dest->GUID, agentData->value.edmGuid.GUID, 16);
AzureIoTClient 4:233dd7616d73 915 result = AGENT_DATA_TYPES_OK;
AzureIoTClient 4:233dd7616d73 916 }
AzureIoTClient 4:233dd7616d73 917 return result;
AzureIoTClient 4:233dd7616d73 918 }
AzureIoTClient 4:233dd7616d73 919
AzureIoTClient 4:233dd7616d73 920 /*Codes_SRS_SERIALIZER_99_074:[ EDM_BINARY]*/
AzureIoTClient 4:233dd7616d73 921 /*Codes_SRS_SERIALIZER_99_075:[ Create_AGENT_DATA_TYPE_from_EDM_BINARY]*/
AzureIoTClient 4:233dd7616d73 922 static AGENT_DATA_TYPES_RESULT C2(ToAGENT_DATA_TYPE_, EDM_BINARY)(AGENT_DATA_TYPE* dest, EDM_BINARY edmBinary)
AzureIoTClient 4:233dd7616d73 923 {
AzureIoTClient 4:233dd7616d73 924 return Create_AGENT_DATA_TYPE_from_EDM_BINARY(dest, edmBinary);
AzureIoTClient 4:233dd7616d73 925 }
AzureIoTClient 4:233dd7616d73 926
AzureIoTClient 4:233dd7616d73 927 static AGENT_DATA_TYPES_RESULT C2(FromAGENT_DATA_TYPE_, EDM_BINARY)(const AGENT_DATA_TYPE* agentData, EDM_BINARY* dest)
AzureIoTClient 4:233dd7616d73 928 {
AzureIoTClient 4:233dd7616d73 929 AGENT_DATA_TYPES_RESULT result;
AzureIoTClient 4:233dd7616d73 930 if (agentData->type != EDM_BINARY_TYPE)
AzureIoTClient 4:233dd7616d73 931 {
AzureIoTClient 4:233dd7616d73 932 result = AGENT_DATA_TYPES_INVALID_ARG;
AzureIoTClient 4:233dd7616d73 933 }
AzureIoTClient 4:233dd7616d73 934 else
AzureIoTClient 4:233dd7616d73 935 {
AzureIoTClient 4:233dd7616d73 936 if ((dest->data = (unsigned char *)malloc(agentData->value.edmBinary.size)) == NULL) /*cast because this get included in a C++ file.*/
AzureIoTClient 4:233dd7616d73 937 {
AzureIoTClient 4:233dd7616d73 938 result = AGENT_DATA_TYPES_ERROR;
AzureIoTClient 4:233dd7616d73 939 }
AzureIoTClient 4:233dd7616d73 940 else
AzureIoTClient 4:233dd7616d73 941 {
AzureIoTClient 4:233dd7616d73 942 memcpy(dest->data, agentData->value.edmBinary.data, agentData->value.edmBinary.size);
AzureIoTClient 4:233dd7616d73 943 dest->size = agentData->value.edmBinary.size;
AzureIoTClient 4:233dd7616d73 944 result = AGENT_DATA_TYPES_OK;
AzureIoTClient 4:233dd7616d73 945 }
AzureIoTClient 4:233dd7616d73 946 }
AzureIoTClient 4:233dd7616d73 947 return result;
AzureIoTClient 4:233dd7616d73 948 }
AzureIoTClient 4:233dd7616d73 949
AzureIoTClient 4:233dd7616d73 950 static void C2(destroyLocalParameter, EDM_BINARY)(EDM_BINARY* value)
AzureIoTClient 4:233dd7616d73 951 {
AzureIoTClient 4:233dd7616d73 952 if (value != NULL)
AzureIoTClient 4:233dd7616d73 953 {
AzureIoTClient 4:233dd7616d73 954 free(value->data);
AzureIoTClient 4:233dd7616d73 955 value->data = NULL;
AzureIoTClient 4:233dd7616d73 956 value->size = 0;
AzureIoTClient 4:233dd7616d73 957 }
AzureIoTClient 4:233dd7616d73 958 }
AzureIoTClient 4:233dd7616d73 959
AzureIoTClient 4:233dd7616d73 960 static void C2(destroyLocalParameter, EDM_BOOLEAN)(EDM_BOOLEAN* value)
AzureIoTClient 4:233dd7616d73 961 {
AzureIoTClient 4:233dd7616d73 962 (void)value;
AzureIoTClient 4:233dd7616d73 963 }
AzureIoTClient 4:233dd7616d73 964
AzureIoTClient 4:233dd7616d73 965 static void C2(destroyLocalParameter, EDM_BYTE)(EDM_BYTE* value)
AzureIoTClient 4:233dd7616d73 966 {
AzureIoTClient 4:233dd7616d73 967 (void)value;
AzureIoTClient 4:233dd7616d73 968 }
AzureIoTClient 4:233dd7616d73 969
AzureIoTClient 4:233dd7616d73 970 static void C2(destroyLocalParameter, EDM_DATE)(EDM_DATE* value)
AzureIoTClient 4:233dd7616d73 971 {
AzureIoTClient 4:233dd7616d73 972 (void)value;
AzureIoTClient 4:233dd7616d73 973 }
AzureIoTClient 4:233dd7616d73 974
AzureIoTClient 4:233dd7616d73 975 static void C2(destroyLocalParameter, EDM_DATE_TIME_OFFSET)(EDM_DATE_TIME_OFFSET* value)
AzureIoTClient 4:233dd7616d73 976 {
AzureIoTClient 4:233dd7616d73 977 (void)value;
AzureIoTClient 4:233dd7616d73 978 }
AzureIoTClient 4:233dd7616d73 979
AzureIoTClient 4:233dd7616d73 980 static void C2(destroyLocalParameter, EDM_DECIMAL)(EDM_DECIMAL* value)
AzureIoTClient 4:233dd7616d73 981 {
AzureIoTClient 4:233dd7616d73 982 if (value != NULL)
AzureIoTClient 4:233dd7616d73 983 {
AzureIoTClient 4:233dd7616d73 984 STRING_delete(value->value);
AzureIoTClient 4:233dd7616d73 985 value->value = NULL;
AzureIoTClient 4:233dd7616d73 986 }
AzureIoTClient 4:233dd7616d73 987 }
AzureIoTClient 4:233dd7616d73 988
AzureIoTClient 4:233dd7616d73 989 static void C2(destroyLocalParameter, EDM_DOUBLE)(EDM_DOUBLE* value)
AzureIoTClient 4:233dd7616d73 990 {
AzureIoTClient 4:233dd7616d73 991 (void)value;
AzureIoTClient 4:233dd7616d73 992 }
AzureIoTClient 4:233dd7616d73 993
AzureIoTClient 4:233dd7616d73 994 static void C2(destroyLocalParameter, EDM_DURATION)(EDM_DURATION* value)
AzureIoTClient 4:233dd7616d73 995 {
AzureIoTClient 4:233dd7616d73 996 if (value != NULL)
AzureIoTClient 4:233dd7616d73 997 {
AzureIoTClient 4:233dd7616d73 998 free(value->digits);
AzureIoTClient 4:233dd7616d73 999 value->digits = NULL;
AzureIoTClient 4:233dd7616d73 1000 value->nDigits = 0;
AzureIoTClient 4:233dd7616d73 1001 }
AzureIoTClient 4:233dd7616d73 1002 }
AzureIoTClient 4:233dd7616d73 1003
AzureIoTClient 4:233dd7616d73 1004 static void C2(destroyLocalParameter, EDM_GUID)(EDM_GUID* value)
AzureIoTClient 4:233dd7616d73 1005 {
AzureIoTClient 4:233dd7616d73 1006 (void)value;
AzureIoTClient 4:233dd7616d73 1007 }
AzureIoTClient 4:233dd7616d73 1008
AzureIoTClient 4:233dd7616d73 1009 static void C2(destroyLocalParameter, EDM_INT16)(EDM_INT16* value)
AzureIoTClient 4:233dd7616d73 1010 {
AzureIoTClient 4:233dd7616d73 1011 (void)value;
AzureIoTClient 4:233dd7616d73 1012 }
AzureIoTClient 4:233dd7616d73 1013
AzureIoTClient 4:233dd7616d73 1014 static void C2(destroyLocalParameter, EDM_INT32)(EDM_INT32* value)
AzureIoTClient 4:233dd7616d73 1015 {
AzureIoTClient 4:233dd7616d73 1016 (void)value;
AzureIoTClient 4:233dd7616d73 1017 }
AzureIoTClient 4:233dd7616d73 1018
AzureIoTClient 4:233dd7616d73 1019 static void C2(destroyLocalParameter, EDM_INT64)(EDM_INT64* value)
AzureIoTClient 4:233dd7616d73 1020 {
AzureIoTClient 4:233dd7616d73 1021 (void)value;
AzureIoTClient 4:233dd7616d73 1022 }
AzureIoTClient 4:233dd7616d73 1023
AzureIoTClient 4:233dd7616d73 1024 static void C2(destroyLocalParameter, EDM_SBYTE)(EDM_SBYTE* value)
AzureIoTClient 4:233dd7616d73 1025 {
AzureIoTClient 4:233dd7616d73 1026 (void)value;
AzureIoTClient 4:233dd7616d73 1027 }
AzureIoTClient 4:233dd7616d73 1028
AzureIoTClient 4:233dd7616d73 1029 static void C2(destroyLocalParameter, EDM_SINGLE)(EDM_SINGLE* value)
AzureIoTClient 4:233dd7616d73 1030 {
AzureIoTClient 4:233dd7616d73 1031 (void)value;
AzureIoTClient 4:233dd7616d73 1032 }
AzureIoTClient 4:233dd7616d73 1033
AzureIoTClient 4:233dd7616d73 1034 static void C2(destroyLocalParameter, EDM_STRING)(EDM_STRING* value)
AzureIoTClient 4:233dd7616d73 1035 {
AzureIoTClient 4:233dd7616d73 1036 (void)value;
AzureIoTClient 4:233dd7616d73 1037 }
AzureIoTClient 4:233dd7616d73 1038
AzureIoTClient 4:233dd7616d73 1039
AzureIoTClient 4:233dd7616d73 1040 static void C2(destroyLocalParameter, EDM_TIME_OF_DAY)(EDM_TIME_OF_DAY* value)
AzureIoTClient 4:233dd7616d73 1041 {
AzureIoTClient 4:233dd7616d73 1042 (void)value;
AzureIoTClient 4:233dd7616d73 1043 }
AzureIoTClient 4:233dd7616d73 1044
AzureIoTClient 4:233dd7616d73 1045 static void C2(destroyLocalParameter, int)(int* value)
AzureIoTClient 4:233dd7616d73 1046 {
AzureIoTClient 4:233dd7616d73 1047 (void)value;
AzureIoTClient 4:233dd7616d73 1048 }
AzureIoTClient 4:233dd7616d73 1049
AzureIoTClient 4:233dd7616d73 1050 static void C2(destroyLocalParameter, float)(float* value)
AzureIoTClient 4:233dd7616d73 1051 {
AzureIoTClient 4:233dd7616d73 1052 (void)value;
AzureIoTClient 4:233dd7616d73 1053 }
AzureIoTClient 4:233dd7616d73 1054
AzureIoTClient 4:233dd7616d73 1055 static void C2(destroyLocalParameter, double)(double* value)
AzureIoTClient 4:233dd7616d73 1056 {
AzureIoTClient 4:233dd7616d73 1057 (void)value;
AzureIoTClient 4:233dd7616d73 1058 }
AzureIoTClient 4:233dd7616d73 1059
AzureIoTClient 4:233dd7616d73 1060 static void C2(destroyLocalParameter, long)(long* value)
AzureIoTClient 4:233dd7616d73 1061 {
AzureIoTClient 4:233dd7616d73 1062 (void)value;
AzureIoTClient 4:233dd7616d73 1063 }
AzureIoTClient 4:233dd7616d73 1064
AzureIoTClient 4:233dd7616d73 1065 static void C2(destroyLocalParameter, int8_t)(int8_t* value)
AzureIoTClient 4:233dd7616d73 1066 {
AzureIoTClient 4:233dd7616d73 1067 (void)value;
AzureIoTClient 4:233dd7616d73 1068 }
AzureIoTClient 4:233dd7616d73 1069
AzureIoTClient 4:233dd7616d73 1070 static void C2(destroyLocalParameter, uint8_t)(uint8_t* value)
AzureIoTClient 4:233dd7616d73 1071 {
AzureIoTClient 4:233dd7616d73 1072 (void)value;
AzureIoTClient 4:233dd7616d73 1073 }
AzureIoTClient 4:233dd7616d73 1074
AzureIoTClient 4:233dd7616d73 1075 static void C2(destroyLocalParameter, int16_t)(int16_t* value)
AzureIoTClient 4:233dd7616d73 1076 {
AzureIoTClient 4:233dd7616d73 1077 (void)value;
AzureIoTClient 4:233dd7616d73 1078 }
AzureIoTClient 4:233dd7616d73 1079
AzureIoTClient 4:233dd7616d73 1080 static void C2(destroyLocalParameter, int32_t)(int32_t* value)
AzureIoTClient 4:233dd7616d73 1081 {
AzureIoTClient 4:233dd7616d73 1082 (void)value;
AzureIoTClient 4:233dd7616d73 1083 }
AzureIoTClient 4:233dd7616d73 1084
AzureIoTClient 4:233dd7616d73 1085 static void C2(destroyLocalParameter, int64_t)(int64_t* value)
AzureIoTClient 4:233dd7616d73 1086 {
AzureIoTClient 4:233dd7616d73 1087 (void)value;
AzureIoTClient 4:233dd7616d73 1088 }
AzureIoTClient 4:233dd7616d73 1089
AzureIoTClient 4:233dd7616d73 1090 static void C2(destroyLocalParameter, bool)(bool* value)
AzureIoTClient 4:233dd7616d73 1091 {
AzureIoTClient 4:233dd7616d73 1092 (void)value;
AzureIoTClient 4:233dd7616d73 1093 }
AzureIoTClient 4:233dd7616d73 1094
AzureIoTClient 4:233dd7616d73 1095 static void C2(destroyLocalParameter, ascii_char_ptr)(ascii_char_ptr* value)
AzureIoTClient 4:233dd7616d73 1096 {
AzureIoTClient 4:233dd7616d73 1097 (void)value;
AzureIoTClient 4:233dd7616d73 1098 }
AzureIoTClient 4:233dd7616d73 1099
AzureIoTClient 4:233dd7616d73 1100 static void C2(destroyLocalParameter, ascii_char_ptr_no_quotes)(ascii_char_ptr_no_quotes* value)
AzureIoTClient 4:233dd7616d73 1101 {
AzureIoTClient 4:233dd7616d73 1102 (void)value;
AzureIoTClient 4:233dd7616d73 1103 }
AzureIoTClient 4:233dd7616d73 1104
AzureIoTClient 4:233dd7616d73 1105 #ifdef __cplusplus
AzureIoTClient 4:233dd7616d73 1106 }
AzureIoTClient 4:233dd7616d73 1107 #endif
AzureIoTClient 4:233dd7616d73 1108
AzureIoTClient 4:233dd7616d73 1109 #endif /*SERIALIZER_H*/
AzureIoTClient 4:233dd7616d73 1110
AzureIoTClient 4:233dd7616d73 1111