-
Notifications
You must be signed in to change notification settings - Fork 733
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
as_float() doesn't take the default value #163
Comments
Just to make sure, are you referring to the case where the attribute is present, but contains values that do not represent a valid floating point number? |
Yes |
So in general this is currently working as documented (documentation says that conversion issues result in unspecified values). In terms of implementation, this is currently tracked as #15 (for integer parsing there's now custom validation code, but the behavior hasn't been changed to use the default value; for floating point parsing currently pugixml relies on strtod, that has some issues wrt error reporting). Thinking about this, I realized that in one specific case the current behavior can be more surprising than usual, which is when the contents is empty. I could change the code to check that case specifically, although I'm not sure if in your case the value is empty as opposed to a non-empty string that just happens to not be a number. |
So I've tried two tests: With empty data: |
Yeah, my question is whether fixing this for just empty data is interesting to you. The default values were originally intended for use when attributes just don't exist, i.e. |
It didn't work for the invalid float either. |
Ok, for now I will just treat this as part of #15 then. |
I've tried passing the default values (not 0) to as_float() method described here. It doesn't seem to take it. The method still returns 0 when it can't convert the XML data.
The text was updated successfully, but these errors were encountered: