You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
There are different ways to go about this. From the top of my head, I can think of two:
The most basic approach would be to introduce an ensureFullyParsed() function that throws if the current structure contains more children.
Forces you to be explicit about your intentions. Should you forget this call at the end of your parsing function and run into errors it it plain to see what is going on.
The need to be explicit makes it easy to screw up.
Add a consumeFully() method that takes a lambda. This lambda would contain the parsing code. If, after leaving the lambda, there's still content left -> throw.
This layer of indirection and the fact that exisitng code related to decoding would need to be adapted with another layer of indirection makes this cumbersome and error-prone
Introduce a flag to the Asn1Decodable interface that indicates whetherdoDecode() should have consumed all content.
We could make it default to true (because, let's be honest, this is what you want), then no changes would be needed to 99% of all parsing code. Realistically, this means that no parsing logic would need to be adapted, only cleaned up, to remove redundant checks.
We could not add a default value, then it would need to be explicitly set by every implementing class. Upside: no changes in behaviour. Downside: breaks existing code.
Whatever we do: having libraries compiled against different versions of Signum in the same classpath could lead to issues.
No description provided.
The text was updated successfully, but these errors were encountered: