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

Why XMLDocument::SaveFile is not const like in TinyXML 1 ? #523

Open
victorlevasseur opened this issue Feb 5, 2017 · 4 comments
Open

Why XMLDocument::SaveFile is not const like in TinyXML 1 ? #523

victorlevasseur opened this issue Feb 5, 2017 · 4 comments

Comments

@victorlevasseur
Copy link

victorlevasseur commented Feb 5, 2017

Just wonder why, as my program relies on this and I would prefer not to change it as a save operation is not supposed to change the XMLDocument object.

@victorlevasseur victorlevasseur changed the title Why XMLDocument::SaveFile is not const like in TinyXML 1 Why XMLDocument::SaveFile is not const like in TinyXML 1 ? Feb 5, 2017
@leethomason
Copy link
Owner

That's a minor bug. The issue is that SaveFile() can cause a SetError() to occur. Possibly SetError() should be mutable - but that's clunky - or the save shouldn't set an error?

@victorlevasseur
Copy link
Author

victorlevasseur commented Feb 10, 2017

Making SetError (and the errors attributes) mutable is a quick and easy solution. However, this isn't clean. Maybe XMLDocument shouln't store errors but functions currently using SetError should return a kind of Error object (as you don't want TinyXML2 to use exceptions).

@JugglerShu
Copy link

Same question on XMLDocument::DeepCopy. I think it can be const.

@RL-S
Copy link

RL-S commented Jan 19, 2023

Why is it not clean to declare the error value mutable? It sounds like the correct solution to achieve const-correctness.
I now have to compromise my program's const-correctness to work around SaveFile not being const, that's a lot less clean.

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

No branches or pull requests

4 participants