Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

QCBOREncode_Tell and QCBOREncode_SubString #251

Merged
merged 8 commits into from
Aug 16, 2024
Merged

Conversation

laurencelundblade
Copy link
Owner

Address #247 and #248

(initial PR; testing still needed)

Copy link
Contributor

@BrianSipos BrianSipos left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Even with my comment above, the addition of QCBOREncode_RetrieveOutputStorage() and QCBOREncode_Tell() fits my needs.

*
* See important usage WARNING in QCBOREncode_Tell()
*/
UsefulBufC
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since this is the encoder side and the original buffer is mutable anyway, could this return a non-const UsefulBuf?

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That would be counter to the UsefulBuf convention of UsefulBuf's with data always be const and empty buffers not const. I think that convention is upheld everywhere (including t_cose).

I don't mean to be pedantic about it, but I'd like to keep it as for consistency with the convention.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's fair and my need can use overall Tell offsets where modifying the encoded form is needed for efficiency.

@BrianSipos
Copy link
Contributor

BrianSipos commented Aug 13, 2024

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
Copy link
Owner Author

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
Copy link
Owner Author

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
Copy link
Contributor

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.

@laurencelundblade laurencelundblade merged commit e222674 into master Aug 16, 2024
44 checks passed
@laurencelundblade laurencelundblade deleted the encode_tell branch August 16, 2024 17:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants