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

Make ShouldWrite policy a state of each element #284

Open
robUx4 opened this issue Mar 2, 2024 · 0 comments
Open

Make ShouldWrite policy a state of each element #284

robUx4 opened this issue Mar 2, 2024 · 0 comments
Labels
abi-break breaks the ABI (e.g. programs linked against the library have to be recompiled) api-break breaks the API (e.g. programs using it will have to adjust their source code)

Comments

@robUx4
Copy link
Contributor

robUx4 commented Mar 2, 2024

ShouldWrite is a new thing in 2.0. It's set to a default value in each call so older code don't need to care about it if they don't want too. But it's still missing in many places.

For example in EbmlMaster::PushElement() it should not add elements that would otherwise not be written. This is also called internally in ProcessMandatory(). There's also AddNewElt() calling PushElement() so would require the same ShouldWrite usage.

Adding ShouldWrite to each call that can potentially end up with a write element is not only tedious, but it's inconsistent. If one part of the code uses one particular ShouldWrite and another uses a different one (like the default by not explicitly setting one), they might end up adding/writing elements that are not allowed by one or the other.

Using a state (SetWriteFilter, GetWriteFilter) allows consistency between the calls. The setter may refuse to set the new policy if it doesn't match the current state, or it could have a flag to force the new policy.

@robUx4 robUx4 added api-break breaks the API (e.g. programs using it will have to adjust their source code) abi-break breaks the ABI (e.g. programs linked against the library have to be recompiled) labels Mar 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
abi-break breaks the ABI (e.g. programs linked against the library have to be recompiled) api-break breaks the API (e.g. programs using it will have to adjust their source code)
Projects
None yet
Development

No branches or pull requests

1 participant