Skip to content

Commit c5afe78

Browse files
committed
cbor.h, cborparser.c: Migrate parser documentation.
Not 100% sure of the syntax for documenting struct-members outside of the struct as I'm too used to doing it inline, hopefully this works as expected. :-)
1 parent 3c7f92b commit c5afe78

File tree

2 files changed

+70
-60
lines changed

2 files changed

+70
-60
lines changed

src/cbor.h

Lines changed: 1 addition & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -321,71 +321,12 @@ enum CborParserIteratorFlags
321321

322322
struct CborValue;
323323

324-
/**
325-
* Defines an interface for abstract document readers. This structure is used
326-
* in conjunction with \ref cbor_parser_init_reader to define how the various
327-
* required operations are to be implemented.
328-
*/
324+
329325
struct CborParserOperations
330326
{
331-
/**
332-
* Determines whether \a len bytes may be read from the reader. This is
333-
* called before \ref read_bytes and \ref transfer_bytes to ensure it is safe
334-
* to read the requested number of bytes from the reader.
335-
*
336-
* \param value The CBOR value being parsed.
337-
*
338-
* \param len The number of bytes sought.
339-
*
340-
* \retval true \a len bytes may be read from the reader.
341-
* \retval false Insufficient data is available to be read at this time.
342-
*/
343327
bool (*can_read_bytes)(const struct CborValue *value, size_t len);
344-
345-
/**
346-
* Reads \a len bytes from the reader starting at \a offset bytes from
347-
* the current read position and copies them to \a dst. The read pointer
348-
* is *NOT* modified by this operation.
349-
*
350-
* \param value The CBOR value being parsed.
351-
*
352-
* \param dst The buffer the read bytes will be copied to.
353-
*
354-
* \param offset The starting position for the read relative to the
355-
* current read position.
356-
*
357-
* \param len The number of bytes sought.
358-
*/
359328
void *(*read_bytes)(const struct CborValue *value, void *dst, size_t offset, size_t len);
360-
361-
/**
362-
* Skips past \a len bytes from the reader without reading them. The read
363-
* pointer is advanced in the process.
364-
*
365-
* \param value The CBOR value being parsed.
366-
*
367-
* \param len The number of bytes skipped.
368-
*/
369329
void (*advance_bytes)(struct CborValue *value, size_t len);
370-
371-
/**
372-
* Overwrite the user-supplied pointer \a userptr with the address where the
373-
* data indicated by \a offset is located, then advance the read pointer
374-
* \a len bytes beyond that point.
375-
*
376-
* This routine is used for accessing strings embedded in CBOR documents
377-
* (both text and binary strings).
378-
*
379-
* \param value The CBOR value being parsed.
380-
*
381-
* \param userptr The pointer that will be updated to reference the location
382-
* of the data in the buffer.
383-
*
384-
* \param offset The starting position for the read relative to the
385-
* current read position.
386-
*
387-
* \param len The number of bytes sought.
388-
*/
389330
CborError (*transfer_string)(struct CborValue *value, const void **userptr, size_t offset, size_t len);
390331
};
391332

src/cborparser.c

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,75 @@
141141
* \endif
142142
*/
143143

144+
/**
145+
* \struct CborParserOperations
146+
*
147+
* Defines an interface for abstract document readers. This structure is used
148+
* in conjunction with \ref cbor_parser_init_reader to define how the various
149+
* required operations are to be implemented.
150+
*
151+
*
152+
* \var CborParserOperations::can_read_bytes
153+
*
154+
* Determines whether \a len bytes may be read from the reader. This is
155+
* called before \ref read_bytes and \ref transfer_bytes to ensure it is safe
156+
* to read the requested number of bytes from the reader.
157+
*
158+
* \param value The CBOR value being parsed.
159+
*
160+
* \param len The number of bytes sought.
161+
*
162+
* \retval true \a len bytes may be read from the reader.
163+
* \retval false Insufficient data is available to be read at this time.
164+
*
165+
*
166+
* \var CborParserOperations::read_bytes
167+
*
168+
* Reads \a len bytes from the reader starting at \a offset bytes from
169+
* the current read position and copies them to \a dst. The read pointer
170+
* is *NOT* modified by this operation.
171+
*
172+
* \param value The CBOR value being parsed.
173+
*
174+
* \param dst The buffer the read bytes will be copied to.
175+
*
176+
* \param offset The starting position for the read relative to the
177+
* current read position.
178+
*
179+
* \param len The number of bytes sought.
180+
*
181+
*
182+
* \var CborParserOperations::advance_bytes
183+
*
184+
* Skips past \a len bytes from the reader without reading them. The read
185+
* pointer is advanced in the process.
186+
*
187+
* \param value The CBOR value being parsed.
188+
*
189+
* \param len The number of bytes skipped.
190+
*
191+
*
192+
* \var CborParserOperations::transfer_string
193+
*
194+
* Overwrite the user-supplied pointer \a userptr with the address where the
195+
* data indicated by \a offset is located, then advance the read pointer
196+
* \a len bytes beyond that point.
197+
*
198+
* This routine is used for accessing strings embedded in CBOR documents
199+
* (both text and binary strings).
200+
*
201+
* \param value The CBOR value being parsed.
202+
*
203+
* \param userptr The pointer that will be updated to reference the location
204+
* of the data in the buffer.
205+
*
206+
* \param offset The starting position for the read relative to the
207+
* current read position.
208+
*
209+
* \param len The number of bytes sought.
210+
*/
211+
212+
144213
static uint64_t extract_number_and_advance(CborValue *it)
145214
{
146215
/* This function is only called after we've verified that the number

0 commit comments

Comments
 (0)