tinyxml2 icon indicating copy to clipboard operation
tinyxml2 copied to clipboard

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

Open victorlevasseur opened this issue 8 years ago • 4 comments

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 avatar Feb 05 '17 14:02 victorlevasseur

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?

leethomason avatar Feb 05 '17 23:02 leethomason

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).

victorlevasseur avatar Feb 10 '17 18:02 victorlevasseur

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

JugglerShu avatar Aug 24 '17 02:08 JugglerShu

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.

RL-S avatar Jan 19 '23 15:01 RL-S