Skip to content

Commit ccffc6f

Browse files
committed
cborencoder: Document the write callback function.
What is not known, is what the significance is of `CborEncoderAppendType`. It basically tells the writer the nature of the data being written, but the default implementation ignores this and just blindly appends it no matter what. That raises the question of why it's important enough that the writer function needs to know about it.
1 parent a41ea04 commit ccffc6f

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

src/cbor.h

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,20 @@ typedef enum CborEncoderAppendType
215215
CborEncoderAppendStringData = 1
216216
} CborEncoderAppendType;
217217

218-
typedef CborError (*CborEncoderWriteFunction)(void *, const void *, size_t, CborEncoderAppendType);
218+
/**
219+
* Writer interface call-back function. When there is data to be written to
220+
* the CBOR document, this routine will be called. The \a token parameter is
221+
* taken from the \a token argument provided to \ref cbor_encoder_init_writer
222+
* and may be used in any way the writer function sees fit.
223+
*
224+
* The \a data parameter contains a pointer to the raw bytes to be copied to
225+
* the output buffer, with \a len specifying how long the payload is, which
226+
* can be as small as a single byte or an entire (byte or text) string.
227+
*
228+
* The \a append parameter informs the writer function whether it is writing
229+
* a string or general CBOR data.
230+
*/
231+
typedef CborError (*CborEncoderWriteFunction)(void *token, const void *data, size_t len, CborEncoderAppendType append);
219232

220233
enum CborEncoderFlags
221234
{

0 commit comments

Comments
 (0)