36#ifndef qcbor_main_decode_h 
   37#define qcbor_main_decode_h 
   41#include "qcbor/qcbor_private.h" 
  293#define QCBOR_MAX_DECODE_INPUT_SIZE (UINT32_MAX - 2) 
  299#define QCBOR_MAX_TAGS_PER_ITEM QCBOR_MAX_TAGS_PER_ITEM1 
  305#define QCBOR_TYPE_NONE           0 
  308#define QCBOR_TYPE_ANY            1 
  313#define QCBOR_TYPE_INT64          2 
  317#define QCBOR_TYPE_UINT64         3 
  320#define QCBOR_TYPE_ARRAY          4 
  323#define QCBOR_TYPE_MAP            5 
  326#define QCBOR_TYPE_BYTE_STRING    6 
  331#define QCBOR_TYPE_TEXT_STRING    7 
  336#define QCBOR_TYPE_POSBIGNUM      9 
  349#define QCBOR_TYPE_NEGBIGNUM     10 
  356#define QCBOR_TYPE_DATE_STRING   11 
  360#define QCBOR_TYPE_DATE_EPOCH    12 
  369#define QCBOR_TYPE_UKNOWN_SIMPLE 13 
  373#define QCBOR_TYPE_DECIMAL_FRACTION            14 
  378#define QCBOR_TYPE_DECIMAL_FRACTION_POS_BIGNUM 15 
  383#define QCBOR_TYPE_DECIMAL_FRACTION_NEG_BIGNUM 16 
  387#define QCBOR_TYPE_DECIMAL_FRACTION_POS_U64    79 
  392#define QCBOR_TYPE_DECIMAL_FRACTION_NEG_U64    80 
  397#define QCBOR_TYPE_BIGFLOAT                    17 
  402#define QCBOR_TYPE_BIGFLOAT_POS_BIGMANTISSA    18 
  403#define QCBOR_TYPE_BIGFLOAT_POS_BIGNUM         18 
  408#define QCBOR_TYPE_BIGFLOAT_NEG_BIGMANTISSA    19 
  409#define QCBOR_TYPE_BIGFLOAT_NEG_BIGNUM         19 
  414#define QCBOR_TYPE_BIGFLOAT_POS_U64MANTISSA    82 
  419#define QCBOR_TYPE_BIGFLOAT_NEG_U64MANTISSA    83 
  422#define QCBOR_TYPE_FALSE         20 
  425#define QCBOR_TYPE_TRUE          21 
  428#define QCBOR_TYPE_NULL          22 
  431#define QCBOR_TYPE_UNDEF         23 
  434#define QCBOR_TYPE_FLOAT         26 
  437#define QCBOR_TYPE_DOUBLE        27 
  446#define QCBOR_TYPE_65BIT_NEG_INT 28 
  449#define QCBOR_TYPE_BREAK         31 
  453#define QCBOR_TYPE_MAP_AS_ARRAY  32 
  458#define QBCOR_TYPE_WRAPPED_CBOR  36 
  461#define QCBOR_TYPE_URI           44 
  465#define QCBOR_TYPE_BASE64URL     45 
  469#define QCBOR_TYPE_BASE64        46 
  472#define QCBOR_TYPE_REGEX         47 
  476#define QCBOR_TYPE_MIME          48 
  479#define QCBOR_TYPE_UUID          49 
  483#define QBCOR_TYPE_WRAPPED_CBOR_SEQUENCE  75 
  487#define QCBOR_TYPE_BINARY_MIME   76 
  492#define QCBOR_TYPE_DAYS_STRING   77 
  497#define QCBOR_TYPE_DAYS_EPOCH    78 
  503#define QCBOR_TYPE_TAG_NUMBER 127 
  507#define QCBOR_TYPE_START_USER_DEFINED 128 
  510#define QCBOR_TYPE_END_USER_DEFINED 255 
  517#define QCBOR_LAST_UNMAPPED_TAG (CBOR_TAG_INVALID16 - QCBOR_NUM_MAPPED_TAGS - 1) 
  623#ifndef USEFULBUF_DISABLE_ALL_FLOAT 
  641#ifndef USEFULBUF_DISABLE_ALL_FLOAT 
  642         double   fSecondsFraction;
 
  657#ifndef QCBOR_DISABLE_EXP_AND_MANTISSA 
  664      uint8_t     userDefined[24];
 
  671#ifndef QCBOR_DISABLE_NON_INTEGER_LABELS 
  680#ifndef QCBOR_DISABLE_TAGS 
 
  696#define QCBOR_COUNT_INDICATES_INDEFINITE_LENGTH UINT16_MAX 
  774#define QCBOR_DECODE_MIN_MEM_POOL_SIZE 8 
  860#ifndef QCBOR_DISABLE_INDEFINITE_LENGTH_STRINGS 
  897                           void               *pAllocateContext,
 
 1449                                   const uint16_t            uMappedTagNumber);
 
 1456                                uint8_t            *puNextNestLevel);
 
 1462                                  const size_t        uOffset,
 
 1471#ifndef QCBOR_DISABLE_INDEFINITE_LENGTH_STRINGS 
 1475                           void               *pAllocateContext,
 
 1478   pMe->StringAllocator.pfAllocator   = pfAllocateFunction;
 
 1479   pMe->StringAllocator.pAllocateCxt  = pAllocateContext;
 
 1480   pMe->bStringAllocateAll            = bAllStrings;
 
 
 1485static inline uint32_t
 
 1488   if(pMe->uLastError) {
 
 
 1519   if(uErr >= QCBOR_START_OF_NOT_WELL_FORMED_ERRORS &&
 
 1520      uErr <= QCBOR_END_OF_NOT_WELL_FORMED_ERRORS) {
 
 
 1530   if(uErr >= QCBOR_START_OF_UNRECOVERABLE_DECODE_ERRORS &&
 
 1531      uErr <= QCBOR_END_OF_UNRECOVERABLE_DECODE_ERRORS) {
 
 
 1542   pMe->uLastError = (uint8_t)uError;
 
 
 1550#ifndef QCBOR_DISABLE_TAGS 
 1551   memcpy(pMe->auLastTagNumbers,
 
 1564#ifndef QCBOR_DISABLE_TAGS 
 1571   *uOffset = SIZE_MAX;
 
 1574   pMe->uLastError = (uint8_t)QCBORDecode_Private_GetNextTagContent(pMe, Item);
 
 1586#if  QCBOR_MAP_OFFSET_CACHE_INVALID < QCBOR_MAX_DECODE_INPUT_SIZE 
 1587#error QCBOR_MAP_OFFSET_CACHE_INVALID is too large 
 1590#if QCBOR_NON_BOUNDED_OFFSET < QCBOR_MAX_DECODE_INPUT_SIZE 
 1591#error QCBOR_NON_BOUNDED_OFFSET is too large 
struct q_useful_buf UsefulBuf
static UsefulBufC UsefulInputBuf_RetrieveUndecodedInput(UsefulInputBuf *pUInBuf)
Retrieve the undecoded input buffer.
Definition UsefulBuf.h:2708
static size_t UsefulInputBuf_Tell(UsefulInputBuf *pUInBuf)
Returns current position in input buffer.
Definition UsefulBuf.h:2450
QCBORError
Definition qcbor_common.h:260
@ QCBOR_SUCCESS
Definition qcbor_common.h:262
QCBORError QCBORDecode_PartialFinish(QCBORDecodeContext *pCtx, size_t *puConsumed)
Return number of bytes consumed so far.
void QCBORDecode_VGetNext(QCBORDecodeContext *pCtx, QCBORItem *pDecodedItem)
Get the next item (integer, byte string, array...) in the preorder traversal of the CBOR tree.
static void QCBORDecode_SetError(QCBORDecodeContext *pCtx, QCBORError uError)
Manually set error condition, or set user-defined error.
Definition qcbor_main_decode.h:1540
QCBORError QCBORDecode_EndCheck(QCBORDecodeContext *pCtx)
Tell whether cursor is at end of the input.
QCBORError QCBORDecode_GetNext(QCBORDecodeContext *pCtx, QCBORItem *pDecodedItem)
Preorder traversal like QCBORDecode_VGetNext() without use of internal error state.
static QCBORError QCBORDecode_GetAndResetError(QCBORDecodeContext *pCtx)
Get and reset the decoding error.
Definition qcbor_main_decode.h:1509
static bool QCBORDecode_IsUnrecoverableError(QCBORError uErr)
Whether a decoding error is recoverable.
Definition qcbor_main_decode.h:1528
void QCBORDecode_VPeekNext(QCBORDecodeContext *pCtx, QCBORItem *pDecodedItem)
Get the next data item without consuming it.
QCBORError QCBORDecode_Finish(QCBORDecodeContext *pCtx)
Check that a decode completed successfully.
static UsefulBufC QCBORDecode_RetrieveUndecodedInput(QCBORDecodeContext *pCtx)
Retrieve the undecoded input buffer.
Definition qcbor_main_decode.h:1497
void QCBORDecode_VGetNextConsume(QCBORDecodeContext *pCtx, QCBORItem *pDecodedItem)
Get the next item, fully consuming it if it is a map or array.
static void QCBORDecode_SetUpAllocator(QCBORDecodeContext *pCtx, QCBORStringAllocate pfAllocateFunction, void *pAllocateContext, bool bAllStrings)
Sets up a custom string allocator for indefinite-length strings.
Definition qcbor_main_decode.h:1473
UsefulBuf(* QCBORStringAllocate)(void *pAllocateCxt, void *pOldMem, size_t uNewSize)
Prototype for the implementation of a string allocator.
Definition qcbor_main_decode.h:759
struct _QCBORDecodeContext QCBORDecodeContext
Definition qcbor_main_decode.h:785
static bool QCBORDecode_IsNotWellFormedError(QCBORError uErr)
Whether an error indicates non-well-formed CBOR.
Definition qcbor_main_decode.h:1517
QCBORError QCBORDecode_PeekNext(QCBORDecodeContext *pCtx, QCBORItem *pDecodedItem)
Get the next data item without consuming it without use of internal error state.
static QCBORError QCBORDecode_GetError(QCBORDecodeContext *pCtx)
Get the decoding error.
Definition qcbor_main_decode.h:1503
QCBORError QCBORDecode_SetMemPool(QCBORDecodeContext *pCtx, UsefulBuf MemPool, bool bAllStrings)
Set up the MemPool string allocator for indefinite-length strings.
static uint32_t QCBORDecode_Tell(QCBORDecodeContext *pCtx)
Get the current traversal cursort offset in the input CBOR.
Definition qcbor_main_decode.h:1486
struct _QCBORItem QCBORItem
QCBORDecodeMode
Definition qcbor_main_decode.h:200
@ QCBOR_DECODE_MODE_DCBOR
Definition qcbor_main_decode.h:281
@ QCBOR_DECODE_NO_INDEF_LENGTH
Definition qcbor_main_decode.h:226
@ QCBOR_DECODE_ALLOW_UNPROCESSED_TAG_NUMBERS
Definition qcbor_main_decode.h:223
@ QCBOR_DECODE_MODE_NORMAL
Definition qcbor_main_decode.h:202
@ QCBOR_DECODE_MODE_MAP_STRINGS_ONLY
Definition qcbor_main_decode.h:206
@ QCBOR_DECODE_ONLY_PREFERRED_BIG_NUMBERS
Definition qcbor_main_decode.h:235
@ QCBOR_DECODE_ONLY_SORTED_MAPS
Definition qcbor_main_decode.h:240
@ QCBOR_DECODE_MODE_PREFERRED
Definition qcbor_main_decode.h:264
@ QCBOR_DECODE_ONLY_PREFERRED_NUMBERS
Definition qcbor_main_decode.h:230
@ QCBOR_DECODE_MODE_CDE
Definition qcbor_main_decode.h:276
@ QCBOR_DECODE_ONLY_REDUCED_FLOATS
Definition qcbor_main_decode.h:246
@ QCBOR_DECODE_DISALLOW_DCBOR_SIMPLES
Definition qcbor_main_decode.h:251
@ QCBOR_DECODE_MODE_MAP_AS_ARRAY
Definition qcbor_main_decode.h:217
void QCBORDecode_CompatibilityV1(QCBORDecodeContext *pCtx)
[Deprecated] Configure CBOR decoder context for QCBOR v1 compatibility.
void QCBORDecode_Init(QCBORDecodeContext *pCtx, UsefulBufC EncodedCBOR, QCBORDecodeMode uConfigFlags)
Definition qcbor_main_decode.h:574
union _QCBORItem::@2 label
UsefulBufC bigNum
Definition qcbor_main_decode.h:652
uint8_t uSimple
Definition qcbor_main_decode.h:655
UsefulBufC string
Definition qcbor_main_decode.h:615
uint8_t uLabelAlloc
Definition qcbor_main_decode.h:602
double dfnum
Definition qcbor_main_decode.h:625
int64_t epochDays
Definition qcbor_main_decode.h:648
float fnum
Definition qcbor_main_decode.h:627
QCBORMappedTagNumbers auTagNumbers
Definition qcbor_main_decode.h:689
int64_t int64
Definition qcbor_main_decode.h:608
uint64_t uint64
Definition qcbor_main_decode.h:610
uint8_t uDataAlloc
Definition qcbor_main_decode.h:596
uint8_t uDataType
Definition qcbor_main_decode.h:577
uint8_t uNestingLevel
Definition qcbor_main_decode.h:585
uint8_t uLabelType
Definition qcbor_main_decode.h:581
uint8_t uNextNestLevel
Definition qcbor_main_decode.h:590
struct _QCBORItem::@1::@3 epochDate
uint16_t uCount
Definition qcbor_main_decode.h:622
Definition qcbor_main_decode.h:554
Definition UsefulBuf.h:280
Definition UsefulBuf.h:291