Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » U++ Library support » U++ Core » Xmlize and double
Problems with null doubles and Xmlize in 602b version. [message #903 is a reply to message #882] Tue, 07 February 2006 16:55 Go to previous messageGo to previous message
pivica is currently offline  pivica
Messages: 57
Registered: November 2005
Location: Belgrade, Serbia
Member
I've just downloaded 602b. Xmlize class for doubles works OK when numbers are not DOUBLE_NULL. But in application which I am developing user can leave empty EditDouble ctrls and in that case double from that ctrls has DOUBLE_NULL value. When storing with Xmlize such double value has empty string value, but when trying to load it XmlError("expected floating point number") is raised.

For example:

class A
{
public:
	void Xmlize(XmlIO xml) { xml ("d", d); }
	double d;
};

//...

EditDouble ctrl;
ctrl.Clear();

A a;
a.d = ctrl;	// Now d has DOUBLE_NULL value
StoreAsXMLFile(a, "a", "a.xml");
LoadFromXMLFile(a, "a.xml"); // return false!


"a.xml" after StoreAsXMLFile is something like this:

<a>
<d value=""/>
</a>

Problem is in Xmlize.cpp in XmlAttrLoad(double& var, const String& text) method, XmlError is raised when text is empty.

template<> void XmlAttrLoad(double& var, const String& text)
{
	CParser p(text);
	if(!p.IsDouble())
		throw XmlError("expected floating point number");
	var = p.ReadDouble();
}


My temporary workaround is to determine if text is empty:

template<> void XmlAttrLoad(double& var, const String& text)
{
	CParser p(text);
	/////
	if (text.IsEmpty())
	{
		var = DOUBLE_NULL;
		return;
	}
	/////
	if(!p.IsDouble())
		throw XmlError("expected floating point number");
	var = p.ReadDouble();
}


Same problem maybe exist in XmlAttrLoad(int& var, const String& text) and XmlAttrLoad(dword& var, const String& text). They are also throwing XmlError.
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: signature of the stou function
Next Topic: Serbian translation
Goto Forum:
  


Current Time: Sun Aug 24 13:27:13 CEST 2025

Total time taken to generate the page: 0.04868 seconds