Skip to content

Commit 9e9aaf5

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 f0e4868 commit 9e9aaf5

File tree

2 files changed

+70
-60
lines changed

2 files changed

+70
-60
lines changed

src/cbor.h

+1-60
Original file line numberDiff line numberDiff line change
@@ -322,71 +322,12 @@ enum CborParserIteratorFlags
322322

323323
struct CborValue;
324324

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-
*/
325+
330326
struct CborParserOperations
331327
{
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 value The CBOR value being parsed.
338-
*
339-
* \param len The number of bytes sought.
340-
*
341-
* \retval true \a len bytes may be read from the reader.
342-
* \retval false Insufficient data is available to be read at this time.
343-
*/
344328
bool (*can_read_bytes)(const struct CborValue *value, size_t len);
345-
346-
/**
347-
* Reads \a len bytes from the reader starting at \a offset bytes from
348-
* the current read position and copies them to \a dst. The read pointer
349-
* is *NOT* modified by this operation.
350-
*
351-
* \param value The CBOR value being parsed.
352-
*
353-
* \param dst The buffer the read bytes will be copied to.
354-
*
355-
* \param offset The starting position for the read relative to the
356-
* current read position.
357-
*
358-
* \param len The number of bytes sought.
359-
*/
360329
void *(*read_bytes)(const struct CborValue *value, void *dst, size_t offset, size_t len);
361-
362-
/**
363-
* Skips past \a len bytes from the reader without reading them. The read
364-
* pointer is advanced in the process.
365-
*
366-
* \param value The CBOR value being parsed.
367-
*
368-
* \param len The number of bytes skipped.
369-
*/
370330
void (*advance_bytes)(struct CborValue *value, size_t len);
371-
372-
/**
373-
* Overwrite the user-supplied pointer \a userptr with the address where the
374-
* data indicated by \a offset is located, then advance the read pointer
375-
* \a len bytes beyond that point.
376-
*
377-
* This routine is used for accessing strings embedded in CBOR documents
378-
* (both text and binary strings).
379-
*
380-
* \param value The CBOR value being parsed.
381-
*
382-
* \param userptr The pointer that will be updated to reference the location
383-
* of the data in the buffer.
384-
*
385-
* \param offset The starting position for the read relative to the
386-
* current read position.
387-
*
388-
* \param len The number of bytes sought.
389-
*/
390331
CborError (*transfer_string)(struct CborValue *value, const void **userptr, size_t offset, size_t len);
391332
};
392333

src/cborparser.c

+69
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)