-
Notifications
You must be signed in to change notification settings - Fork 47
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
Rework Id creation to check statically for invalid IDs #230
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cannot test further at the moment, as the corresponding libMatroska PR doesn't merge anymore due to conflicts in KaxSemantic.cpp after merging some other PR.
ebml/EbmlId.h
Outdated
return Value >= 0x4000; | ||
if (Value < 0x1000000) | ||
return Value >= 0x200000; | ||
return Value >= 0x10000000; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wrong indentation for the last return
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed. I'll rebase the branches soon.
It's a 32-bit value, there's only 4 possible lengths.
In C++17 that implies "inline".
It's deduced during contruction.
An EbmlId can never be bigger that 4. There is no constructor with a value higher than 4 bytes. It can never be lower than 0 as it's unsigned. It can never be 0 because a value of 0 corresponds to 0x80 in EBML.
When we have a buffer we can convert it to an Id value.
Maybe it's possible with std::enable_if but I haven't managed to do it. Not sure it would be usable on reading though.
We don't need to pass the length of the ID anymore (we may not even store it anymore).
libmatroska will need this to build Matroska-Org/libmatroska#169