-
-
Notifications
You must be signed in to change notification settings - Fork 6.7k
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
Binary subtype field cannot represent all CBOR tags #2863
Comments
Indeed the library currently only supports subtypes in the range of 0..255. I can't remember why we decided for |
It would change the size of the object and the return type of this function (which has an error in its comment, it doesn't return -1 for unset):
This could potentially cause build errors if it were changed if someone assigns it to a uint8_t and there's now a narrowing conversion. It could also cause issues if two different modules were compiled with different versions and passed objects around, but I'm not sure that's something that should be supported anyway. |
Good catch noticing the issue with the return type! |
Also, is it possible to add a binary element without tagging it at all? Tag number 0 cannot be used for this purpose as it has been assigned a meaning. |
The binary type has a member function has_subclass to check this. See https://json.nlohmann.me/features/binary_values/#api-for-binary-values |
I started to work on the issue, see #2908. Next step would be to set |
Does the default value of the subtype member need to change from 0 to -1 to match the comment, or does the comment need to be updated? |
The value of |
Next steps on #2908: the binary subtype uses |
@DavidJRobertson @gregmarr PR #2908 is now ready for review. All that is missing is overworking the documentation wrt. the new subtype type and the fact that tags in CBOR can now be stored (rather than just being ignore). |
@nlohmann Ah, you're right, I missed that fix in the function itself. |
I would merge the branch later today. Feedback still welcome! |
The subtype field on
binary_t
/byte_container_with_subtype
has type uint8_t. Since these subtypes are mapped to CBOR tags, I had expected to be able to use tag values above 255 (list of tags: https://www.iana.org/assignments/cbor-tags/cbor-tags.xhtml)The text was updated successfully, but these errors were encountered: