QCBOR
Loading...
Searching...
No Matches
qcbor_spiffy_decode.h
Go to the documentation of this file.
1/* ==========================================================================
2 * qcbor_spiffy_decode.h -- higher-level easier-to-use CBOR decoding.
3 *
4 * Copyright (c) 2020-2025, Laurence Lundblade. All rights reserved.
5 * Copyright (c) 2021, Arm Limited. All rights reserved.
6 *
7 * SPDX-License-Identifier: BSD-3-Clause
8 *
9 * See BSD-3-Clause license in file named "LICENSE"
10 *
11 * Forked from qcbor_decode.h on 7/23/2020
12 * ========================================================================== */
13#ifndef qcbor_spiffy_decode_h
14#define qcbor_spiffy_decode_h
15
16
17#include "qcbor/qcbor_decode.h"
18
19
20#ifdef __cplusplus
21extern "C" {
22#if 0
23} // Keep editor indention formatting happy
24#endif
25#endif
26
27
161
162
163
164
169#define QCBOR_TAG_REQUIREMENT_TAG 0
170
175#define QCBOR_TAG_REQUIREMENT_NOT_A_TAG 1
176
181#define QCBOR_TAG_REQUIREMENT_OPTIONAL_TAG 2
182
185#define QCBOR_TAG_REQUIREMENT_ALLOW_ADDITIONAL_TAGS 0x80
186
187
188
189
192#define QCBOR_CONVERT_TYPE_XINT64 0x01
195#define QCBOR_CONVERT_TYPE_FLOAT 0x02
198#define QCBOR_CONVERT_TYPE_BIG_NUM 0x04
201#define QCBOR_CONVERT_TYPE_DECIMAL_FRACTION 0x08
204#define QCBOR_CONVERT_TYPE_BIGFLOAT 0x10
205
206
207
208
230static void
232 int64_t *pnValue);
233
234static void
235QCBORDecode_GetInt64InMapN(QCBORDecodeContext *pCtx,
236 int64_t nLabel,
237 int64_t *pnValue);
238
239static void
240QCBORDecode_GetInt64InMapSZ(QCBORDecodeContext *pCtx,
241 const char *szLabel,
242 int64_t *pnValue);
243
244
282static void
284 uint32_t uConvertTypes,
285 int64_t *pnValue);
286
287static void
288QCBORDecode_GetInt64ConvertInMapN(QCBORDecodeContext *pCtx,
289 int64_t nLabel,
290 uint32_t uConvertTypes,
291 int64_t *pnValue);
292
293static void
294QCBORDecode_GetInt64ConvertInMapSZ(QCBORDecodeContext *pCtx,
295 const char *szLabel,
296 uint32_t uConvertTypes,
297 int64_t *pnValue);
298
299
337void
339 uint32_t uConvertTypes,
340 int64_t *pnValue);
341
342void
343QCBORDecode_GetInt64ConvertAllInMapN(QCBORDecodeContext *pCtx,
344 int64_t nLabel,
345 uint32_t uConvertTypes,
346 int64_t *pnValue);
347
348void
349QCBORDecode_GetInt64ConvertAllInMapSZ(QCBORDecodeContext *pCtx,
350 const char *szLabel,
351 uint32_t uConvertTypes,
352 int64_t *pnValue);
353
354
370static void
372 uint64_t *puValue);
373
374static void
375QCBORDecode_GetUInt64InMapN(QCBORDecodeContext *pCtx,
376 int64_t nLabel,
377 uint64_t *puValue);
378
379static void
380QCBORDecode_GetUInt64InMapSZ(QCBORDecodeContext *pCtx,
381 const char *szLabel,
382 uint64_t *puValue);
383
384
409static void
411 uint32_t uConvertTypes,
412 uint64_t *puValue);
413
414static void
415QCBORDecode_GetUInt64ConvertInMapN(QCBORDecodeContext *pCtx,
416 int64_t nLabel,
417 uint32_t uConvertTypes,
418 uint64_t *puValue);
419
420static void
421QCBORDecode_GetUInt64ConvertInMapSZ(QCBORDecodeContext *pCtx,
422 const char *szLabel,
423 uint32_t uConvertTypes,
424 uint64_t *puValue);
425
426
440void
442 uint32_t uConvertTypes,
443 uint64_t *puValue);
444
445void
446QCBORDecode_GetUInt64ConvertAllInMapN(QCBORDecodeContext *pCtx,
447 int64_t nLabel,
448 uint32_t uConvertTypes,
449 uint64_t *puValue);
450
451void
452QCBORDecode_GetUInt64ConvertAllInMapSZ(QCBORDecodeContext *pCtx,
453 const char *szLabel,
454 uint32_t uConvertTypes,
455 uint64_t *puValue);
456
457
458
459
473static void
475 UsefulBufC *pBytes);
476
477static void
478QCBORDecode_GetByteStringInMapN(QCBORDecodeContext *pCtx,
479 int64_t nLabel,
480 UsefulBufC *pBytes);
481
482static void
483QCBORDecode_GetByteStringInMapSZ(QCBORDecodeContext *pCtx,
484 const char *szLabel,
485 UsefulBufC *pBytes);
486
487
503static void
505 UsefulBufC *pText);
506
507static void
508QCBORDecode_GetTextStringInMapN(QCBORDecodeContext *pCtx,
509 int64_t nLabel,
510 UsefulBufC *pText);
511
512static void
513QCBORDecode_GetTextStringInMapSZ(QCBORDecodeContext *pCtx,
514 const char *szLabel,
515 UsefulBufC *pText);
516
517
518
519
520#ifndef USEFULBUF_DISABLE_ALL_FLOAT
542static void
544 double *pValue);
545
546static void
547QCBORDecode_GetDoubleInMapN(QCBORDecodeContext *pCtx,
548 int64_t nLabel,
549 double *pdValue);
550
551static void
552QCBORDecode_GetDoubleInMapSZ(QCBORDecodeContext *pCtx,
553 const char *szLabel,
554 double *pdValue);
555
556
589static void
591 uint32_t uConvertTypes,
592 double *pdValue);
593
594static void
595QCBORDecode_GetDoubleConvertInMapN(QCBORDecodeContext *pCtx,
596 int64_t nLabel,
597 uint32_t uConvertTypes,
598 double *pdValue);
599
600static void
601QCBORDecode_GetDoubleConvertInMapSZ(QCBORDecodeContext *pCtx,
602 const char *szLabel,
603 uint32_t uConvertTypes,
604 double *pdValue);
605
606
630void
632 uint32_t uConvertTypes,
633 double *pdValue);
634
635void
636QCBORDecode_GetDoubleConvertAllInMapN(QCBORDecodeContext *pCtx,
637 int64_t nLabel,
638 uint32_t uConvertTypes,
639 double *pdValue);
640
641void
642QCBORDecode_GetDoubleConvertAllInMapSZ(QCBORDecodeContext *pCtx,
643 const char *szLabel,
644 uint32_t uConvertTypes,
645 double *pdValue);
646#endif /* USEFULBUF_DISABLE_ALL_FLOAT */
647
648
649
650
705static void
707
708void
709QCBORDecode_EnterArrayFromMapN(QCBORDecodeContext *pMe, int64_t uLabel);
710
711void
712QCBORDecode_EnterArrayFromMapSZ(QCBORDecodeContext *pMe, const char *szLabel);
713
714
732static void
734
735
736
779static void
781 QCBORItem *pItem,
782 UsefulBufC *pEncodedCBOR);
783
784static void
785QCBORDecode_GetArrayFromMapN(QCBORDecodeContext *pCtx,
786 int64_t nLabel,
787 QCBORItem *pItem,
788 UsefulBufC *pEncodedCBOR);
789
790static void
791QCBORDecode_GetArrayFromMapSZ(QCBORDecodeContext *pCtx,
792 const char *szLabel,
793 QCBORItem *pItem,
794 UsefulBufC *pEncodedCBOR);
795
796
851static void
853
854void
855QCBORDecode_EnterMapFromMapN(QCBORDecodeContext *pCtx, int64_t nLabel);
856
857void
858QCBORDecode_EnterMapFromMapSZ(QCBORDecodeContext *pCtx, const char *szLabel);
859
860
878static void
880
881
925static void
927 QCBORItem *pItem,
928 UsefulBufC *pEncodedCBOR);
929
930static void
931QCBORDecode_GetMapFromMapN(QCBORDecodeContext *pCtx,
932 int64_t nLabel,
933 QCBORItem *pItem,
934 UsefulBufC *pEncodedCBOR);
935
936static void
937QCBORDecode_GetMapFromMapSZ(QCBORDecodeContext *pCtx,
938 const char *szLabel,
939 QCBORItem *pItem,
940 UsefulBufC *pEncodedCBOR);
941
942
959void
961
962
997void
999 int64_t nLabel,
1000 uint8_t uQcborType,
1001 QCBORItem *pItem);
1002
1003void
1004QCBORDecode_GetItemInMapSZ(QCBORDecodeContext *pCtx,
1005 const char *szLabel,
1006 uint8_t uQcborType,
1007 QCBORItem *pItem);
1008
1009
1068void
1070
1071
1087typedef QCBORError (*QCBORItemCallback)(void *pCallbackCtx,
1088 const QCBORItem *pItem);
1089
1090
1115void
1117 QCBORItem *pItemList,
1118 void *pCallbackCtx,
1119 QCBORItemCallback pfCB);
1120
1121
1122
1123
1137void
1139
1140void
1141QCBORDecode_GetBoolInMapN(QCBORDecodeContext *pCtx,
1142 int64_t nLabel,
1143 bool *pbBool);
1144
1145void
1146QCBORDecode_GetBoolInMapSZ(QCBORDecodeContext *pCtx,
1147 const char *szLabel,
1148 bool *pbBool);
1149
1150
1161static void
1163
1164static void
1165QCBORDecode_GetNullInMapN(QCBORDecodeContext *pCtx,
1166 int64_t nLabel);
1167
1168static void
1169QCBORDecode_GetNullInMapSZ(QCBORDecodeContext *pCtx,
1170 const char *szLabel);
1171
1172
1184static void
1186
1187static void
1188QCBORDecode_GetUndefinedInMapN(QCBORDecodeContext *pCtx,
1189 int64_t nLabel);
1190
1191static void
1192QCBORDecode_GetUndefinedInMapSZ(QCBORDecodeContext *pCtx,
1193 const char *szLabel);
1194
1195
1211void
1212QCBORDecode_GetSimple(QCBORDecodeContext *pCtx, uint8_t *puSimpleValue);
1213
1214void
1215QCBORDecode_GetSimpleInMapN(QCBORDecodeContext *pCtx,
1216 int64_t nLabel,
1217 uint8_t *puSimpleValue);
1218
1219void
1220QCBORDecode_GetSimpleInMapSZ(QCBORDecodeContext *pCtx,
1221 const char *szLabel,
1222 uint8_t *puSimpleValue);
1223
1224
1225
1226
1245static void
1247 uint8_t uTagRequirement,
1248 UsefulBufC *pDateString);
1249
1250static void
1251QCBORDecode_GetDateStringInMapN(QCBORDecodeContext *pCtx,
1252 int64_t nLabel,
1253 uint8_t uTagRequirement,
1254 UsefulBufC *pDateString);
1255
1256static void
1257QCBORDecode_GetDateStringInMapSZ(QCBORDecodeContext *pCtx,
1258 const char *szLabel,
1259 uint8_t uTagRequirement,
1260 UsefulBufC *pDateString);
1261
1262
1281static void
1283 uint8_t uTagRequirement,
1284 UsefulBufC *pDateString);
1285
1286static void
1287QCBORDecode_GetDaysStringInMapN(QCBORDecodeContext *pCtx,
1288 int64_t nLabel,
1289 uint8_t uTagRequirement,
1290 UsefulBufC *pDateString);
1291
1292static void
1293QCBORDecode_GetDaysStringInMapSZ(QCBORDecodeContext *pCtx,
1294 const char *szLabel,
1295 uint8_t uTagRequirement,
1296 UsefulBufC *pDateString);
1297
1298
1342void
1344 uint8_t uTagRequirement,
1345 int64_t *pnTime);
1346
1347void
1348QCBORDecode_GetEpochDateInMapN(QCBORDecodeContext *pCtx,
1349 int64_t nLabel,
1350 uint8_t uTagRequirement,
1351 int64_t *pnTime);
1352
1353void
1354QCBORDecode_GetEpochDateInMapSZ(QCBORDecodeContext *pCtx,
1355 const char *szLabel,
1356 uint8_t uTagRequirement,
1357 int64_t *pnTime);
1358
1359
1379void
1381 uint8_t uTagRequirement,
1382 int64_t *pnDays);
1383
1384void
1385QCBORDecode_GetEpochDaysInMapN(QCBORDecodeContext *pCtx,
1386 int64_t nLabel,
1387 uint8_t uTagRequirement,
1388 int64_t *pnDays);
1389
1390void
1391QCBORDecode_GetEpochDaysInMapSZ(QCBORDecodeContext *pCtx,
1392 const char *szLabel,
1393 uint8_t uTagRequirement,
1394 int64_t *pnDays);
1395
1396
1397
1398
1447void
1449 uint8_t uTagRequirement,
1450 UsefulBufC *pValue,
1451 bool *pbIsNegative);
1452
1453void
1454QCBORDecode_GetBignumInMapN(QCBORDecodeContext *pCtx,
1455 int64_t nLabel,
1456 uint8_t uTagRequirement,
1457 UsefulBufC *pValue,
1458 bool *pbIsNegative);
1459
1460void
1461QCBORDecode_GetBignumInMapSZ(QCBORDecodeContext *pCtx,
1462 const char *szLabel,
1463 uint8_t uTagRequirement,
1464 UsefulBufC *pValue,
1465 bool *pbIsNegative);
1466
1467
1468
1469
1470#ifndef QCBOR_DISABLE_EXP_AND_MANTISSA
1517void
1519 uint8_t uTagRequirement,
1520 int64_t *pnMantissa,
1521 int64_t *pnExponent);
1522
1523void
1524QCBORDecode_GetDecimalFractionInMapN(QCBORDecodeContext *pCtx,
1525 int64_t nLabel,
1526 uint8_t uTagRequirement,
1527 int64_t *pnMantissa,
1528 int64_t *pnExponent);
1529
1530void
1531QCBORDecode_GetDecimalFractionInMapSZ(QCBORDecodeContext *pMe,
1532 const char *szLabel,
1533 uint8_t uTagRequirement,
1534 int64_t *pnMantissa,
1535 int64_t *pnExponent);
1536
1537
1582void
1584 uint8_t uTagRequirement,
1585 UsefulBuf MantissaBuffer,
1586 UsefulBufC *pMantissa,
1587 bool *pbMantissaIsNegative,
1588 int64_t *pnExponent);
1589
1590void
1591QCBORDecode_GetDecimalFractionBigInMapN(QCBORDecodeContext *pCtx,
1592 int64_t nLabel,
1593 uint8_t uTagRequirement,
1594 UsefulBuf MantissaBuffer,
1595 UsefulBufC *pbMantissaIsNegative,
1596 bool *pbIsNegative,
1597 int64_t *pnExponent);
1598
1599void
1600QCBORDecode_GetDecimalFractionBigInMapSZ(QCBORDecodeContext *pCtx,
1601 const char *szLabel,
1602 uint8_t uTagRequirement,
1603 UsefulBuf MantissaBuffer,
1604 UsefulBufC *pMantissa,
1605 bool *pbMantissaIsNegative,
1606 int64_t *pnExponent);
1607
1608
1636void
1638 uint8_t uTagRequirement,
1639 int64_t *pnMantissa,
1640 int64_t *pnExponent);
1641
1642void
1643QCBORDecode_GetBigFloatInMapN(QCBORDecodeContext *pCtx,
1644 int64_t nLabel,
1645 uint8_t uTagRequirement,
1646 int64_t *pnMantissa,
1647 int64_t *pnExponent);
1648
1649void
1650QCBORDecode_GetBigFloatInMapSZ(QCBORDecodeContext *pCtx,
1651 const char *szLabel,
1652 uint8_t uTagRequirement,
1653 int64_t *pnMantissa,
1654 int64_t *pnExponent);
1655
1656
1682void
1684 uint8_t uTagRequirement,
1685 UsefulBuf MantissaBuffer,
1686 UsefulBufC *pMantissa,
1687 bool *pbMantissaIsNegative,
1688 int64_t *pnExponent);
1689
1690void
1691QCBORDecode_GetBigFloatBigInMapN(QCBORDecodeContext *pCtx,
1692 int64_t nLabel,
1693 uint8_t uTagRequirement,
1694 UsefulBuf MantissaBuffer,
1695 UsefulBufC *pMantissa,
1696 bool *pbMantissaIsNegative,
1697 int64_t *pnExponent);
1698
1699void
1700QCBORDecode_GetBigFloatBigInMapSZ(QCBORDecodeContext *pCtx,
1701 const char *szLabel,
1702 uint8_t uTagRequirement,
1703 UsefulBuf MantissaBuffer,
1704 UsefulBufC *pMantissa,
1705 bool *pbMantissaIsNegative,
1706 int64_t *pnExponent);
1707#endif /* #ifndef QCBOR_DISABLE_EXP_AND_MANTISSA */
1708
1709
1710
1711
1730static void
1732 uint8_t uTagRequirement,
1733 UsefulBufC *pURI);
1734
1735static void
1736QCBORDecode_GetURIInMapN(QCBORDecodeContext *pCtx,
1737 int64_t nLabel,
1738 uint8_t uTagRequirement,
1739 UsefulBufC *pURI);
1740
1741static void
1742QCBORDecode_GetURIInMapSZ(QCBORDecodeContext *pCtx,
1743 const char * szLabel,
1744 uint8_t uTagRequirement,
1745 UsefulBufC *pURI);
1746
1747
1768static void
1770 uint8_t uTagRequirement,
1771 UsefulBufC *pB64Text);
1772
1773static void
1774QCBORDecode_GetB64InMapN(QCBORDecodeContext *pCtx,
1775 int64_t nLabel,
1776 uint8_t uTagRequirement,
1777 UsefulBufC *pB64Text);
1778
1779static void
1780QCBORDecode_GetB64InMapSZ(QCBORDecodeContext *pCtx,
1781 const char *szLabel,
1782 uint8_t uTagRequirement,
1783 UsefulBufC *pB64Text);
1784
1805static void
1807 uint8_t uTagRequirement,
1808 UsefulBufC *pB64Text);
1809
1810static void
1811QCBORDecode_GetB64URLInMapN(QCBORDecodeContext *pCtx,
1812 int64_t nLabel,
1813 uint8_t uTagRequirement,
1814 UsefulBufC *pB64Text);
1815
1816static void
1817QCBORDecode_GetB64URLInMapSZ(QCBORDecodeContext *pCtx,
1818 const char *szLabel,
1819 uint8_t uTagRequirement,
1820 UsefulBufC *pB64Text);
1821
1840static void
1842 uint8_t uTagRequirement,
1843 UsefulBufC *pRegex);
1844
1845static void
1846QCBORDecode_GetRegexInMapN(QCBORDecodeContext *pCtx,
1847 int64_t nLabel,
1848 uint8_t uTagRequirement,
1849 UsefulBufC *pRegex);
1850
1851static void
1852QCBORDecode_GetRegexInMapSZ(QCBORDecodeContext *pCtx,
1853 const char * szLabel,
1854 uint8_t uTagRequirement,
1855 UsefulBufC *pRegex);
1856
1857
1889static void
1891 uint8_t uTagRequirement,
1892 UsefulBufC *pMessage,
1893 bool *pbIsTag257);
1894
1895static void
1896QCBORDecode_GetMIMEMessageInMapN(QCBORDecodeContext *pCtx,
1897 int64_t nLabel,
1898 uint8_t uTagRequirement,
1899 UsefulBufC *pMessage,
1900 bool *pbIsTag257);
1901
1902
1903static void
1904QCBORDecode_GetMIMEMessageInMapSZ(QCBORDecodeContext *pCtx,
1905 const char *szLabel,
1906 uint8_t uTagRequirement,
1907 UsefulBufC *pMessage,
1908 bool *pbIsTag257);
1909
1928static void
1930 uint8_t uTagRequirement,
1931 UsefulBufC *pUUID);
1932
1933static void
1934QCBORDecode_GetBinaryUUIDInMapN(QCBORDecodeContext *pCtx,
1935 int64_t nLabel,
1936 uint8_t uTagRequirement,
1937 UsefulBufC *pUUID);
1938
1939static void
1940QCBORDecode_GetBinaryUUIDInMapSZ(QCBORDecodeContext *pCtx,
1941 const char *szLabel,
1942 uint8_t uTagRequirement,
1943 UsefulBufC *pUUID);
1944
1945
1946
1998void
2000 uint8_t uTagRequirement,
2001 UsefulBufC *pBstr);
2002
2003void
2004QCBORDecode_EnterBstrWrappedFromMapN(QCBORDecodeContext *pCtx,
2005 int64_t nLabel,
2006 uint8_t uTagRequirement,
2007 UsefulBufC *pBstr);
2008
2009void
2010QCBORDecode_EnterBstrWrappedFromMapSZ(QCBORDecodeContext *pCtx,
2011 const char *szLabel,
2012 uint8_t uTagRequirement,
2013 UsefulBufC *pBstr);
2014
2015
2029void
2031
2032
2033
2034
2035/* ========================================================================= *
2036 * BEGINNING OF PRIVATE INLINE IMPLEMENTATION *
2037 * ========================================================================= */
2038
2039
2040/* Semi-private funcion used by public inline functions. See qcbor_decode.c */
2041void
2042QCBORDecode_Private_GetUInt64Convert(QCBORDecodeContext *pCtx,
2043 uint32_t uConvertTypes,
2044 uint64_t *puValue,
2045 QCBORItem *pItem);
2046
2047
2048/* Semi-private funcion used by public inline functions. See qcbor_decode.c */
2049void
2050QCBORDecode_Private_GetUInt64ConvertInMapN(QCBORDecodeContext *pCtx,
2051 int64_t nLabel,
2052 uint32_t uConvertTypes,
2053 uint64_t *puValue,
2054 QCBORItem *pItem);
2055
2056
2057/* Semi-private funcion used by public inline functions. See qcbor_decode.c */
2058void
2059QCBORDecode_Private_GetUInt64ConvertInMapSZ(QCBORDecodeContext *pCtx,
2060 const char *szLabel,
2061 uint32_t uConvertTypes,
2062 uint64_t *puValue,
2063 QCBORItem *pItem);
2064
2065/* Semi-private funcion used by public inline functions. See qcbor_decode.c */
2066void
2067QCBORDecode_Private_EnterBoundedMapOrArray(QCBORDecodeContext *pCtx,
2068 uint8_t uType,
2069 QCBORItem *pItem);
2070
2071/* Semi-private funcion used by public inline functions. See qcbor_decode.c */
2072void
2073QCBORDecode_Private_ExitBoundedMapOrArray(QCBORDecodeContext *pCtx,
2074 uint8_t uType);
2075
2076
2077/* Semi-private funcion used by public inline functions. See qcbor_decode.c */
2078void
2079QCBORDecode_Private_GetInt64Convert(QCBORDecodeContext *pCtx,
2080 uint32_t uConvertTypes,
2081 int64_t *pnValue,
2082 QCBORItem *pItem);
2083
2084/* Semi-private funcion used by public inline functions. See qcbor_decode.c */
2085void
2086QCBORDecode_Private_GetInt64ConvertInMapN(QCBORDecodeContext *pCtx,
2087 int64_t nLabel,
2088 uint32_t uConvertTypes,
2089 int64_t *pnValue,
2090 QCBORItem *pItem);
2091
2092/* Semi-private funcion used by public inline functions. See qcbor_decode.c */
2093void
2094QCBORDecode_Private_GetInt64ConvertInMapSZ(QCBORDecodeContext *pCtx,
2095 const char *szLabel,
2096 uint32_t uConvertTypes,
2097 int64_t *pnValue,
2098 QCBORItem *pItem);
2099
2100
2101#ifndef USEFULBUF_DISABLE_ALL_FLOAT
2102/* Semi-private funcion used by public inline functions. See qcbor_decode.c */
2103void
2104QCBORDecode_Private_GetDoubleConvert(QCBORDecodeContext *pCtx,
2105 uint32_t uConvertTypes,
2106 double *pValue,
2107 QCBORItem *pItem);
2108
2109/* Semi-private funcion used by public inline functions. See qcbor_decode.c */
2110void
2111QCBORDecode_Private_GetDoubleConvertInMapN(QCBORDecodeContext *pCtx,
2112 int64_t nLabel,
2113 uint32_t uConvertTypes,
2114 double *pdValue,
2115 QCBORItem *pItem);
2116
2117/* Semi-private funcion used by public inline functions. See qcbor_decode.c */
2118void
2119QCBORDecode_Private_GetDoubleConvertInMapSZ(QCBORDecodeContext *pCtx,
2120 const char *szLabel,
2121 uint32_t uConvertTypes,
2122 double *pdValue,
2123 QCBORItem *pItem);
2124#endif /* !USEFULBUF_DISABLE_ALL_FLOAT */
2125
2126#define QCBOR_TAGSPEC_NUM_TYPES 4
2127/* Semi-private data structure (which might change).
2128 *
2129 * See QCBOR_Private_CheckTagRequirement() which uses this to check the
2130 * type of an item to be decoded as a tag or tag content.
2131 *
2132 * Improvement: Carefully understand what compilers do with this,
2133 * particularly initialization and see if it can be optimized so there
2134 * is less code and maybe so it can be smaller.
2135 */
2136typedef struct {
2137 /* One of QCBOR_TAGSPEC_MATCH_xxx */
2138 uint8_t uTagRequirement;
2139 /* The tagged type translated into QCBOR_TYPE_XXX. Used to match
2140 * explicit tagging */
2141 uint8_t uTaggedTypes[QCBOR_TAGSPEC_NUM_TYPES];
2142 /* The types of the content, which are used to match implicit
2143 * tagging */
2144 uint8_t uAllowedContentTypes[QCBOR_TAGSPEC_NUM_TYPES];
2146
2147
2148/* Semi-private funcion used by public inline functions. See qcbor_decode.c */
2149void
2150QCBORDecode_Private_GetTaggedString(QCBORDecodeContext *pCtx,
2151 QCBOR_Private_TagSpec TagSpec,
2152 UsefulBufC *pBstr);
2153
2154
2155/* Semi-private funcion used by public inline functions. See qcbor_decode.c */
2156void
2157QCBORDecode_Private_GetTaggedStringInMapN(QCBORDecodeContext *pCtx,
2158 int64_t nLabel,
2159 QCBOR_Private_TagSpec TagSpec,
2160 UsefulBufC *pString);
2161
2162/* Semi-private funcion used by public inline functions. See qcbor_decode.c */
2163void
2164QCBORDecode_Private_GetTaggedStringInMapSZ(QCBORDecodeContext *pCtx,
2165 const char *szLabel,
2166 QCBOR_Private_TagSpec TagSpec,
2167 UsefulBufC *pString);
2168
2169
2170/* Semi-private funcion used by public inline functions. See qcbor_decode.c */
2172QCBORDecode_Private_GetMIME(uint8_t uTagRequirement,
2173 const QCBORItem *pItem,
2174 UsefulBufC *pMessage,
2175 bool *pbIsTag257);
2176
2177
2178
2179
2180
2181static inline void
2183 const uint32_t uConvertTypes,
2184 uint64_t *puValue)
2185{
2186 QCBORItem Item;
2187 QCBORDecode_Private_GetUInt64Convert(pMe, uConvertTypes, puValue, &Item);
2188}
2189
2190static inline void
2191QCBORDecode_GetUInt64ConvertInMapN(QCBORDecodeContext *pMe,
2192 const int64_t nLabel,
2193 const uint32_t uConvertTypes,
2194 uint64_t *puValue)
2195{
2196 QCBORItem Item;
2197 QCBORDecode_Private_GetUInt64ConvertInMapN(pMe,
2198 nLabel,
2199 uConvertTypes,
2200 puValue,
2201 &Item);
2202}
2203
2204static inline void
2205QCBORDecode_GetUInt64ConvertInMapSZ(QCBORDecodeContext *pMe,
2206 const char *szLabel,
2207 const uint32_t uConvertTypes,
2208 uint64_t *puValue)
2209{
2210 QCBORItem Item;
2211 QCBORDecode_Private_GetUInt64ConvertInMapSZ(pMe,
2212 szLabel,
2213 uConvertTypes,
2214 puValue,
2215 &Item);
2216}
2217
2218static inline void
2223
2224static inline void
2225QCBORDecode_GetUInt64InMapN(QCBORDecodeContext *pMe,
2226 const int64_t nLabel,
2227 uint64_t *puValue)
2228{
2229 QCBORDecode_GetUInt64ConvertInMapN(pMe,
2230 nLabel,
2232 puValue);
2233}
2234
2235static inline void
2236QCBORDecode_GetUInt64InMapSZ(QCBORDecodeContext *pMe,
2237 const char *szLabel,
2238 uint64_t *puValue)
2239{
2240 QCBORDecode_GetUInt64ConvertInMapSZ(pMe,
2241 szLabel,
2243 puValue);
2244}
2245
2246
2247static inline void
2249 QCBORDecode_Private_EnterBoundedMapOrArray(pMe, QCBOR_TYPE_MAP, pItem);
2250}
2251
2252static inline void
2254 QCBORDecode_Private_EnterBoundedMapOrArray(pMe, QCBOR_TYPE_ARRAY, pItem);
2255}
2256
2257
2258static inline void
2260{
2261 QCBORDecode_Private_ExitBoundedMapOrArray(pMe, QCBOR_TYPE_ARRAY);
2262}
2263
2264static inline void
2266{
2267 QCBORDecode_Private_ExitBoundedMapOrArray(pMe, QCBOR_TYPE_MAP);
2268}
2269
2270
2271/* Semi-private funcion used by public inline functions. See qcbor_decode.c */
2272void
2273QCBORDecode_Private_GetArrayOrMap(QCBORDecodeContext *pCtx,
2274 uint8_t uType,
2275 QCBORItem *pItem,
2276 UsefulBufC *pEncodedCBOR);
2277
2278
2279/* Semi-private funcion used by public inline functions. See qcbor_decode.c */
2280void
2281QCBORDecode_Private_SearchAndGetArrayOrMap(QCBORDecodeContext *pCtx,
2282 QCBORItem *pTarget,
2283 QCBORItem *pItem,
2284 UsefulBufC *pEncodedCBOR);
2285
2286
2287static inline void
2289 QCBORItem *pItem,
2290 UsefulBufC *pEncodedCBOR)
2291{
2292 QCBORDecode_Private_GetArrayOrMap(pMe, QCBOR_TYPE_ARRAY, pItem, pEncodedCBOR);
2293}
2294
2295
2296static inline void
2297QCBORDecode_GetArrayFromMapN(QCBORDecodeContext *pMe,
2298 int64_t nLabel,
2299 QCBORItem *pItem,
2300 UsefulBufC *pEncodedCBOR)
2301{
2302 QCBORItem OneItemSearch[2];
2303 OneItemSearch[0].uLabelType = QCBOR_TYPE_INT64;
2304 OneItemSearch[0].label.int64 = nLabel;
2305 OneItemSearch[0].uDataType = QCBOR_TYPE_ARRAY;
2306 OneItemSearch[1].uLabelType = QCBOR_TYPE_NONE;
2307
2308 QCBORDecode_Private_SearchAndGetArrayOrMap(pMe, OneItemSearch, pItem, pEncodedCBOR);
2309}
2310
2311
2312static inline void
2313QCBORDecode_GetArrayFromMapSZ(QCBORDecodeContext *pMe,
2314 const char *szLabel,
2315 QCBORItem *pItem,
2316 UsefulBufC *pEncodedCBOR)
2317{
2318#ifndef QCBOR_DISABLE_NON_INTEGER_LABELS
2319 QCBORItem OneItemSearch[2];
2320 OneItemSearch[0].uLabelType = QCBOR_TYPE_TEXT_STRING;
2321 OneItemSearch[0].label.string = UsefulBuf_FromSZ(szLabel);
2322 OneItemSearch[0].uDataType = QCBOR_TYPE_ARRAY;
2323 OneItemSearch[1].uLabelType = QCBOR_TYPE_NONE;
2324
2325 QCBORDecode_Private_SearchAndGetArrayOrMap(pMe, OneItemSearch, pItem, pEncodedCBOR);
2326#else
2327 (void)szLabel;
2328 (void)pItem;
2329 (void)pEncodedCBOR;
2330 pMe->uLastError = QCBOR_ERR_MAP_LABEL_TYPE;
2331#endif /* ! QCBOR_DISABLE_NON_INTEGER_LABELS */
2332}
2333
2334static inline void
2336 QCBORItem *pItem,
2337 UsefulBufC *pEncodedCBOR)
2338{
2339 QCBORDecode_Private_GetArrayOrMap(pMe, QCBOR_TYPE_MAP, pItem, pEncodedCBOR);
2340}
2341
2342
2343static inline void
2344QCBORDecode_GetMapFromMapN(QCBORDecodeContext *pMe,
2345 int64_t nLabel,
2346 QCBORItem *pItem,
2347 UsefulBufC *pEncodedCBOR)
2348{
2349 QCBORItem OneItemSearch[2];
2350 OneItemSearch[0].uLabelType = QCBOR_TYPE_INT64;
2351 OneItemSearch[0].label.int64 = nLabel;
2352 OneItemSearch[0].uDataType = QCBOR_TYPE_MAP;
2353 OneItemSearch[1].uLabelType = QCBOR_TYPE_NONE;
2354
2355 QCBORDecode_Private_SearchAndGetArrayOrMap(pMe, OneItemSearch, pItem, pEncodedCBOR);
2356}
2357
2358
2359static inline void
2360QCBORDecode_GetMapFromMapSZ(QCBORDecodeContext *pMe,
2361 const char *szLabel,
2362 QCBORItem *pItem,
2363 UsefulBufC *pEncodedCBOR)
2364{
2365#ifndef QCBOR_DISABLE_NON_INTEGER_LABELS
2366 QCBORItem OneItemSearch[2];
2367 OneItemSearch[0].uLabelType = QCBOR_TYPE_TEXT_STRING;
2368 OneItemSearch[0].label.string = UsefulBuf_FromSZ(szLabel);
2369 OneItemSearch[0].uDataType = QCBOR_TYPE_MAP;
2370 OneItemSearch[1].uLabelType = QCBOR_TYPE_NONE;
2371
2372 QCBORDecode_Private_SearchAndGetArrayOrMap(pMe, OneItemSearch, pItem, pEncodedCBOR);
2373#else
2374 (void)szLabel;
2375 (void)pItem;
2376 (void)pEncodedCBOR;
2377 pMe->uLastError = QCBOR_ERR_MAP_LABEL_TYPE;
2378#endif /* ! QCBOR_DISABLE_NON_INTEGER_LABELS */
2379}
2380
2381
2382
2383static inline void
2385 const uint32_t uConvertTypes,
2386 int64_t *pnValue)
2387{
2388 QCBORItem Item;
2389 QCBORDecode_Private_GetInt64Convert(pMe, uConvertTypes, pnValue, &Item);
2390}
2391
2392static inline void
2393QCBORDecode_GetInt64ConvertInMapN(QCBORDecodeContext *pMe,
2394 const int64_t nLabel,
2395 const uint32_t uConvertTypes,
2396 int64_t *pnValue)
2397{
2398 QCBORItem Item;
2399 QCBORDecode_Private_GetInt64ConvertInMapN(pMe,
2400 nLabel,
2401 uConvertTypes,
2402 pnValue,
2403 &Item);
2404}
2405
2406static inline void
2407QCBORDecode_GetInt64ConvertInMapSZ(QCBORDecodeContext *pMe,
2408 const char *szLabel,
2409 const uint32_t uConvertTypes,
2410 int64_t *pnValue)
2411{
2412 QCBORItem Item;
2413 QCBORDecode_Private_GetInt64ConvertInMapSZ(pMe,
2414 szLabel,
2415 uConvertTypes,
2416 pnValue,
2417 &Item);
2418}
2419
2420static inline void
2425
2426static inline void
2427QCBORDecode_GetInt64InMapN(QCBORDecodeContext *pMe,
2428 const int64_t nLabel,
2429 int64_t *pnValue)
2430{
2431 QCBORDecode_GetInt64ConvertInMapN(pMe,
2432 nLabel,
2434 pnValue);
2435}
2436
2437static inline void
2438QCBORDecode_GetInt64InMapSZ(QCBORDecodeContext *pMe,
2439 const char *szLabel,
2440 int64_t *pnValue)
2441{
2442 QCBORDecode_GetInt64ConvertInMapSZ(pMe,
2443 szLabel,
2445 pnValue);
2446}
2447
2448
2449
2450
2451
2452#ifndef USEFULBUF_DISABLE_ALL_FLOAT
2453static inline void
2455 const uint32_t uConvertTypes,
2456 double *pdValue)
2457{
2458 QCBORItem Item;
2459 QCBORDecode_Private_GetDoubleConvert(pMe, uConvertTypes, pdValue, &Item);
2460}
2461
2462static inline void
2463QCBORDecode_GetDoubleConvertInMapN(QCBORDecodeContext *pMe,
2464 const int64_t nLabel,
2465 uint32_t uConvertTypes,
2466 double *pdValue)
2467{
2468 QCBORItem Item;
2469 QCBORDecode_Private_GetDoubleConvertInMapN(pMe,
2470 nLabel,
2471 uConvertTypes,
2472 pdValue,
2473 &Item);
2474}
2475
2476static inline void
2477QCBORDecode_GetDoubleConvertInMapSZ(QCBORDecodeContext *pMe,
2478 const char *szLabel,
2479 const uint32_t uConvertTypes,
2480 double *pdValue)
2481{
2482 QCBORItem Item;
2483 QCBORDecode_Private_GetDoubleConvertInMapSZ(pMe,
2484 szLabel,
2485 uConvertTypes,
2486 pdValue,
2487 &Item);
2488}
2489
2490static inline void
2495
2496static inline void
2497QCBORDecode_GetDoubleInMapN(QCBORDecodeContext *pMe,
2498 const int64_t nLabel,
2499 double *pdValue)
2500{
2501 QCBORDecode_GetDoubleConvertInMapN(pMe,
2502 nLabel,
2504 pdValue);
2505}
2506
2507static inline void
2508QCBORDecode_GetDoubleInMapSZ(QCBORDecodeContext *pMe,
2509 const char *szLabel,
2510 double *pdValue)
2511{
2512 QCBORDecode_GetDoubleConvertInMapSZ(pMe,
2513 szLabel,
2515 pdValue);
2516}
2517#endif /* USEFULBUF_DISABLE_ALL_FLOAT */
2518
2519
2520
2521
2522
2523static inline void
2525{
2526 // Complier should make this just a 64-bit integer parameter
2527 const QCBOR_Private_TagSpec TagSpec =
2528 {
2532 };
2533
2534 QCBORDecode_Private_GetTaggedString(pMe, TagSpec, pValue);
2535}
2536
2537static inline void
2538QCBORDecode_GetByteStringInMapN(QCBORDecodeContext *pMe,
2539 const int64_t nLabel,
2540 UsefulBufC *pBstr)
2541{
2542 const QCBOR_Private_TagSpec TagSpec =
2543 {
2547 };
2548 QCBORDecode_Private_GetTaggedStringInMapN(pMe, nLabel, TagSpec, pBstr);
2549}
2550
2551static inline void
2552QCBORDecode_GetByteStringInMapSZ(QCBORDecodeContext *pMe,
2553 const char *szLabel,
2554 UsefulBufC *pBstr)
2555{
2556 const QCBOR_Private_TagSpec TagSpec =
2557 {
2561 };
2562
2563 QCBORDecode_Private_GetTaggedStringInMapSZ(pMe, szLabel, TagSpec, pBstr);
2564}
2565
2566
2567static inline void
2569{
2570 // Complier should make this just 64-bit integer parameter
2571 const QCBOR_Private_TagSpec TagSpec =
2572 {
2576 };
2577
2578 QCBORDecode_Private_GetTaggedString(pMe, TagSpec, pValue);
2579}
2580
2581static inline void
2582QCBORDecode_GetTextStringInMapN(QCBORDecodeContext *pMe,
2583 const int64_t nLabel,
2584 UsefulBufC *pText)
2585{
2586 // This TagSpec only matches text strings; it also should optimize down
2587 // to passing a 64-bit integer
2588 const QCBOR_Private_TagSpec TagSpec =
2589 {
2593 };
2594
2595 QCBORDecode_Private_GetTaggedStringInMapN(pMe, nLabel, TagSpec, pText);
2596}
2597
2598static inline void
2599QCBORDecode_GetTextStringInMapSZ(QCBORDecodeContext *pMe,
2600 const char *szLabel,
2601 UsefulBufC *pText)
2602{
2603 const QCBOR_Private_TagSpec TagSpec =
2604 {
2608 };
2609
2610 QCBORDecode_Private_GetTaggedStringInMapSZ(pMe, szLabel, TagSpec, pText);
2611}
2612
2613static inline void
2615{
2616 QCBORItem item;
2617
2618 QCBORDecode_VGetNext(pMe, &item);
2619 if(pMe->uLastError == QCBOR_SUCCESS && item.uDataType != QCBOR_TYPE_NULL) {
2620 pMe->uLastError = QCBOR_ERR_UNEXPECTED_TYPE;
2621 }
2622}
2623
2624static inline void
2625QCBORDecode_GetNullInMapN(QCBORDecodeContext *pMe,
2626 const int64_t nLabel)
2627{
2628 QCBORItem Item;
2629 QCBORDecode_GetItemInMapN(pMe, nLabel, QCBOR_TYPE_NULL, &Item);
2630}
2631
2632static inline void
2633QCBORDecode_GetNullInMapSZ(QCBORDecodeContext *pMe,
2634 const char *szLabel)
2635{
2636 QCBORItem Item;
2637 QCBORDecode_GetItemInMapSZ(pMe, szLabel, QCBOR_TYPE_NULL, &Item);
2638}
2639
2640static inline void
2642{
2643 QCBORItem item;
2644
2645 QCBORDecode_VGetNext(pMe, &item);
2646 if(pMe->uLastError == QCBOR_SUCCESS && item.uDataType != QCBOR_TYPE_UNDEF) {
2647 pMe->uLastError = QCBOR_ERR_UNEXPECTED_TYPE;
2648 }
2649}
2650
2651static inline void
2652QCBORDecode_GetUndefinedInMapN(QCBORDecodeContext *pMe,
2653 const int64_t nLabel)
2654{
2655 QCBORItem Item;
2656 QCBORDecode_GetItemInMapN(pMe, nLabel, QCBOR_TYPE_UNDEF, &Item);
2657}
2658
2659static inline void
2660QCBORDecode_GetUndefinedInMapSZ(QCBORDecodeContext *pMe,
2661 const char *szLabel)
2662{
2663 QCBORItem Item;
2664 QCBORDecode_GetItemInMapSZ(pMe, szLabel, QCBOR_TYPE_UNDEF, &Item);
2665}
2666
2667
2668
2669static inline void
2671 const uint8_t uTagRequirement,
2672 UsefulBufC *pValue)
2673{
2674 const QCBOR_Private_TagSpec TagSpec =
2675 {
2676 uTagRequirement,
2679 };
2680
2681 QCBORDecode_Private_GetTaggedString(pMe, TagSpec, pValue);
2682}
2683
2684static inline void
2685QCBORDecode_GetDateStringInMapN(QCBORDecodeContext *pMe,
2686 const int64_t nLabel,
2687 const uint8_t uTagRequirement,
2688 UsefulBufC *pText)
2689{
2690 const QCBOR_Private_TagSpec TagSpec =
2691 {
2692 uTagRequirement,
2695 };
2696
2697 QCBORDecode_Private_GetTaggedStringInMapN(pMe, nLabel, TagSpec, pText);
2698}
2699
2700static inline void
2701QCBORDecode_GetDateStringInMapSZ(QCBORDecodeContext *pMe,
2702 const char *szLabel,
2703 const uint8_t uTagRequirement,
2704 UsefulBufC *pText)
2705{
2706 const QCBOR_Private_TagSpec TagSpec =
2707 {
2708 uTagRequirement,
2711 };
2712
2713 QCBORDecode_Private_GetTaggedStringInMapSZ(pMe, szLabel, TagSpec, pText);
2714}
2715
2716static inline void
2718 const uint8_t uTagRequirement,
2719 UsefulBufC *pValue)
2720{
2721 const QCBOR_Private_TagSpec TagSpec =
2722 {
2723 uTagRequirement,
2726 };
2727
2728 QCBORDecode_Private_GetTaggedString(pMe, TagSpec, pValue);
2729}
2730
2731static inline void
2732QCBORDecode_GetDaysStringInMapN(QCBORDecodeContext *pMe,
2733 const int64_t nLabel,
2734 const uint8_t uTagRequirement,
2735 UsefulBufC *pText)
2736{
2737 const QCBOR_Private_TagSpec TagSpec =
2738 {
2739 uTagRequirement,
2742 };
2743
2744 QCBORDecode_Private_GetTaggedStringInMapN(pMe, nLabel, TagSpec, pText);
2745}
2746
2747static inline void
2748QCBORDecode_GetDaysStringInMapSZ(QCBORDecodeContext *pMe,
2749 const char *szLabel,
2750 const uint8_t uTagRequirement,
2751 UsefulBufC *pText)
2752{
2753 const QCBOR_Private_TagSpec TagSpec =
2754 {
2755 uTagRequirement,
2758 };
2759
2760 QCBORDecode_Private_GetTaggedStringInMapSZ(pMe, szLabel, TagSpec, pText);
2761}
2762
2763
2764
2765static inline void
2767 const uint8_t uTagRequirement,
2768 UsefulBufC *pUUID)
2769{
2770 const QCBOR_Private_TagSpec TagSpec =
2771 {
2772 uTagRequirement,
2775 };
2776
2777 QCBORDecode_Private_GetTaggedString(pMe, TagSpec, pUUID);
2778}
2779
2780static inline void
2781QCBORDecode_GetURIInMapN(QCBORDecodeContext *pMe,
2782 const int64_t nLabel,
2783 const uint8_t uTagRequirement,
2784 UsefulBufC *pUUID)
2785{
2786 const QCBOR_Private_TagSpec TagSpec =
2787 {
2788 uTagRequirement,
2791 };
2792
2793 QCBORDecode_Private_GetTaggedStringInMapN(pMe, nLabel, TagSpec, pUUID);
2794}
2795
2796static inline void
2797QCBORDecode_GetURIInMapSZ(QCBORDecodeContext *pMe,
2798 const char *szLabel,
2799 const uint8_t uTagRequirement,
2800 UsefulBufC *pUUID)
2801{
2802 const QCBOR_Private_TagSpec TagSpec =
2803 {
2804 uTagRequirement,
2807 };
2808
2809 QCBORDecode_Private_GetTaggedStringInMapSZ(pMe, szLabel, TagSpec, pUUID);
2810}
2811
2812
2813static inline void
2815 const uint8_t uTagRequirement,
2816 UsefulBufC *pB64Text)
2817{
2818 const QCBOR_Private_TagSpec TagSpec =
2819 {
2820 uTagRequirement,
2823 };
2824
2825 QCBORDecode_Private_GetTaggedString(pMe, TagSpec, pB64Text);
2826}
2827
2828static inline void
2829QCBORDecode_GetB64InMapN(QCBORDecodeContext *pMe,
2830 const int64_t nLabel,
2831 const uint8_t uTagRequirement,
2832 UsefulBufC *pB64Text)
2833{
2834 const QCBOR_Private_TagSpec TagSpec =
2835 {
2836 uTagRequirement,
2839 };
2840
2841 QCBORDecode_Private_GetTaggedStringInMapN(pMe, nLabel, TagSpec, pB64Text);
2842}
2843
2844static inline void
2845QCBORDecode_GetB64InMapSZ(QCBORDecodeContext *pMe,
2846 const char *szLabel,
2847 const uint8_t uTagRequirement,
2848 UsefulBufC *pB64Text)
2849{
2850 const QCBOR_Private_TagSpec TagSpec =
2851 {
2852 uTagRequirement,
2855 };
2856 QCBORDecode_Private_GetTaggedStringInMapSZ(pMe, szLabel, TagSpec, pB64Text);
2857}
2858
2859
2860static inline void
2862 const uint8_t uTagRequirement,
2863 UsefulBufC *pB64Text)
2864{
2865 const QCBOR_Private_TagSpec TagSpec =
2866 {
2867 uTagRequirement,
2870 };
2871
2872 QCBORDecode_Private_GetTaggedString(pMe, TagSpec, pB64Text);
2873}
2874
2875static inline void
2876QCBORDecode_GetB64URLInMapN(QCBORDecodeContext *pMe,
2877 const int64_t nLabel,
2878 const uint8_t uTagRequirement,
2879 UsefulBufC *pB64Text)
2880{
2881 const QCBOR_Private_TagSpec TagSpec =
2882 {
2883 uTagRequirement,
2886 };
2887
2888 QCBORDecode_Private_GetTaggedStringInMapN(pMe, nLabel, TagSpec, pB64Text);
2889}
2890
2891static inline void
2892QCBORDecode_GetB64URLInMapSZ(QCBORDecodeContext *pMe,
2893 const char *szLabel,
2894 const uint8_t uTagRequirement,
2895 UsefulBufC *pB64Text)
2896{
2897 const QCBOR_Private_TagSpec TagSpec =
2898 {
2899 uTagRequirement,
2902 };
2903
2904 QCBORDecode_Private_GetTaggedStringInMapSZ(pMe, szLabel, TagSpec, pB64Text);
2905}
2906
2907
2908static inline void
2910 const uint8_t uTagRequirement,
2911 UsefulBufC *pRegex)
2912{
2913 const QCBOR_Private_TagSpec TagSpec =
2914 {
2915 uTagRequirement,
2918 };
2919
2920 QCBORDecode_Private_GetTaggedString(pMe, TagSpec, pRegex);
2921}
2922
2923static inline void
2924QCBORDecode_GetRegexInMapN(QCBORDecodeContext *pMe,
2925 const int64_t nLabel,
2926 const uint8_t uTagRequirement,
2927 UsefulBufC *pRegex)
2928{
2929 const QCBOR_Private_TagSpec TagSpec =
2930 {
2931 uTagRequirement,
2934 };
2935
2936 QCBORDecode_Private_GetTaggedStringInMapN(pMe, nLabel, TagSpec, pRegex);
2937}
2938
2939static inline void
2940QCBORDecode_GetRegexInMapSZ(QCBORDecodeContext *pMe,
2941 const char * szLabel,
2942 const uint8_t uTagRequirement,
2943 UsefulBufC *pRegex)
2944{
2945 const QCBOR_Private_TagSpec TagSpec =
2946 {
2947 uTagRequirement,
2950 };
2951
2952 QCBORDecode_Private_GetTaggedStringInMapSZ(pMe, szLabel, TagSpec, pRegex);
2953}
2954
2955
2956static inline void
2958 const uint8_t uTagRequirement,
2959 UsefulBufC *pMessage,
2960 bool *pbIsTag257)
2961{
2962 if(pMe->uLastError != QCBOR_SUCCESS) {
2963 /* Already in error state, do nothing */
2964 return;
2965 }
2966
2967 QCBORItem Item;
2968 QCBORError uError = QCBORDecode_GetNext(pMe, &Item);
2969 if(uError != QCBOR_SUCCESS) {
2970 pMe->uLastError = (uint8_t)uError;
2971 return;
2972 }
2973
2974 pMe->uLastError = (uint8_t)QCBORDecode_Private_GetMIME(uTagRequirement,
2975 &Item,
2976 pMessage,
2977 pbIsTag257);
2978}
2979
2980static inline void
2981QCBORDecode_GetMIMEMessageInMapN(QCBORDecodeContext *pMe,
2982 const int64_t nLabel,
2983 const uint8_t uTagRequirement,
2984 UsefulBufC *pMessage,
2985 bool *pbIsTag257)
2986{
2987 QCBORItem Item;
2988 QCBORDecode_GetItemInMapN(pMe, nLabel, QCBOR_TYPE_ANY, &Item);
2989
2990 if(pMe->uLastError == QCBOR_SUCCESS) {
2991 pMe->uLastError = (uint8_t)QCBORDecode_Private_GetMIME(uTagRequirement,
2992 &Item,
2993 pMessage,
2994 pbIsTag257);
2995 }
2996}
2997
2998static inline void
2999QCBORDecode_GetMIMEMessageInMapSZ(QCBORDecodeContext *pMe,
3000 const char *szLabel,
3001 const uint8_t uTagRequirement,
3002 UsefulBufC *pMessage,
3003 bool *pbIsTag257)
3004{
3005 QCBORItem Item;
3006 QCBORDecode_GetItemInMapSZ(pMe, szLabel, QCBOR_TYPE_ANY, &Item);
3007
3008 if(pMe->uLastError == QCBOR_SUCCESS) {
3009 pMe->uLastError = (uint8_t)QCBORDecode_Private_GetMIME(uTagRequirement,
3010 &Item,
3011 pMessage,
3012 pbIsTag257);
3013 }
3014}
3015
3016
3017static inline void
3019 const uint8_t uTagRequirement,
3020 UsefulBufC *pUUID)
3021{
3022 const QCBOR_Private_TagSpec TagSpec =
3023 {
3024 uTagRequirement,
3027 };
3028
3029 QCBORDecode_Private_GetTaggedString(pMe, TagSpec, pUUID);
3030}
3031
3032static inline void
3033QCBORDecode_GetBinaryUUIDInMapN(QCBORDecodeContext *pMe,
3034 const int64_t nLabel,
3035 const uint8_t uTagRequirement,
3036 UsefulBufC *pUUID)
3037{
3038 const QCBOR_Private_TagSpec TagSpec =
3039 {
3040 uTagRequirement,
3043 };
3044
3045 QCBORDecode_Private_GetTaggedStringInMapN(pMe, nLabel, TagSpec, pUUID);
3046}
3047
3048static inline void
3049QCBORDecode_GetBinaryUUIDInMapSZ(QCBORDecodeContext *pMe,
3050 const char *szLabel,
3051 const uint8_t uTagRequirement,
3052 UsefulBufC *pUUID)
3053{
3054 const QCBOR_Private_TagSpec TagSpec =
3055 {
3056 uTagRequirement,
3059 };
3060
3061 QCBORDecode_Private_GetTaggedStringInMapSZ(pMe, szLabel, TagSpec, pUUID);
3062}
3063
3064/* ======================================================================== *
3065 * END OF PRIVATE INLINE IMPLEMENTATION *
3066 * ======================================================================== */
3067
3068#ifdef __cplusplus
3069}
3070#endif
3071
3072#endif /* qcbor_spiffy_decode_h */
struct q_useful_buf UsefulBuf
static UsefulBufC UsefulBuf_FromSZ(const char *szString)
Convert a NULL-terminated string to a UsefulBufC.
Definition UsefulBuf.h:1835
struct q_useful_buf_c UsefulBufC
QCBORError
Definition qcbor_common.h:265
@ QCBOR_ERR_MAP_LABEL_TYPE
Definition qcbor_common.h:415
@ QCBOR_ERR_UNEXPECTED_TYPE
Definition qcbor_common.h:452
@ QCBOR_SUCCESS
Definition qcbor_common.h:267
#define QCBOR_TYPE_DAYS_STRING
Definition qcbor_decode.h:362
#define QCBOR_TYPE_BASE64URL
Definition qcbor_decode.h:335
void QCBORDecode_VGetNext(QCBORDecodeContext *pCtx, QCBORItem *pDecodedItem)
Get the next item (integer, byte string, array...) in the preorder traversal of the CBOR tree.
#define QCBOR_TYPE_UUID
Definition qcbor_decode.h:349
#define QCBOR_TYPE_DATE_STRING
Definition qcbor_decode.h:257
#define QCBOR_TYPE_ANY
Definition qcbor_decode.h:219
#define QCBOR_TYPE_BASE64
Definition qcbor_decode.h:339
QCBORError QCBORDecode_GetNext(QCBORDecodeContext *pCtx, QCBORItem *pDecodedItem)
Preorder traversal like QCBORDecode_VGetNext() without use of internal error state.
#define QCBOR_TYPE_NONE
Definition qcbor_decode.h:216
#define QCBOR_TYPE_NULL
Definition qcbor_decode.h:308
#define QCBOR_TYPE_TEXT_STRING
Definition qcbor_decode.h:242
#define QCBOR_TYPE_ARRAY
Definition qcbor_decode.h:231
#define QCBOR_TYPE_REGEX
Definition qcbor_decode.h:342
#define QCBOR_TYPE_INT64
Definition qcbor_decode.h:224
#define QCBOR_TYPE_UNDEF
Definition qcbor_decode.h:311
#define QCBOR_TYPE_MAP
Definition qcbor_decode.h:234
struct _QCBORDecodeContext QCBORDecodeContext
Definition qcbor_decode.h:659
#define QCBOR_TYPE_BYTE_STRING
Definition qcbor_decode.h:237
struct _QCBORItem QCBORItem
#define QCBOR_TYPE_URI
Definition qcbor_decode.h:331
void QCBORDecode_GetItemsInMap(QCBORDecodeContext *pCtx, QCBORItem *pItemList)
Get multiple labeled items from a CBOR map efficiently.
static void QCBORDecode_GetUndefined(QCBORDecodeContext *pCtx)
Decode the next item as a CBOR "undefined" item.
Definition qcbor_spiffy_decode.h:2641
static void QCBORDecode_EnterArray(QCBORDecodeContext *pCtx, QCBORItem *pItem)
Enter an array for decoding in bounded mode.
Definition qcbor_spiffy_decode.h:2253
static void QCBORDecode_GetArray(QCBORDecodeContext *pCtx, QCBORItem *pItem, UsefulBufC *pEncodedCBOR)
Get the encoded bytes that make up an array.
Definition qcbor_spiffy_decode.h:2288
void QCBORDecode_GetDecimalFraction(QCBORDecodeContext *pCtx, uint8_t uTagRequirement, int64_t *pnMantissa, int64_t *pnExponent)
Decode the next item as a decimal fraction.
void QCBORDecode_GetItemInMapN(QCBORDecodeContext *pCtx, int64_t nLabel, uint8_t uQcborType, QCBORItem *pItem)
Get an item in map by label and type.
static void QCBORDecode_GetB64URL(QCBORDecodeContext *pCtx, uint8_t uTagRequirement, UsefulBufC *pB64Text)
Decode the next item as base64URL encoded text.
Definition qcbor_spiffy_decode.h:2861
static void QCBORDecode_GetB64(QCBORDecodeContext *pCtx, uint8_t uTagRequirement, UsefulBufC *pB64Text)
Decode the next item as base64 encoded text.
Definition qcbor_spiffy_decode.h:2814
static void QCBORDecode_GetUInt64Convert(QCBORDecodeContext *pCtx, uint32_t uConvertTypes, uint64_t *puValue)
Decode next item as an unsigned 64-bit integer with basic conversions.
Definition qcbor_spiffy_decode.h:2182
void QCBORDecode_GetDoubleConvertAll(QCBORDecodeContext *pCtx, uint32_t uConvertTypes, double *pdValue)
Decode next item as a double floating-point value with conversion.
static void QCBORDecode_GetDouble(QCBORDecodeContext *pCtx, double *pValue)
Decode next item into a double floating-point value.
Definition qcbor_spiffy_decode.h:2491
void QCBORDecode_GetBool(QCBORDecodeContext *pCtx, bool *pbBool)
Decode the next item as a Boolean.
void QCBORDecode_GetBigFloat(QCBORDecodeContext *pCtx, uint8_t uTagRequirement, int64_t *pnMantissa, int64_t *pnExponent)
Decode the next item as a big float.
#define QCBOR_CONVERT_TYPE_FLOAT
Definition qcbor_spiffy_decode.h:195
static void QCBORDecode_GetNull(QCBORDecodeContext *pCtx)
Decode the next item as a null.
Definition qcbor_spiffy_decode.h:2614
void QCBORDecode_GetEpochDays(QCBORDecodeContext *pCtx, uint8_t uTagRequirement, int64_t *pnDays)
Decode the next item as an days-count epoch date.
static void QCBORDecode_GetMIMEMessage(QCBORDecodeContext *pCtx, uint8_t uTagRequirement, UsefulBufC *pMessage, bool *pbIsTag257)
Decode the next item as a MIME message.
Definition qcbor_spiffy_decode.h:2957
void QCBORDecode_GetUInt64ConvertAll(QCBORDecodeContext *pCtx, uint32_t uConvertTypes, uint64_t *puValue)
Decode next item into an unsigned 64-bit integer with conversions.
void QCBORDecode_Rewind(QCBORDecodeContext *pCtx)
Reset traversal cursor to start of map, array, byte-string wrapped CBOR or start of input.
void QCBORDecode_GetEpochDate(QCBORDecodeContext *pCtx, uint8_t uTagRequirement, int64_t *pnTime)
Decode the next item as an epoch date.
static void QCBORDecode_GetDaysString(QCBORDecodeContext *pCtx, uint8_t uTagRequirement, UsefulBufC *pDateString)
Decode the next item as a date-only string.
Definition qcbor_spiffy_decode.h:2717
static void QCBORDecode_ExitArray(QCBORDecodeContext *pCtx)
Exit an array that has been enetered.
Definition qcbor_spiffy_decode.h:2259
static void QCBORDecode_GetUInt64(QCBORDecodeContext *pCtx, uint64_t *puValue)
Decode next item into an unsigned 64-bit integer.
Definition qcbor_spiffy_decode.h:2219
void QCBORDecode_GetSimple(QCBORDecodeContext *pCtx, uint8_t *puSimpleValue)
Decode the next item as a CBOR simple value.
void QCBORDecode_GetBigFloatBig(QCBORDecodeContext *pCtx, uint8_t uTagRequirement, UsefulBuf MantissaBuffer, UsefulBufC *pMantissa, bool *pbMantissaIsNegative, int64_t *pnExponent)
Decode the next item as a big float with a big number mantissa.
void QCBORDecode_EnterBstrWrapped(QCBORDecodeContext *pCtx, uint8_t uTagRequirement, UsefulBufC *pBstr)
Decode some byte-string wrapped CBOR.
void QCBORDecode_GetInt64ConvertAll(QCBORDecodeContext *pCtx, uint32_t uConvertTypes, int64_t *pnValue)
Decode next item into a signed 64-bit integer with conversions.
#define QCBOR_TAG_REQUIREMENT_NOT_A_TAG
Definition qcbor_spiffy_decode.h:175
void QCBORDecode_ExitBstrWrapped(QCBORDecodeContext *pCtx)
Exit some bstr-wrapped CBOR has been enetered.
void QCBORDecode_GetItemsInMapWithCallback(QCBORDecodeContext *pCtx, QCBORItem *pItemList, void *pCallbackCtx, QCBORItemCallback pfCB)
Get a group of labeled items all at once from a map with a callback.
static void QCBORDecode_GetInt64(QCBORDecodeContext *pCtx, int64_t *pnValue)
Decode next item into a signed 64-bit integer.
Definition qcbor_spiffy_decode.h:2421
static void QCBORDecode_GetInt64Convert(QCBORDecodeContext *pCtx, uint32_t uConvertTypes, int64_t *pnValue)
Decode next item into a signed 64-bit integer with basic conversions.
Definition qcbor_spiffy_decode.h:2384
#define QCBOR_TAG_REQUIREMENT_TAG
Definition qcbor_spiffy_decode.h:169
static void QCBORDecode_GetByteString(QCBORDecodeContext *pCtx, UsefulBufC *pBytes)
Decode the next item as a byte string.
Definition qcbor_spiffy_decode.h:2524
static void QCBORDecode_EnterMap(QCBORDecodeContext *pCtx, QCBORItem *pItem)
Enter a map for decoding and searching.
Definition qcbor_spiffy_decode.h:2248
static void QCBORDecode_GetURI(QCBORDecodeContext *pCtx, uint8_t uTagRequirement, UsefulBufC *pURI)
Decode the next item as a URI.
Definition qcbor_spiffy_decode.h:2766
static void QCBORDecode_GetDateString(QCBORDecodeContext *pCtx, uint8_t uTagRequirement, UsefulBufC *pDateString)
Decode the next item as a date string.
Definition qcbor_spiffy_decode.h:2670
static void QCBORDecode_GetTextString(QCBORDecodeContext *pCtx, UsefulBufC *pText)
Decode the next item as a text string.
Definition qcbor_spiffy_decode.h:2568
#define QCBOR_CONVERT_TYPE_XINT64
Definition qcbor_spiffy_decode.h:192
void QCBORDecode_GetDecimalFractionBig(QCBORDecodeContext *pCtx, uint8_t uTagRequirement, UsefulBuf MantissaBuffer, UsefulBufC *pMantissa, bool *pbMantissaIsNegative, int64_t *pnExponent)
Decode the next item as a decimal fraction with a big number mantissa.
#define QCBOR_TAG_REQUIREMENT_ALLOW_ADDITIONAL_TAGS
Definition qcbor_spiffy_decode.h:185
static void QCBORDecode_GetMap(QCBORDecodeContext *pCtx, QCBORItem *pItem, UsefulBufC *pEncodedCBOR)
Get the bytes that make up a map.
Definition qcbor_spiffy_decode.h:2335
static void QCBORDecode_GetBinaryUUID(QCBORDecodeContext *pCtx, uint8_t uTagRequirement, UsefulBufC *pUUID)
Decode the next item as a UUID.
Definition qcbor_spiffy_decode.h:3018
QCBORError(* QCBORItemCallback)(void *pCallbackCtx, const QCBORItem *pItem)
Per-item callback for map searching.
Definition qcbor_spiffy_decode.h:1087
static void QCBORDecode_GetDoubleConvert(QCBORDecodeContext *pCtx, uint32_t uConvertTypes, double *pdValue)
Decode next item into a double floating-point with basic conversion.
Definition qcbor_spiffy_decode.h:2454
void QCBORDecode_GetBignum(QCBORDecodeContext *pCtx, uint8_t uTagRequirement, UsefulBufC *pValue, bool *pbIsNegative)
Decode the next item as a big number.
static void QCBORDecode_GetRegex(QCBORDecodeContext *pCtx, uint8_t uTagRequirement, UsefulBufC *pRegex)
Decode the next item as a regular expression.
Definition qcbor_spiffy_decode.h:2909
static void QCBORDecode_ExitMap(QCBORDecodeContext *pCtx)
Exit a map that has been enetered.
Definition qcbor_spiffy_decode.h:2265
union _QCBORItem::@142366264112071376221236236241357252244130212175 label
UsefulBufC string
Definition qcbor_decode.h:475
int64_t int64
Definition qcbor_decode.h:468
uint8_t uDataType
Definition qcbor_decode.h:437
uint8_t uLabelType
Definition qcbor_decode.h:441
Definition qcbor_spiffy_decode.h:2136