@@ -29,7 +29,7 @@ extern "C" {
29
29
* @anchor TagDecoding
30
30
* ## Tag Decoding
31
31
*
32
- * See @ref CBORTags first if you are unfamiliar with the notion of
32
+ * See @ref CBORTags first if you are unfamiliar with
33
33
* tags in CBOR.
34
34
*
35
35
* QCBOR v2 offers several ways to decode tags.
@@ -188,12 +188,12 @@ enum QCBORDecodeTagReq {
188
188
189
189
#ifndef QCBOR_DISABLE_TAGS
190
190
/**
191
- * @brief Returns the tag numbers for an item .
191
+ * @brief Get the next tag number .
192
192
*
193
- * @param[in] pCtx The decoder context.
193
+ * @param[in] pCtx The decoder context.
194
194
* @param[out] puTagNumber The returned tag number.
195
195
*
196
- * In QCBOR v2, all tag numbers on an item MUST be fetched with this
196
+ * In QCBOR v2, all tag numbers on an item must be fetched with this
197
197
* method. If not, @ref QCBOR_ERR_UNPROCESSED_TAG_NUMBER will
198
198
* occur. This is a major change from QCBORv1. The QCBOR v1 behavior
199
199
* is too lax for proper CBOR decoding. When a tag number occurs it
@@ -202,7 +202,7 @@ enum QCBORDecodeTagReq {
202
202
* incorrectly characterized as optional implying they could be
203
203
* ignored.
204
204
*
205
- * In typical item decoding, tag numbers are not used, not present and
205
+ * In much item decoding, tag numbers are not used, not present and
206
206
* not expected. There's no need to call this.
207
207
*
208
208
* When the protocol being decoded does use a tag number then this
@@ -216,8 +216,8 @@ enum QCBORDecodeTagReq {
216
216
* number to switch the flow of decoding. If there's a possibility of
217
217
* a tag number then this must be called.
218
218
*
219
- * If this is called and there is no tag number, then this will return
220
- * @ref QCBOR_SUCCESS and the tag number returned will be
219
+ * If this is called and there is no tag number, then this will succeed
220
+ * (no error will be set) and the tag number returned will be
221
221
* @ref CBOR_TAG_INVALID64.
222
222
*
223
223
* Usually there is only one tag number per item, but CBOR allows
@@ -236,9 +236,9 @@ QCBORDecode_VGetNextTagNumber(QCBORDecodeContext *pCtx, uint64_t *puTagNumber);
236
236
237
237
238
238
/**
239
- * @brief Returns the tag numbers for an item .
239
+ * @brief Get the next tag number .
240
240
*
241
- * @param[in] pCtx The decoder context.
241
+ * @param[in] pCtx The decoder context.
242
242
* @param[out] puTagNumber The returned tag number.
243
243
*
244
244
* @return See error table of decoding errors set by QCBORDecode_VGetNext().
@@ -258,30 +258,31 @@ QCBORError
258
258
QCBORDecode_GetNextTagNumberInMapSZ (QCBORDecodeContext * pCtx , const char * szLabel , uint64_t * puTagNumber );
259
259
260
260
261
-
262
261
/**
263
262
* @brief Returns the tag numbers for a decoded item.
264
263
*
265
264
* @param[in] pCtx The decoder context.
266
- * @param[in] pItem The CBOR item to get the tag for .
267
- * @param[in] uIndex The index of the tag to get.
265
+ * @param[in] pItem The decoded CBOR item to get the tag number from .
266
+ * @param[in] uIndex The index of the tag to get.
268
267
*
269
268
* @returns The nth tag number or @ref CBOR_TAG_INVALID64.
270
269
*
271
- * Typically, this is only used with @ref QCBOR_DECODE_ALLOW_UNPROCESSED_TAG_NUMBERS.
272
- * Normally, tag numbers are processed QCBORDecode_VGetNextTagNumber() or
273
- * QCBORTagContentCallBack.
270
+ * Tag numbers are typically processed by consuming them with
271
+ * QCBORDecode_VGetNextTagNumber() or a QCBORTagContentCallBack(),
272
+ * rather than this function. Use of this function should not be mixed
273
+ * with use of QCBORDecode_VGetNextTagNumber() or
274
+ * QCBORDecode_GetNextTagNumber().
274
275
*
275
- * TODO: rewrite this paragraph
276
- * TODO: are tag not fetched by QCBORDecode_VGetNextTagNumber put here?
277
- * When QCBOR decodes an item that is a tag, it will fully decode tags
278
- * it is able to. Tags that it is unable to process are put in a list
279
- * in the QCBORItem.
276
+ * When QCBOR is initialized with
277
+ * @ref QCBOR_DECODE_ALLOW_UNPROCESSED_TAG_NUMBERS, tag numbers preceding
278
+ * an item are accumulated and associated with the QCBORItem (as was
279
+ * always done in QCBOR v1). This function retrieves them from the
280
+ * item. They cannot be accessed directly from @c pItem because they
281
+ * are mapped to save space.
280
282
*
281
- * Tags nest. Here the tag with index 0 is the outermost, the one
282
- * furthest form the data item that is the tag content. This is
283
- * the opposite order of QCBORDecode_GetNthTag(), but more
284
- * useful.
283
+ * Tags nest. The tag at index 0 is the outermost, the furthest from
284
+ * the tagged data item. This ordering is the reverse of
285
+ * QCBORDecode_GetNthTag(), but is generally more useful.
285
286
*
286
287
* Deep tag nesting is rare so this implementation imposes a limit of
287
288
* @ref QCBOR_MAX_TAGS_PER_ITEM on nesting and returns @ref
@@ -290,15 +291,16 @@ QCBORDecode_GetNextTagNumberInMapSZ(QCBORDecodeContext *pCtx, const char *szLabe
290
291
* the constant can be increased and the library recompiled. It will
291
292
* use more memory).
292
293
*
293
- * See also @ref TagDecoding @ref CBORTags.
294
+ * Deep tag nesting is rare, so this implementation limits nesting to
295
+ * @ref QCBOR_MAX_TAGS_PER_ITEM. If this limit is exceeded,
296
+ * @ref QCBOR_ERR_TOO_MANY_TAGS is returned. This constraint is
297
+ * specific to this implementation, not CBOR itself .
294
298
*
295
- * To reduce memory used by a @ref QCBORItem, tag numbers larger than
296
- * @c UINT16_MAX are mapped so the tag numbers in @c auTagNumbers must be
297
- * accessed with this function rather than directly.
299
+ * See also @ref TagDecoding @ref CBORTags.
298
300
*
299
- * This returns @ref CBOR_TAG_INVALID64 if any error occurred when
300
- * getting the item. This is also returned if there are no tags on the
301
- * item or no tag at @c uIndex .
301
+ * If an error occurs when retrieving the item, or if the item has no
302
+ * tags or no tag at @c uIndex, this function returns @ref
303
+ * CBOR_TAG_INVALID64 .
302
304
*/
303
305
uint64_t
304
306
QCBORDecode_GetNthTagNumber (const QCBORDecodeContext * pCtx , const QCBORItem * pItem , uint8_t uIndex );
@@ -312,14 +314,22 @@ QCBORDecode_GetNthTagNumber(const QCBORDecodeContext *pCtx, const QCBORItem *pIt
312
314
*
313
315
* @returns The nth tag number or @ref CBOR_TAG_INVALID64.
314
316
*
315
- * This returns tags of the most recently decoded item. See
316
- * QCBORDecode_GetNthTagNumber(). This is particularly of use for spiffy
317
- * decode functions that don't return a @ref QCBORItem.
318
- *
319
- * This does not work for QCBORDecode_GetNext(),
320
- * QCBORDecode_PeekNext(), QCBORDecode_VPeekNext() or
321
- * QCBORDecode_VGetNextConsume() but these all return a
322
- * @ref QCBORItem, so it is not necessary.
317
+ * Like QCBORDecode_GetNthTagNumber(), this function is used when
318
+ * QCBOR is initialized with
319
+ * @ref QCBOR_DECODE_ALLOW_UNPROCESSED_TAG_NUMBERS. It returns the tag
320
+ * numbers of the most recently decoded item. See
321
+ * QCBORDecode_GetNthTagNumber().
322
+ *
323
+ * This is useful with spiffy decode functions that do not return a
324
+ * @ref QCBORItem. Use of this function should not be mixed with use
325
+ * of QCBORDecode_VGetNextTagNumber() or
326
+ * QCBORDecode_GetNextTagNumber().
327
+ *
328
+ * It does not work with QCBORDecode_GetNext(),
329
+ * QCBORDecode_PeekNext(), QCBORDecode_VPeekNext(), or
330
+ * QCBORDecode_VGetNextConsume() as these return the tag numbers in a
331
+ * @ref QCBORItem rather than save them as the last tags in the decode
332
+ * context.
323
333
*
324
334
* If a decoding error is set, then this returns @ref CBOR_TAG_INVALID64.
325
335
*/
0 commit comments