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 default value
Xmlize default value [message #37808] Wed, 14 November 2012 10:27 Go to next message
koldo is currently offline  koldo
Messages: 3355
Registered: August 2008
Senior Veteran
Hello all

A possible idea to improve Xmlize/Serialize functions would be to add a default value to be used when no data is found loading the class.

It could be like this

void Xmlize(XmlIO &xml) {
	xml
		("MyString", myString, "Default value")
		("MyDouble", myDouble, 1200.2)
	;
}


Best regards
Iñaki
Re: Xmlize default value [message #39590 is a reply to message #37808] Tue, 02 April 2013 22:29 Go to previous messageGo to next message
nixnixnix is currently offline  nixnixnix
Messages: 415
Registered: February 2007
Location: Kelowna, British Columbia
Senior Member
I agree.

My understanding of XML was that it is relatively robust so that if there is a missing field, it just gets ignored. However, the current version sets missing fields to null which seems to defeat the purpose.

Can this be easily fixed or extended to work the way that Koldo suggests? Either would work for me.

Nick
Re: Xmlize default value [message #39591 is a reply to message #39590] Tue, 02 April 2013 23:53 Go to previous messageGo to next message
koldo is currently offline  koldo
Messages: 3355
Registered: August 2008
Senior Veteran
Thank you Nick.

I still think it would be good Smile


Best regards
Iñaki
Re: Xmlize default value [message #41703 is a reply to message #39591] Sun, 12 January 2014 00:03 Go to previous messageGo to next message
nixnixnix is currently offline  nixnixnix
Messages: 415
Registered: February 2007
Location: Kelowna, British Columbia
Senior Member
Still think this would be a good addition for reasons stated above.

Cheers,

Nick
Re: Xmlize default value [message #41707 is a reply to message #41703] Sun, 12 January 2014 20:20 Go to previous messageGo to next message
koldo is currently offline  koldo
Messages: 3355
Registered: August 2008
Senior Veteran
Added to Redmine here.

Best regards
Iñaki
Re: Xmlize default value [message #42003 is a reply to message #41707] Mon, 10 February 2014 15:07 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
I have implemented this, but I have encountred nasty problem on the way. All works fine except for string, where there is unresolvable overloading ambiguity with

template <class T> XmlIO operator()(const char *tag, const char *itemtag, T& var);

which is variant intended to choose tag of items while serializing containers.

The only nice solution would be to change this non-operator method, something like

template <class T> XmlIO Container(const char *tag, const char *itemtag, T& var);

or perhaps possible remove it completely (currently, there are also default variants with "item", "key" etc...).

Any suggestions?
Re: Xmlize default value [message #42032 is a reply to message #42003] Wed, 12 February 2014 18:38 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
In the end, solved by changing operator() to List method. (I guess nobody bothers to use this feature anyways).

Mirek
Re: Xmlize default value [message #42039 is a reply to message #42032] Thu, 13 February 2014 00:01 Go to previous message
nixnixnix is currently offline  nixnixnix
Messages: 415
Registered: February 2007
Location: Kelowna, British Columbia
Senior Member
Thanks Mirek,

Works for me. Smile

Nick
Previous Topic: proposal: bool Index::HasUnlinked()
Next Topic: To get xml errors from LoadFromXML
Goto Forum:
  


Current Time: Thu Mar 28 15:14:18 CET 2024

Total time taken to generate the page: 0.01463 seconds