@@ -321,11 +321,80 @@ enum CborParserIteratorFlags
321
321
};
322
322
323
323
struct CborValue ;
324
+
325
+ /**
326
+ * Defines an interface for abstract document readers. This structure is used
327
+ * in conjunction with \ref cbor_parser_init_reader to define how the various
328
+ * required operations are to be implemented.
329
+ */
324
330
struct CborParserOperations
325
331
{
332
+ /**
333
+ * Determines whether \a len bytes may be read from the reader. This is
334
+ * called before \ref read_bytes and \ref transfer_bytes to ensure it is safe
335
+ * to read the requested number of bytes from the reader.
336
+ *
337
+ * \param token An opaque object passed to \ref cbor_parser_init_reader
338
+ * that may be used to pass context information between the
339
+ * \ref CborParserOperations methods.
340
+ *
341
+ * \param len The number of bytes sought.
342
+ *
343
+ * \retval true \a len bytes may be read from the reader.
344
+ * \retval false Insufficient data is available to be read at this time.
345
+ */
326
346
bool (* can_read_bytes )(void * token , size_t len );
347
+
348
+ /**
349
+ * Reads \a len bytes from the reader starting at \a offset bytes from
350
+ * the current read position and copies them to \a dst. The read pointer
351
+ * is *NOT* modified by this operation.
352
+ *
353
+ * \param token An opaque object passed to \ref cbor_parser_init_reader
354
+ * that may be used to pass context information between the
355
+ * \ref CborParserOperations methods.
356
+ *
357
+ * \param dst The buffer the read bytes will be copied to.
358
+ *
359
+ * \param offset The starting position for the read relative to the
360
+ * current read position.
361
+ *
362
+ * \param len The number of bytes sought.
363
+ */
327
364
void * (* read_bytes )(void * token , void * dst , size_t offset , size_t len );
365
+
366
+ /**
367
+ * Skips past \a len bytes from the reader without reading them. The read
368
+ * pointer is advanced in the process.
369
+ *
370
+ * \param token An opaque object passed to \ref cbor_parser_init_reader
371
+ * that may be used to pass context information between the
372
+ * \ref CborParserOperations methods.
373
+ *
374
+ * \param len The number of bytes skipped.
375
+ */
328
376
void (* advance_bytes )(void * token , size_t len );
377
+
378
+ /**
379
+ * Overwrite the user-supplied pointer \a userptr with the address where the
380
+ * data indicated by \a offset is located, then advance the read pointer
381
+ * \a len bytes beyond that point.
382
+ *
383
+ * This routine is used for accessing strings embedded in CBOR documents
384
+ * (both text and binary strings).
385
+ *
386
+ * \param token An opaque object passed to \ref cbor_parser_init_reader
387
+ * that may be used to pass context information between the
388
+ * \ref CborParserOperations methods.
389
+ *
390
+ * \param userptr The pointer that will be updated to reference the location
391
+ * of the data in the buffer.
392
+ *
393
+ * \param offset The starting position for the read relative to the
394
+ * current read position.
395
+ *
396
+ * \param len The number of bytes sought.
397
+ */
329
398
CborError (* transfer_string )(void * token , const void * * userptr , size_t offset , size_t len );
330
399
};
331
400
0 commit comments