laurencelundblade / QCBOR

Comprehensive, powerful, commercial-quality CBOR encoder/ decoder that is still suited for small devices.
Other
182 stars 47 forks source link

QCBOREncode_Tell and QCBOREncode_SubString #251

Closed laurencelundblade closed 1 month ago

laurencelundblade commented 1 month ago

Address #247 and #248

(initial PR; testing still needed)

BrianSipos commented 1 month ago

This doesn't fully address #248. For the decoder there could be a public API similar to QCBORDecode_RetrieveInputStorage() to access the input UsefulBufC.

laurencelundblade commented 1 month ago

This doesn't fully address #248. For the encoder there could be a public API similar to QCBORDecode_RetrieveInputStorage() to access the input UsefulBufC.

You want the thus-far-encoded CBOR, right? You can get that by passing 0 as the start to SubString(). Finish() can also be called multiple times, but it errors if there are open arrays or maps, where SubString doesn't. (If you look inside the implementation of Finish and SubString are almost the same too)

Thanks for your feedback.

laurencelundblade commented 1 month ago

This doesn't fully address #248. For the encoder there could be a public API similar to QCBORDecode_RetrieveInputStorage() to access the input UsefulBufC.

You want the thus-far-encoded CBOR, right? You can get that by passing 0 as the start to SubString(). Finish() can also be called multiple times, but it errors if there are open arrays or maps, where SubString doesn't. (If you look inside the implementation of Finish and SubString are almost the same too)

Thanks for your feedback.

Ahh, but you are talking about QCBORDecode() aren't you. That's fine. Got too focused on encode.

BrianSipos commented 1 month ago

Ahh, but you are talking about QCBORDecode() aren't you. That's fine. Got too focused on encode.

Yes it didn't help that I had a typo in my comment. This is about a similar interface for the decoder.