1 | // Copyright (c) Microsoft. All rights reserved.
|
---|
2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
---|
3 |
|
---|
4 | #ifndef AGENT_DATA_TYPES_H
|
---|
5 | #define AGENT_DATA_TYPES_H
|
---|
6 |
|
---|
7 | #ifdef __cplusplus
|
---|
8 | #include <cstdint>
|
---|
9 | #include <ctime>
|
---|
10 | #include <cstddef>
|
---|
11 | #else
|
---|
12 | #if ((defined _WIN32_WCE) && _WIN32_WCE==0x0600)
|
---|
13 | #include "stdint_ce6.h"
|
---|
14 | #else
|
---|
15 | #include <stdint.h>
|
---|
16 | #endif
|
---|
17 | #include <stddef.h>
|
---|
18 | #endif
|
---|
19 |
|
---|
20 | #include "azure_c_shared_utility/agenttime.h"
|
---|
21 | #include "azure_macro_utils/macro_utils.h"
|
---|
22 | #include "azure_c_shared_utility/strings.h"
|
---|
23 |
|
---|
24 | /*Codes_SRS_AGENT_TYPE_SYSTEM_99_001:[ AGENT_TYPE_SYSTEM shall have the following interface]*/
|
---|
25 |
|
---|
26 | #ifdef __cplusplus
|
---|
27 | extern "C"
|
---|
28 | {
|
---|
29 | #endif
|
---|
30 |
|
---|
31 | /*the following forward declarations the closest implementation to "interface" in OOP*/
|
---|
32 | struct AGENT_DATA_TYPE_TAG;
|
---|
33 | typedef struct AGENT_DATA_TYPE_TAG AGENT_DATA_TYPE;
|
---|
34 |
|
---|
35 | /*this file contains the definitions of the data types of EDM*/
|
---|
36 | /*the types are taken from */
|
---|
37 | /*http://docs.oasis-open.org/odata/odata/v4.0/cos01/part3-csdl/odata-v4.0-cos01-part3-csdl.html*/
|
---|
38 | /*chapter 4.4 - "Primitive Data Types" */
|
---|
39 |
|
---|
40 | /*the C implementation of these types follows:*/
|
---|
41 | /*even the simpler types are encapsulated in structs to purposely avoid compiler promotions/casts etc*/
|
---|
42 |
|
---|
43 | /*Binary data.*/
|
---|
44 | typedef struct EDM_BINARY_TAG
|
---|
45 | {
|
---|
46 | size_t size;
|
---|
47 | unsigned char* data;
|
---|
48 | }EDM_BINARY;
|
---|
49 |
|
---|
50 | #define EDM_BOOLEANS_VALUES \
|
---|
51 | EDM_TRUE, \
|
---|
52 | EDM_FALSE
|
---|
53 |
|
---|
54 | MU_DEFINE_ENUM_WITHOUT_INVALID(EDM_BOOLEANS, EDM_BOOLEANS_VALUES);
|
---|
55 |
|
---|
56 | /*ispositiveinfinity*/
|
---|
57 |
|
---|
58 | #ifdef _MSC_VER
|
---|
59 | #define ISPOSITIVEINFINITY(x) ((_finite((x))==0) && ((_fpclass((x)) & _FPCLASS_PINF) == _FPCLASS_PINF))
|
---|
60 | #else
|
---|
61 | #if defined __STDC_VERSION__
|
---|
62 | #if ((__STDC_VERSION__ == 199901L) || (__STDC_VERSION__ == 201112L) || (__STDC_VERSION__ == 201710L))
|
---|
63 | /*C99, C11 or C18 compiler*/
|
---|
64 | #define ISPOSITIVEINFINITY(x) (isinf((x)) && (signbit((x))==0))
|
---|
65 | #else
|
---|
66 | #error update this file to contain the latest C standard.
|
---|
67 | #endif
|
---|
68 | #else
|
---|
69 | #ifdef __cplusplus
|
---|
70 | #define ISPOSITIVEINFINITY(x) (std::isinf((x)) && (signbit((x))==0))
|
---|
71 | #else
|
---|
72 | #error unknown (or C89) compiler, must provide a definition for ISPOSITIVEINFINITY
|
---|
73 | #endif
|
---|
74 | #endif
|
---|
75 | #endif
|
---|
76 |
|
---|
77 | #ifdef _MSC_VER
|
---|
78 | /*not exactly signbit*/
|
---|
79 | #define ISNEGATIVEINFINITY(x) ((_finite((x))==0) && ((_fpclass((x)) & _FPCLASS_NINF) == _FPCLASS_NINF))
|
---|
80 | #else
|
---|
81 | #if defined __STDC_VERSION__
|
---|
82 | #if ((__STDC_VERSION__ == 199901L) || (__STDC_VERSION__ == 201112L) || (__STDC_VERSION__ == 201710L))
|
---|
83 | /*C99, C11 or C18 compiler*/
|
---|
84 | #define ISNEGATIVEINFINITY(x) (isinf((x)) && (signbit((x))!=0))
|
---|
85 | #else
|
---|
86 | #error update this file to contain the latest C standard.
|
---|
87 | #endif
|
---|
88 | #else
|
---|
89 | #ifdef __cplusplus
|
---|
90 | #define ISNEGATIVEINFINITY(x) (std::isinf((x)) && (signbit((x)) != 0))
|
---|
91 | #else
|
---|
92 | #error unknown (or C89) compiler, must provide a definition for ISNEGATIVEINFINITY
|
---|
93 | #endif
|
---|
94 | #endif
|
---|
95 | #endif
|
---|
96 |
|
---|
97 | /*Binary-valued logic.*/
|
---|
98 | typedef struct EDM_BOOLEAN_TAG
|
---|
99 | {
|
---|
100 | EDM_BOOLEANS value;
|
---|
101 | }EDM_BOOLEAN;
|
---|
102 |
|
---|
103 | /*Unsigned 8-bit integer*/
|
---|
104 | typedef struct EDM_BYTE_TAG
|
---|
105 | {
|
---|
106 | uint8_t value;
|
---|
107 | } EDM_BYTE;
|
---|
108 |
|
---|
109 | /*Date without a time-zone offset*/
|
---|
110 | /*The edm:Date expression evaluates to a primitive date value. A date expression MUST be assigned a
|
---|
111 | value of type xs:date, see [XML-Schema-2], section 3.3.9. The value MUST also conform to rule
|
---|
112 | dateValue in [OData-ABNF], i.e. it MUST NOT contain a time-zone offset.*/
|
---|
113 | /*section 3.3.9: date uses the date/timeSevenPropertyModel, with hour, minute, and second required to be absent.*/
|
---|
114 | /*dateValue in OData-ABNF is : dateValue = year "-" month "-" day */
|
---|
115 | /*year = [ "-" ] ( "0" 3DIGIT / oneToNine 3*DIGIT )
|
---|
116 | month = "0" oneToNine
|
---|
117 | / "1" ( "0" / "1" / "2" )
|
---|
118 | day = "0" oneToNine
|
---|
119 | / ( "1" / "2" ) DIGIT
|
---|
120 | / "3" ( "0" / "1" )*/
|
---|
121 | typedef struct EDM_DATE_TAG
|
---|
122 | {
|
---|
123 | int16_t year; /*can represent all values for a year*/ /*they can be between -9999 and 9999*/
|
---|
124 | uint8_t month;
|
---|
125 | uint8_t day;
|
---|
126 | } EDM_DATE;
|
---|
127 |
|
---|
128 |
|
---|
129 | /*The edm:DateTimeOffset expression evaluates to a primitive date/time value with a time-zone offset.
|
---|
130 | A date/time expression MUST be assigned a value of type xs:dateTimeStamp, see [XML-Schema-2],
|
---|
131 | section 3.4.28. The value MUST also conform to rule dateTimeOffsetValue in [OData-ABNF], i.e. it
|
---|
132 | MUST NOT contain an end-of-day fragment (24:00:00).*/
|
---|
133 | /*section 3.4.28 says : dateTimeStampLexicalRep ::= yearFrag '-' monthFrag '-' dayFrag 'T' ((hourFrag ':' minuteFrag ':' secondFrag) | endOfDayFrag) timezoneFrag?*/
|
---|
134 | /*[OData-ABNF] says: dateTimeOffsetValue = year "-" month "-" day "T" hour ":" minute [ ":" second [ "." fractionalSeconds ] ] ( "Z" / sign hour ":" minute )*/
|
---|
135 | /*fractionalSeconds = 1*12DIGIT, FYI*/
|
---|
136 | typedef struct EDM_DATE_TIME_OFFSET_TAG
|
---|
137 | {
|
---|
138 | struct tm dateTime;
|
---|
139 | uint8_t hasFractionalSecond;
|
---|
140 | uint64_t fractionalSecond; /*because UINT32 only has 10 digits*/
|
---|
141 | uint8_t hasTimeZone;
|
---|
142 | int8_t timeZoneHour;
|
---|
143 | uint8_t timeZoneMinute;
|
---|
144 | }EDM_DATE_TIME_OFFSET;
|
---|
145 |
|
---|
146 | /*Edm.Guid*/
|
---|
147 | /*16-byte (128-bit) unique identifier*/
|
---|
148 | /*The edm:Guid expression evaluates to a primitive 32-character string value. A guid expression MUST be
|
---|
149 | assigned a value conforming to the rule guidValue in [OData-ABNF].*/
|
---|
150 | /*guidValue is 8HEXDIG "-" 4HEXDIG "-" 4HEXDIG "-" 4HEXDIG "-" 12HEXDIG*/
|
---|
151 | typedef struct EDM_GUID_TAG
|
---|
152 | {
|
---|
153 | uint8_t GUID[16];
|
---|
154 | }EDM_GUID;
|
---|
155 |
|
---|
156 |
|
---|
157 | /*Edm.Decimal*/
|
---|
158 | /*The edm:Decimal expression evaluates to a primitive decimal value. A decimal expression MUST be
|
---|
159 | assigned a value conforming to the rule decimalValue in [OData-ABNF].*/
|
---|
160 | /*[OData-ABNF] says: decimalValue = [SIGN] 1*DIGIT ["." 1*DIGIT] */
|
---|
161 | /* this is binary coded decimal style then*/
|
---|
162 | typedef struct EDM_DECIMAL_TAG
|
---|
163 | {
|
---|
164 | STRING_HANDLE value;
|
---|
165 | } EDM_DECIMAL;
|
---|
166 |
|
---|
167 | /*Edm.Double*/
|
---|
168 | /*IEEE 754 binary64 floating-point number (15-17 decimal digits)*/
|
---|
169 |
|
---|
170 | typedef struct EDM_DOUBLE_TAG
|
---|
171 | {
|
---|
172 | double value;
|
---|
173 | } EDM_DOUBLE;
|
---|
174 |
|
---|
175 |
|
---|
176 | /*Edm.Duration*/
|
---|
177 | /*Signed duration in days, hours, minutes, and (sub)seconds*/
|
---|
178 | /*The edm:Duration expression evaluates to a primitive duration value. A duration expression MUST be
|
---|
179 | assigned a value of type xs:dayTimeDuration, see [XML-Schema-2], section 3.4.27.*/
|
---|
180 | /*XML-Schema section 3.4.27 says: "[...]leaving only those with day, hour, minutes, and/or seconds fields." */
|
---|
181 | /*day is "unsignedNoDecimalPtNumeral" and that can have as many digits... ?*/
|
---|
182 | typedef struct EDM_DURATION_TAG
|
---|
183 | {
|
---|
184 | size_t nDigits;
|
---|
185 | char* digits;
|
---|
186 | }
|
---|
187 | EDM_DURATION;
|
---|
188 |
|
---|
189 |
|
---|
190 | /*Edm.Int16*/
|
---|
191 | /*Signed 16-bit integer*/
|
---|
192 | /*[OData=ABNF] says about Int16: numbers in the range from -32768 to 32767 */
|
---|
193 | /*this is not C compliant, because C89 has for (read:guarantees) short SHRT_MIN -32767... (notice how it misses -32768)*/
|
---|
194 | /*C99 has the same*/
|
---|
195 | /*C11 has the same*/
|
---|
196 | /*platform types has to check for -32768 compliance*/
|
---|
197 | typedef struct EDM_INT16_TAG
|
---|
198 | {
|
---|
199 | int16_t value;
|
---|
200 | } EDM_INT16;
|
---|
201 |
|
---|
202 | /*Edm.Int32*/
|
---|
203 | /*Signed 32-bit integer*/
|
---|
204 | /*OData-ABNF has for int32Value = [ sign ] 1*10DIGIT ; numbers in the range from -2147483648 to 2147483647*/
|
---|
205 | /*same issue as for EDM_16*/
|
---|
206 | /*platform types has to check compliance based on LONG_MIN #define*/
|
---|
207 | typedef struct EDM_INT32_TAG
|
---|
208 | {
|
---|
209 | int32_t value;
|
---|
210 | } EDM_INT32;
|
---|
211 |
|
---|
212 | /*Edm.Int64*/
|
---|
213 | /*Signed 64-bit integer*/
|
---|
214 | /*OData=ABNF: int64Value = [ sign ] 1*19DIGIT ; numbers in the range from -9223372036854775808 to 9223372036854775807*/
|
---|
215 | /*C89 has no mention of anything on 64bits*/
|
---|
216 | /*C99 mention LLONG_MIN as -9223372036854775807 and LLONG_MAX as 9223372036854775807*/
|
---|
217 | /*C11 is the same as C99*/
|
---|
218 | typedef struct EDM_INT64_TAG
|
---|
219 | {
|
---|
220 | int64_t value; /*SINT64 might be a single type or s truct provided by platformTypes, depending on C compiler support*/
|
---|
221 | } EDM_INT64;
|
---|
222 |
|
---|
223 | /*Edm.SByte*/
|
---|
224 | /*Signed 8-bit integer*/
|
---|
225 | /*OData=ABNF: sbyteValue = [ sign ] 1*3DIGIT ; numbers in the range from -128 to 127*/
|
---|
226 | /*C89, C99, C11 all have SCHAR_MIN, SCHAR_MAX between -127 and 127 (guaranteed)*/
|
---|
227 | /*so platformTypes.h has to check that -128 is attainable*/
|
---|
228 | typedef struct EDM_SBYTE_TAG
|
---|
229 | {
|
---|
230 | int8_t value;
|
---|
231 | } EDM_SBYTE;
|
---|
232 |
|
---|
233 | /*Edm.Single*/
|
---|
234 | /*IEEE 754 binary32 floating-point number (6-9 decimal digits)*/
|
---|
235 | /*with the same "fears" as for Edm.Double*/
|
---|
236 | typedef struct EDM_SINGLE_TAG
|
---|
237 | {
|
---|
238 | float value;
|
---|
239 | } EDM_SINGLE;
|
---|
240 |
|
---|
241 | /*not clear what this is
|
---|
242 | typedef EDM_STREAM_TAG
|
---|
243 | {
|
---|
244 |
|
---|
245 | }EDM_STREAM;
|
---|
246 | */
|
---|
247 |
|
---|
248 | /*Edm.String*/
|
---|
249 | /*Sequence of UTF-8 characters*/
|
---|
250 | typedef struct EDM_STRING_TAG
|
---|
251 | {
|
---|
252 | size_t length; /*number of unsigned char* in the string*/
|
---|
253 | char* chars;
|
---|
254 | } EDM_STRING;
|
---|
255 |
|
---|
256 | /*Edm.TimeOfDay*/
|
---|
257 | /*Clock time 00:00-23:59:59.999999999999*/
|
---|
258 | /*The edm:TimeOfDay expression evaluates to a primitive time value. A time-of-day expression MUST be
|
---|
259 | assigned a value conforming to the rule timeOfDayValue in [OData-ABNF].*/
|
---|
260 | /*timeOfDayValue = hour ":" minute [ ":" second [ "." fractionalSeconds ] ]*/
|
---|
261 | typedef struct EDM_TIME_OF_DAY_TAG
|
---|
262 | {
|
---|
263 | uint8_t hour;
|
---|
264 | uint8_t minute;
|
---|
265 | uint8_t second;
|
---|
266 | uint64_t fractionalSecond;
|
---|
267 | }EDM_TIME_OF_DAY;
|
---|
268 |
|
---|
269 | /*positionLiteral = doubleValue SP doubleValue ; longitude, then latitude*/
|
---|
270 | typedef struct EDM_POSITION_LITERAL_TAG
|
---|
271 | {
|
---|
272 | double longitude;
|
---|
273 | double latitude;
|
---|
274 | }EDM_POSITION_LITERAL;
|
---|
275 |
|
---|
276 |
|
---|
277 | /*sridLiteral = "SRID" EQ 1*5DIGIT SEMI*/
|
---|
278 | typedef struct EDM_SRID_LITERAL_TAG
|
---|
279 | {
|
---|
280 | uint16_t digits;
|
---|
281 | } EDM_SRID_LITERAL;
|
---|
282 |
|
---|
283 | /*lineStringData = OPEN positionLiteral 1*( COMMA positionLiteral ) CLOSE*/
|
---|
284 | typedef struct EDM_LINE_STRING_DATA_TAG
|
---|
285 | {
|
---|
286 | size_t nPositionLiterals;
|
---|
287 | EDM_POSITION_LITERAL *positionLiterals;
|
---|
288 | }EDM_LINE_STRING_DATA;
|
---|
289 |
|
---|
290 | /*pointData = OPEN positionLiteral CLOSE*/
|
---|
291 | typedef struct EDM_POINT_DATA_TAG
|
---|
292 | {
|
---|
293 | EDM_POSITION_LITERAL positionLiteral;
|
---|
294 | }EDM_POINT_DATA;
|
---|
295 |
|
---|
296 | /*ringLiteral = OPEN positionLiteral *( COMMA positionLiteral ) CLOSE*/
|
---|
297 | typedef struct EDM_RING_LITERAL_TAG
|
---|
298 | {
|
---|
299 | size_t nPositionLiterals;
|
---|
300 | EDM_POSITION_LITERAL *positionLiterals;
|
---|
301 | }EDM_RING_LITERAL;
|
---|
302 |
|
---|
303 | /*pointLiteral ="Point" pointData*/
|
---|
304 | typedef struct EDM_POINT_LITERAL_TAG
|
---|
305 | {
|
---|
306 | EDM_POINT_DATA pointData;
|
---|
307 | } EDM_POINT_LITERAL;
|
---|
308 |
|
---|
309 | /*polygonData = OPEN ringLiteral *( COMMA ringLiteral ) CLOSE*/
|
---|
310 | typedef struct EDM_POLYGON_DATA_TAG
|
---|
311 | {
|
---|
312 | size_t nRingLiterals;
|
---|
313 | EDM_RING_LITERAL *ringLiterals;
|
---|
314 | }EDM_POLYGON_DATA;
|
---|
315 |
|
---|
316 | /*polygonLiteral = "Polygon" polygonData*/
|
---|
317 | typedef struct EDM_POLYGON_LITERAL_TAG
|
---|
318 | {
|
---|
319 | EDM_POLYGON_DATA polygonData;
|
---|
320 | }EDM_POLYGON_LITERAL;
|
---|
321 |
|
---|
322 | /*fullPolygonLiteral = sridLiteral polygonLiteral*/
|
---|
323 | typedef struct EDM_FULL_POLYGON_LITERAL_TAG
|
---|
324 | {
|
---|
325 | EDM_SRID_LITERAL srid;
|
---|
326 | EDM_POLYGON_LITERAL polygonLiteral;
|
---|
327 | }EDM_FULL_POLYGON_LITERAL;
|
---|
328 |
|
---|
329 | /*fullPointLiteral = sridLiteral pointLiteral*/
|
---|
330 | typedef struct EDM_FULL_POINT_LITERAL_TAG
|
---|
331 | {
|
---|
332 | EDM_SRID_LITERAL srid;
|
---|
333 | EDM_POINT_LITERAL pointLiteral;
|
---|
334 | } EDM_FULL_POINT_LITERAL;
|
---|
335 |
|
---|
336 | /*geographyPoint = geographyPrefix SQUOTE fullPointLiteral SQUOTE*/
|
---|
337 | typedef struct EDM_GEOGRAPHY_POINT_TAG
|
---|
338 | {
|
---|
339 | EDM_FULL_POINT_LITERAL fullPointLiteral;
|
---|
340 | }EDM_GEOGRAPHY_POINT;
|
---|
341 |
|
---|
342 | /*multiPolygonLiteral = "MultiPolygon(" [ polygonData *( COMMA polygonData ) ] CLOSE*/
|
---|
343 | typedef struct EDM_MULTI_POLYGON_LITERAL_TAG
|
---|
344 | {
|
---|
345 | size_t nPolygonDatas;
|
---|
346 | EDM_POLYGON_DATA * polygonDatas;
|
---|
347 | }EDM_MULTI_POLYGON_LITERAL;
|
---|
348 |
|
---|
349 | /*fullMultiPolygonLiteral = sridLiteral multiPolygonLiteral*/
|
---|
350 | typedef struct EDM_FULL_MULTI_POLYGON_LITERAL_TAG
|
---|
351 | {
|
---|
352 | EDM_SRID_LITERAL srid;
|
---|
353 | EDM_MULTI_POLYGON_LITERAL multiPolygonLiteral;
|
---|
354 | }EDM_FULL_MULTI_POLYGON_LITERAL;
|
---|
355 |
|
---|
356 | /*multiPointLiteral = "MultiPoint(" [ pointData *( COMMA pointData ) ] CLOSE*/
|
---|
357 | typedef struct EDM_MULTI_POINT_LITERAL_TAG
|
---|
358 | {
|
---|
359 | size_t nPointDatas;
|
---|
360 | EDM_POINT_DATA *pointDatas;
|
---|
361 | }EDM_MULTI_POINT_LITERAL;
|
---|
362 |
|
---|
363 | /*fullMultiPointLiteral = sridLiteral multiPointLiteral*/
|
---|
364 | typedef struct EDM_FULL_MULTI_POINT_LITERAL_TAG
|
---|
365 | {
|
---|
366 | EDM_SRID_LITERAL srid;
|
---|
367 | EDM_MULTI_POINT_LITERAL multiPointLiteral;
|
---|
368 | }EDM_FULL_MULTI_POINT_LITERAL;
|
---|
369 |
|
---|
370 | /*lineStringLiteral = "LineString" lineStringData*/
|
---|
371 | typedef struct EDM_LINE_STRING_LITERAL_TAG
|
---|
372 | {
|
---|
373 | EDM_LINE_STRING_DATA lineStringData;
|
---|
374 | }EDM_LINE_STRING_LITERAL;
|
---|
375 |
|
---|
376 | /*fullLineStringLiteral = sridLiteral lineStringLiteral*/
|
---|
377 | typedef struct EDM_FULL_LINE_STRING_LITERAL_TAG
|
---|
378 | {
|
---|
379 | EDM_SRID_LITERAL srid;
|
---|
380 | EDM_LINE_STRING_LITERAL lineStringLiteral;
|
---|
381 | } EDM_FULL_LINE_STRING_LITERAL;
|
---|
382 |
|
---|
383 | /*multiLineStringLiteral = "MultiLineString(" [ lineStringData *( COMMA lineStringData ) ] CLOSE*/
|
---|
384 | typedef struct EDM_MULTI_LINE_STRING_LITERAL_TAG
|
---|
385 | {
|
---|
386 | size_t nLineStringDatas;
|
---|
387 | EDM_LINE_STRING_DATA lineStringData;
|
---|
388 | }EDM_MULTI_LINE_STRING_LITERAL;
|
---|
389 |
|
---|
390 | /*fullMultiLineStringLiteral = sridLiteral multiLineStringLiteral*/
|
---|
391 | typedef struct EDM_FULL_MULTI_LINE_STRING_LITERAL_TAG
|
---|
392 | {
|
---|
393 | EDM_SRID_LITERAL srid;
|
---|
394 | EDM_MULTI_LINE_STRING_LITERAL multiLineStringLiteral;
|
---|
395 | }EDM_FULL_MULTI_LINE_STRING_LITERAL;
|
---|
396 |
|
---|
397 |
|
---|
398 |
|
---|
399 | /*forward defines*/
|
---|
400 | struct EDM_GEO_LITERAL_TAG;
|
---|
401 | typedef struct EDM_GEO_LITERAL_TAG EDM_GEO_LITERAL;
|
---|
402 |
|
---|
403 | /*collectionLiteral = "Collection(" geoLiteral *( COMMA geoLiteral ) CLOSE*/
|
---|
404 | typedef struct EDM_COLLECTION_LITERAL_TAG
|
---|
405 | {
|
---|
406 | size_t nGeoLiterals;
|
---|
407 | EDM_GEO_LITERAL* geoLiterals;
|
---|
408 | } EDM_COLLECTION_LITERAL;
|
---|
409 |
|
---|
410 | /*geoLiteral = collectionLiteral
|
---|
411 | / lineStringLiteral
|
---|
412 | / multiPointLiteral
|
---|
413 | / multiLineStringLiteral
|
---|
414 | / multiPolygonLiteral
|
---|
415 | / pointLiteral
|
---|
416 | / polygonLiteral
|
---|
417 | */
|
---|
418 | typedef enum EDM_GEO_LITERAL_TYPE_TAG
|
---|
419 | {
|
---|
420 | EDM_COLLECTION_LITERAL_TYPE,
|
---|
421 | EDM_LINE_STRING_LITERAL_TYPE,
|
---|
422 | EDM_MULTI_POINT_LITERAL_TYPE,
|
---|
423 | EDM_MULTI_LINE_STRING_LITERAL_TYPE,
|
---|
424 | EDM_MULTI_POLIGON_LITERAL_TYPE,
|
---|
425 | EDM_POINT_LITERAL_TYPE,
|
---|
426 | EDM_POLYGON_LITERAL_TYPE
|
---|
427 | }EDM_GEO_LITERAL_TYPE;
|
---|
428 |
|
---|
429 | struct EDM_GEO_LITERAL_TAG
|
---|
430 | {
|
---|
431 | EDM_GEO_LITERAL_TYPE literalType;
|
---|
432 | union
|
---|
433 | {
|
---|
434 | EDM_COLLECTION_LITERAL collectionLiteral;
|
---|
435 | EDM_LINE_STRING_LITERAL lineStringLiteral;
|
---|
436 | EDM_MULTI_POINT_LITERAL multiPointLiteral;
|
---|
437 | EDM_MULTI_LINE_STRING_LITERAL multiLineStringLiteral;
|
---|
438 | EDM_MULTI_POLYGON_LITERAL multiPolygonLiteral;
|
---|
439 | EDM_POINT_LITERAL pointLiteral;
|
---|
440 | EDM_POLYGON_LITERAL polygonLiteral;
|
---|
441 | } u;
|
---|
442 | };
|
---|
443 |
|
---|
444 | /*fullCollectionLiteral = sridLiteral collectionLiteral*/
|
---|
445 | typedef struct EDM_FULL_COLLECTION_LITERAL_TAG
|
---|
446 | {
|
---|
447 | EDM_SRID_LITERAL srid;
|
---|
448 | EDM_COLLECTION_LITERAL collectionLiteral;
|
---|
449 | }EDM_FULL_COLLECTION_LITERAL;
|
---|
450 |
|
---|
451 | /*now geography stuff*/
|
---|
452 |
|
---|
453 | /*geographyCollection = geographyPrefix SQUOTE fullCollectionLiteral SQUOTE*/
|
---|
454 | typedef struct EDM_GEOGRAPHY_COLLECTION_TAG
|
---|
455 | {
|
---|
456 | EDM_FULL_COLLECTION_LITERAL fullCollectionLiteral;
|
---|
457 | }EDM_GEOGRAPHY_COLLECTION;
|
---|
458 |
|
---|
459 | /*geographyLineString = geographyPrefix SQUOTE fullLineStringLiteral SQUOTE*/
|
---|
460 | typedef struct EDM_GEOGRAPHY_LINE_STRING_TAG
|
---|
461 | {
|
---|
462 | EDM_FULL_LINE_STRING_LITERAL fullLineStringLiteral;
|
---|
463 | }EDM_GEOGRAPHY_LINE_STRING;
|
---|
464 |
|
---|
465 | /*geographyMultiLineString = geographyPrefix SQUOTE fullMultiLineStringLiteral SQUOTE*/
|
---|
466 | typedef struct EDM_GEOGRAPHY_MULTI_LINE_STRING_TAG
|
---|
467 | {
|
---|
468 | EDM_FULL_MULTI_LINE_STRING_LITERAL fullMultiLineStringLiteral;
|
---|
469 | }EDM_GEOGRAPHY_MULTI_LINE_STRING;
|
---|
470 |
|
---|
471 | /*geographyMultiPoint = geographyPrefix SQUOTE fullMultiPointLiteral SQUOTE*/
|
---|
472 | typedef struct EDM_GEOGRAPHY_MULTI_POINT_TAG
|
---|
473 | {
|
---|
474 | EDM_FULL_MULTI_POINT_LITERAL fullMultiPointLiteral;
|
---|
475 | }EDM_GEOGRAPHY_MULTI_POINT;
|
---|
476 |
|
---|
477 | /*geographyMultiPolygon = geographyPrefix SQUOTE fullMultiPolygonLiteral SQUOTE*/
|
---|
478 | typedef struct EDM_GEOGRAPHY_MULTI_POLYGON_TAG
|
---|
479 | {
|
---|
480 | EDM_FULL_MULTI_POLYGON_LITERAL fullMultiPolygonLiteral;
|
---|
481 | }EDM_GEOGRAPHY_MULTI_POLYGON;
|
---|
482 |
|
---|
483 | /*geographyPolygon = geographyPrefix SQUOTE fullPolygonLiteral SQUOTE*/
|
---|
484 | typedef struct EDM_GEOGRAPHY_POLYGON_TAG
|
---|
485 | {
|
---|
486 | EDM_FULL_POLYGON_LITERAL fullPolygonLiteral;
|
---|
487 | }EDM_GEOGRAPHY_POLYGON;
|
---|
488 |
|
---|
489 | /*geometryCollection = geometryPrefix SQUOTE fullCollectionLiteral SQUOTE*/
|
---|
490 | /*forward defines*/
|
---|
491 |
|
---|
492 |
|
---|
493 | /*geometryPolygon = geometryPrefix SQUOTE fullPolygonLiteral SQUOTE*/
|
---|
494 | typedef struct EDM_GEOMETRY_POLYGON_TAG
|
---|
495 | {
|
---|
496 | EDM_FULL_POLYGON_LITERAL fullPolygonLiteral;
|
---|
497 | }EDM_GEOMETRY_POLYGON;
|
---|
498 |
|
---|
499 | /*geometryPoint = geometryPrefix SQUOTE fullPointLiteral SQUOTE*/
|
---|
500 | typedef struct EDM_GEOMETRY_POINT_TAG
|
---|
501 | {
|
---|
502 | EDM_FULL_POINT_LITERAL fullPointLiteral;
|
---|
503 | }EDM_GEOMETRY_POINT;
|
---|
504 |
|
---|
505 | /*geometryMultiPolygon = geometryPrefix SQUOTE fullMultiPolygonLiteral SQUOTE*/
|
---|
506 | typedef struct EDM_GEOMETRY_MULTI_POLYGON_TAG
|
---|
507 | {
|
---|
508 | EDM_FULL_MULTI_POLYGON_LITERAL fullMultiPolygonLiteral;
|
---|
509 | }
|
---|
510 | EDM_GEOMETRY_MULTI_POLYGON;
|
---|
511 |
|
---|
512 | /*geometryMultiPoint = geometryPrefix SQUOTE fullMultiPointLiteral SQUOTE*/
|
---|
513 | typedef struct EDM_GEOMETRY_MULTI_POINT_TAG
|
---|
514 | {
|
---|
515 | EDM_FULL_MULTI_POINT_LITERAL fullMultiPointLiteral;
|
---|
516 | }EDM_GEOMETRY_MULTI_POINT;
|
---|
517 |
|
---|
518 | /*geometryMultiLineString = geometryPrefix SQUOTE fullMultiLineStringLiteral SQUOTE*/
|
---|
519 | typedef struct EDM_GEOMETRY_MULTI_LINE_STRING_TAG
|
---|
520 | {
|
---|
521 | EDM_FULL_MULTI_LINE_STRING_LITERAL fullMultiLineStringLiteral;
|
---|
522 | }EDM_GEOMETRY_MULTI_LINE_STRING;
|
---|
523 |
|
---|
524 | /*geometryLineString = geometryPrefix SQUOTE fullLineStringLiteral SQUOTE*/
|
---|
525 | typedef struct EDM_GEOMETRY_LINE_STRING_TAG
|
---|
526 | {
|
---|
527 | EDM_FULL_LINE_STRING_LITERAL fullLineStringLiteral;
|
---|
528 | }EDM_GEOMETRY_LINE_STRING;
|
---|
529 |
|
---|
530 | /*geometryCollection = geometryPrefix SQUOTE fullCollectionLiteral SQUOTE*/
|
---|
531 | typedef struct EDM_GEOMETRY_COLLECTION_TAG
|
---|
532 | {
|
---|
533 | EDM_FULL_COLLECTION_LITERAL fullCollectionLiteral;
|
---|
534 | }EDM_GEOMETRY_COLLECTION;
|
---|
535 |
|
---|
536 | /*holds the name and the value of a COMPLEX_TYPE... field*/
|
---|
537 | typedef struct COMPLEX_TYPE_FIELD_TAG
|
---|
538 | {
|
---|
539 | const char* fieldName;
|
---|
540 | AGENT_DATA_TYPE* value;
|
---|
541 | }COMPLEX_TYPE_FIELD_TYPE;
|
---|
542 |
|
---|
543 | /*EDM_COMPLEX_TYPE - this type doesn't exist in EDMX as a primitive type*/
|
---|
544 | typedef struct EDM_COMPLEX_TYPE_TAG
|
---|
545 | {
|
---|
546 | size_t nMembers;
|
---|
547 | COMPLEX_TYPE_FIELD_TYPE *fields;
|
---|
548 | }EDM_COMPLEX_TYPE;
|
---|
549 |
|
---|
550 | #define AGENT_DATA_TYPES_RESULT_VALUES \
|
---|
551 | AGENT_DATA_TYPES_OK, \
|
---|
552 | AGENT_DATA_TYPES_ERROR, \
|
---|
553 | AGENT_DATA_TYPES_INVALID_ARG, \
|
---|
554 | AGENT_DATA_TYPES_NOT_IMPLEMENTED, \
|
---|
555 | AGENT_DATA_TYPES_JSON_ENCODER_ERRROR
|
---|
556 |
|
---|
557 | MU_DEFINE_ENUM_WITHOUT_INVALID(AGENT_DATA_TYPES_RESULT, AGENT_DATA_TYPES_RESULT_VALUES);
|
---|
558 |
|
---|
559 | #define AGENT_DATA_TYPE_TYPE_VALUES\
|
---|
560 | EDM_NO_TYPE, \
|
---|
561 | EDM_BINARY_TYPE, \
|
---|
562 | EDM_BOOLEAN_TYPE, \
|
---|
563 | EDM_BYTE_TYPE, \
|
---|
564 | EDM_DATE_TYPE, \
|
---|
565 | EDM_DATE_TIME_OFFSET_TYPE, \
|
---|
566 | EDM_DECIMAL_TYPE, \
|
---|
567 | EDM_DOUBLE_TYPE, \
|
---|
568 | EDM_DURATION_TYPE, \
|
---|
569 | EDM_GUID_TYPE, \
|
---|
570 | EDM_INT16_TYPE, \
|
---|
571 | EDM_INT32_TYPE, \
|
---|
572 | EDM_INT64_TYPE, \
|
---|
573 | EDM_SBYTE_TYPE, \
|
---|
574 | EDM_SINGLE_TYPE, \
|
---|
575 | EDM_STREAM, /*not supported, because what is stream?*/ \
|
---|
576 | EDM_STRING_TYPE, \
|
---|
577 | EDM_TIME_OF_DAY_TYPE, \
|
---|
578 | EDM_GEOGRAPHY_TYPE, /*not supported because what is "abstract base type"*/ \
|
---|
579 | EDM_GEOGRAPHY_POINT_TYPE, \
|
---|
580 | EDM_GEOGRAPHY_LINE_STRING_TYPE, \
|
---|
581 | EDM_GEOGRAPHY_POLYGON_TYPE, \
|
---|
582 | EDM_GEOGRAPHY_MULTI_POINT_TYPE, \
|
---|
583 | EDM_GEOGRAPHY_MULTI_LINE_STRING_TYPE, \
|
---|
584 | EDM_GEOGRAPHY_MULTI_POLYGON_TYPE, \
|
---|
585 | EDM_GEOGRAPHY_COLLECTION_TYPE, \
|
---|
586 | EDM_GEOMETRY_TYPE, /*not supported because what is "abstract base type"*/ \
|
---|
587 | EDM_GEOMETRY_POINT_TYPE, \
|
---|
588 | EDM_GEOMETRY_LINE_STRING_TYPE, \
|
---|
589 | EDM_GEOMETRY_POLYGON_TYPE, \
|
---|
590 | EDM_GEOMETRY_MULTI_POINT_TYPE, \
|
---|
591 | EDM_GEOMETRY_MULTI_LINE_STRING_TYPE, \
|
---|
592 | EDM_GEOMETRY_MULTI_POLYGON_TYPE, \
|
---|
593 | EDM_GEOMETRY_COLLECTION_TYPE, \
|
---|
594 | EDM_COMPLEX_TYPE_TYPE, \
|
---|
595 | EDM_NULL_TYPE, \
|
---|
596 | EDM_ENTITY_TYPE_TYPE, \
|
---|
597 | EDM_STRING_NO_QUOTES_TYPE \
|
---|
598 |
|
---|
599 |
|
---|
600 | MU_DEFINE_ENUM_WITHOUT_INVALID(AGENT_DATA_TYPE_TYPE, AGENT_DATA_TYPE_TYPE_VALUES);
|
---|
601 |
|
---|
602 | struct AGENT_DATA_TYPE_TAG
|
---|
603 | {
|
---|
604 | AGENT_DATA_TYPE_TYPE type;
|
---|
605 | union
|
---|
606 | {
|
---|
607 | EDM_BINARY edmBinary;
|
---|
608 | EDM_BOOLEAN edmBoolean;
|
---|
609 | EDM_BYTE edmByte;
|
---|
610 | EDM_DATE edmDate;
|
---|
611 | EDM_DATE_TIME_OFFSET edmDateTimeOffset;
|
---|
612 | EDM_DECIMAL edmDecimal;
|
---|
613 | EDM_DOUBLE edmDouble;
|
---|
614 | EDM_DURATION edmDuration;
|
---|
615 | EDM_GUID edmGuid;
|
---|
616 | EDM_INT16 edmInt16;
|
---|
617 | EDM_INT32 edmInt32;
|
---|
618 | EDM_INT64 edmInt64;
|
---|
619 | EDM_SBYTE edmSbyte;
|
---|
620 | EDM_SINGLE edmSingle;
|
---|
621 | /*EDM_STREAM, not supported, because what is stream?*/
|
---|
622 | EDM_STRING edmString;
|
---|
623 | EDM_STRING edmStringNoQuotes;
|
---|
624 | EDM_TIME_OF_DAY edmTimeOfDay;
|
---|
625 | /*EDM_GEOGRAPHY_, not supported because what is "abstract base type"*/
|
---|
626 | EDM_GEOGRAPHY_POINT edmGeographyPoint;
|
---|
627 | EDM_GEOGRAPHY_LINE_STRING edmGeographyLineString;
|
---|
628 | EDM_GEOGRAPHY_POLYGON edmGeographyPolygon;
|
---|
629 | EDM_GEOGRAPHY_MULTI_POINT edmGeographyMultiPoint;
|
---|
630 | EDM_GEOGRAPHY_MULTI_LINE_STRING edmGeographyMultiLineString;
|
---|
631 | EDM_GEOGRAPHY_MULTI_POLYGON edmGeographyMultiPolygon;
|
---|
632 | EDM_GEOGRAPHY_COLLECTION edmGeographyCollection;
|
---|
633 | /* EDM_GEOMETRY_, not supported because what is "abstract base type"*/
|
---|
634 | EDM_GEOMETRY_POINT edmGeometryPoint;
|
---|
635 | EDM_GEOMETRY_LINE_STRING edmGeometryLineString;
|
---|
636 | EDM_GEOMETRY_POLYGON edmGeometryPolygon;
|
---|
637 | EDM_GEOMETRY_MULTI_POINT edmGeometryMultiPoint;
|
---|
638 | EDM_GEOMETRY_MULTI_LINE_STRING edmGeoemtryMultiLineString;
|
---|
639 | EDM_GEOMETRY_MULTI_POLYGON edmGeometryMultiPolygon;
|
---|
640 | EDM_GEOMETRY_COLLECTION edmGeometryCollection;
|
---|
641 | EDM_COMPLEX_TYPE edmComplexType;
|
---|
642 | } value;
|
---|
643 | };
|
---|
644 |
|
---|
645 | #include "umock_c/umock_c_prod.h"
|
---|
646 |
|
---|
647 | MOCKABLE_FUNCTION(, AGENT_DATA_TYPES_RESULT, AgentDataTypes_ToString, STRING_HANDLE, destination, const AGENT_DATA_TYPE*, value);
|
---|
648 |
|
---|
649 | /*Create/Destroy work in pairs. For some data type not calling Uncreate might be ok. For some, it will lead to memory leaks*/
|
---|
650 |
|
---|
651 | /*creates an AGENT_DATA_TYPE containing a EDM_BOOLEAN from a int*/
|
---|
652 | MOCKABLE_FUNCTION(, AGENT_DATA_TYPES_RESULT, Create_EDM_BOOLEAN_from_int, AGENT_DATA_TYPE*, agentData, int, v);
|
---|
653 |
|
---|
654 | /*creates an AGENT_DATA_TYPE containing a UINT8*/
|
---|
655 | MOCKABLE_FUNCTION(, AGENT_DATA_TYPES_RESULT, Create_AGENT_DATA_TYPE_from_UINT8, AGENT_DATA_TYPE*, agentData, uint8_t, v);
|
---|
656 |
|
---|
657 | /*creates an AGENT_DATA_TYPE containing a EDM_DATE */
|
---|
658 | MOCKABLE_FUNCTION(, AGENT_DATA_TYPES_RESULT, Create_AGENT_DATA_TYPE_from_date, AGENT_DATA_TYPE*, agentData, int16_t, year, uint8_t, month, uint8_t, day);
|
---|
659 |
|
---|
660 | /*create an AGENT_DATA_TYPE containing an EDM_DECIMAL from a string representation*/
|
---|
661 | MOCKABLE_FUNCTION(, AGENT_DATA_TYPES_RESULT, Create_EDM_DECIMAL_from_charz, AGENT_DATA_TYPE*, agentData, const char*, v);
|
---|
662 |
|
---|
663 | /*create an AGENT_DATA_TYPE containing an EDM_DOUBLE from a double*/
|
---|
664 | MOCKABLE_FUNCTION(, AGENT_DATA_TYPES_RESULT, Create_AGENT_DATA_TYPE_from_DOUBLE, AGENT_DATA_TYPE*, agentData, double, v);
|
---|
665 |
|
---|
666 | /*create an AGENT_DATA_TYPE from INT16_T*/
|
---|
667 | MOCKABLE_FUNCTION(, AGENT_DATA_TYPES_RESULT, Create_AGENT_DATA_TYPE_from_SINT16, AGENT_DATA_TYPE*, agentData, int16_t, v);
|
---|
668 |
|
---|
669 | /*create an AGENT_DATA_TYPE from INT32_T*/
|
---|
670 | MOCKABLE_FUNCTION(, AGENT_DATA_TYPES_RESULT, Create_AGENT_DATA_TYPE_from_SINT32, AGENT_DATA_TYPE*, agentData, int32_t, v);
|
---|
671 |
|
---|
672 | /*create an AGENT_DATA_TYPE from INT64_T*/
|
---|
673 | MOCKABLE_FUNCTION(, AGENT_DATA_TYPES_RESULT, Create_AGENT_DATA_TYPE_from_SINT64, AGENT_DATA_TYPE*, agentData, int64_t, v);
|
---|
674 |
|
---|
675 | /*create an AGENT_DATA_TYPE from int8_t*/
|
---|
676 | MOCKABLE_FUNCTION(, AGENT_DATA_TYPES_RESULT, Create_AGENT_DATA_TYPE_from_SINT8, AGENT_DATA_TYPE*, agentData, int8_t, v);
|
---|
677 |
|
---|
678 | /*Codes_SRS_AGENT_TYPE_SYSTEM_99_091:[Creates an AGENT_DATA_TYPE containing an Edm.DateTimeOffset from an EDM_DATE_TIME_OFFSET.]*/
|
---|
679 | MOCKABLE_FUNCTION(, AGENT_DATA_TYPES_RESULT, Create_AGENT_DATA_TYPE_from_EDM_DATE_TIME_OFFSET, AGENT_DATA_TYPE*, agentData, EDM_DATE_TIME_OFFSET, v);
|
---|
680 |
|
---|
681 | /*creates an AGENT_DATA_TYPE containing a EDM_GUID*/
|
---|
682 | MOCKABLE_FUNCTION(, AGENT_DATA_TYPES_RESULT, Create_AGENT_DATA_TYPE_from_EDM_GUID, AGENT_DATA_TYPE*, agentData, EDM_GUID, v);
|
---|
683 |
|
---|
684 | /*creates an AGENT_DATA_TYPE containing a EDM_BINARY*/
|
---|
685 | MOCKABLE_FUNCTION(, AGENT_DATA_TYPES_RESULT, Create_AGENT_DATA_TYPE_from_EDM_BINARY, AGENT_DATA_TYPE*, agentData, EDM_BINARY, v);
|
---|
686 |
|
---|
687 | /*create an AGENT_DATA_TYPE from SINGLE*/
|
---|
688 | MOCKABLE_FUNCTION(, AGENT_DATA_TYPES_RESULT, Create_AGENT_DATA_TYPE_from_FLOAT, AGENT_DATA_TYPE*, agentData, float, v);
|
---|
689 |
|
---|
690 | /*create an AGENT_DATA_TYPE from ANSI zero terminated string*/
|
---|
691 | MOCKABLE_FUNCTION(, AGENT_DATA_TYPES_RESULT, Create_AGENT_DATA_TYPE_from_charz, AGENT_DATA_TYPE*, agentData, const char*, v);
|
---|
692 |
|
---|
693 | /*create an AGENT_DATA_TYPE from ANSI zero terminated string (no quotes)*/
|
---|
694 | MOCKABLE_FUNCTION(, AGENT_DATA_TYPES_RESULT, Create_AGENT_DATA_TYPE_from_charz_no_quotes, AGENT_DATA_TYPE*, agentData, const char*, v);
|
---|
695 |
|
---|
696 | /*create an AGENT_DATA_TYPE of type EDM_NULL_TYPE */
|
---|
697 | MOCKABLE_FUNCTION(, AGENT_DATA_TYPES_RESULT, Create_NULL_AGENT_DATA_TYPE, AGENT_DATA_TYPE*, agentData);
|
---|
698 |
|
---|
699 | /*create an AGENT_DATA_TYPE that holds a structs from its fields*/
|
---|
700 | MOCKABLE_FUNCTION(, AGENT_DATA_TYPES_RESULT, Create_AGENT_DATA_TYPE_from_Members, AGENT_DATA_TYPE*,agentData, const char*, typeName, size_t, nMembers, const char* const *, memberNames, const AGENT_DATA_TYPE*, memberValues);
|
---|
701 |
|
---|
702 | /*create a complex AGENT_DATA_TYPE from pointers to AGENT_DATA_TYPE fields*/
|
---|
703 | MOCKABLE_FUNCTION(, AGENT_DATA_TYPES_RESULT, Create_AGENT_DATA_TYPE_from_MemberPointers, AGENT_DATA_TYPE*, agentData, const char*, typeName, size_t, nMembers, const char* const *, memberNames, const AGENT_DATA_TYPE** ,memberPointerValues);
|
---|
704 |
|
---|
705 | /*creates a copy of the AGENT_DATA_TYPE*/
|
---|
706 | MOCKABLE_FUNCTION(, AGENT_DATA_TYPES_RESULT, Create_AGENT_DATA_TYPE_from_AGENT_DATA_TYPE, AGENT_DATA_TYPE*, dest, const AGENT_DATA_TYPE*, src);
|
---|
707 |
|
---|
708 | MOCKABLE_FUNCTION(, void, Destroy_AGENT_DATA_TYPE, AGENT_DATA_TYPE*, agentData);
|
---|
709 |
|
---|
710 | MOCKABLE_FUNCTION(, AGENT_DATA_TYPES_RESULT, CreateAgentDataType_From_String, const char*, source, AGENT_DATA_TYPE_TYPE, type, AGENT_DATA_TYPE*, agentData);
|
---|
711 |
|
---|
712 | MOCKABLE_FUNCTION(, COMPLEX_TYPE_FIELD_TYPE*, AgentDataType_GetComplexTypeField, AGENT_DATA_TYPE*, agentData, size_t, index);
|
---|
713 |
|
---|
714 | #ifdef __cplusplus
|
---|
715 | }
|
---|
716 | #endif
|
---|
717 |
|
---|
718 | #endif
|
---|