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 » ...nize class
...nize class [message #36223] Mon, 14 May 2012 13:17 Go to next message
koldo is currently offline  koldo
Messages: 3354
Registered: August 2008
Senior Veteran
Hello Mirek

Now the syntax of Xmlize and Jsnize is identical. For example:

void SystemOverview::Xmlize(XmlIO &xml) {
	xml
		("signature", signature)("biosVersion", biosVersion)("biosSerial", biosSerial)
		("biosReleaseDate", biosReleaseDate)("computerName", computerName)("kernel", kernel)
		("kerVersion", kerVersion)("kerArchitecture", kerArchitecture)("distro", distro)
		("distVersion", distVersion)("desktop", desktop)("deskVersion", deskVersion)
		("compilerName", compilerName)("compilerVersion", compilerVersion)
		("compilerTime", compilerTime)("compilerMode", compilerMode)
	;	
}

void SystemOverview::Jsonize(JsonIO& json) {
	json
		("signature", signature)("biosVersion", biosVersion)("biosSerial", biosSerial)
		("biosReleaseDate", biosReleaseDate)("computerName", computerName)("kernel", kernel)
		("kerVersion", kerVersion)("kerArchitecture", kerArchitecture)("distro", distro)
		("distVersion", distVersion)("desktop", desktop)("deskVersion", deskVersion)
		("compilerName", compilerName)("compilerVersion", compilerVersion)
		("compilerTime", compilerTime)("compilerMode", compilerMode)
	;	
}

Would it be possible to have a kind of ...nize class to have only one basic implementation per class of the Jsonize and Xmlize methods?


Best regards
Iñaki
Re: ...nize class [message #36224 is a reply to message #36223] Mon, 14 May 2012 14:19 Go to previous messageGo to next message
dolik.rce is currently offline  dolik.rce
Messages: 1789
Registered: August 2008
Location: Czech Republic
Ultimate Contributor

If this is considered, it would be nice to add the same interface for Serialize() as well Wink
Re: ...nize class [message #36234 is a reply to message #36224] Tue, 15 May 2012 15:01 Go to previous messageGo to next message
kohait00 is currently offline  kohait00
Messages: 939
Registered: July 2009
Location: Germany
Experienced Contributor
pretty good idea
Re: ...nize class [message #36241 is a reply to message #36223] Wed, 16 May 2012 11:42 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
Yes, I had that idea too, but unfortunately, it is not 100% same - Xmlize is capable of Attri(butes).

It would be perhaps possible to provide some simplification, using Jsonize for Xmlize, but not vice-versa.

BTW, there are now JsonizeBySerialize and XmlizeBySerialize. So we are perhaps speaking about XmlizeByJsonize, right? Smile
Re: ...nize class [message #36242 is a reply to message #36241] Wed, 16 May 2012 12:01 Go to previous messageGo to next message
koldo is currently offline  koldo
Messages: 3354
Registered: August 2008
Senior Veteran
mirek wrote on Wed, 16 May 2012 11:42

Yes, I had that idea too, but unfortunately, it is not 100% same - Xmlize is capable of Attri(butes).

It would be perhaps possible to provide some simplification, using Jsonize for Xmlize, but not vice-versa.

BTW, there are now JsonizeBySerialize and XmlizeBySerialize. So we are perhaps speaking about XmlizeByJsonize, right? Smile
Hello Mirek

I agree. However it seems ...izeBySerialize functions serve for jsonizing and xmlizing raw data. In our case the resulting XML or Json String would be the same, but using basically only one ...ize method per class and another method per Json, XML or Serialize.


Best regards
Iñaki
Re: ...nize class [message #36244 is a reply to message #36242] Wed, 16 May 2012 12:04 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
koldo wrote on Wed, 16 May 2012 06:01

mirek wrote on Wed, 16 May 2012 11:42

Yes, I had that idea too, but unfortunately, it is not 100% same - Xmlize is capable of Attri(butes).

It would be perhaps possible to provide some simplification, using Jsonize for Xmlize, but not vice-versa.

BTW, there are now JsonizeBySerialize and XmlizeBySerialize. So we are perhaps speaking about XmlizeByJsonize, right? Smile
Hello Mirek

I agree. However it seems ...izeBySerialize functions serve for jsonizing and xmlizing raw data. In our case the resulting XML or Json String would be the same, but using basically only one ...ize method per class and another method per Json, XML or Serialize.



Yep, not totaly same, but quite similar.

Mirek
Re: ...nize class [message #36246 is a reply to message #36244] Wed, 16 May 2012 15:01 Go to previous messageGo to next message
koldo is currently offline  koldo
Messages: 3354
Registered: August 2008
Senior Veteran
Quote:

Yep, not totaly same, but quite similar.
Sorry Mirek Embarassed

I meant that XML and Json with new and old functions would be the same.


Best regards
Iñaki
Re: ...nize class [message #36322 is a reply to message #36246] Sun, 20 May 2012 17:05 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
XmlizeByJsonize added (upptst/JSON contains test of it).
Re: ...nize class [message #36333 is a reply to message #36322] Sun, 20 May 2012 20:35 Go to previous messageGo to next message
koldo is currently offline  koldo
Messages: 3354
Registered: August 2008
Senior Veteran
Thank you Mirek

I understand Smile. Great solution for me. I will apply it immediately to all sources.


Best regards
Iñaki
Re: ...nize class [message #36335 is a reply to message #36333] Sun, 20 May 2012 22:31 Go to previous messageGo to next message
koldo is currently offline  koldo
Messages: 3354
Registered: August 2008
Senior Veteran
Hello Mirek

Is new system fully compatible with older?

I have tried this with an app and an exception was thrown when reading old XML files.

I am not sure now of the exact problem but, for example, before:
<b>
	<type>int</type>
	<value value="0"/>
</b>

and after:
<b type="int" value="0"/>



Best regards
Iñaki
Re: ...nize class [message #36336 is a reply to message #36335] Sun, 20 May 2012 22:42 Go to previous messageGo to next message
koldo is currently offline  koldo
Messages: 3354
Registered: August 2008
Senior Veteran
Hello Mirek

There is also difference in Time and Date. This is the problem that breaks my main program throwing a "string expected" exception:

Before:
<biosReleaseDate value="20080923"/>

After:
<biosReleaseDate>20080923</biosReleaseDate>


Best regards
Iñaki
Re: ...nize class [message #36339 is a reply to message #36335] Mon, 21 May 2012 13:33 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
koldo wrote on Sun, 20 May 2012 16:31

Hello Mirek

Is new system fully compatible with older?



No, it is not. Frankly, I was not even thinking that it should...

I am not even sure I can reach the compatibility, as long as I am using Jsonized Value as intermediate form... (e.g. Date gets converted to String by Jsonize, so I have to send String to XML).
Re: ...nize class [message #36342 is a reply to message #36339] Mon, 21 May 2012 13:46 Go to previous messageGo to next message
koldo is currently offline  koldo
Messages: 3354
Registered: August 2008
Senior Veteran
Hello Mirek

This issue was not really important so you decide.

Here the problem is not that the XML strings generated are not exactly the same. The problem is that when reading them an exception is thrown.

If reading:
<b><type>int</type><value value="0"/></b>

would be like reading:
<b type="int" value="0"/>

And if reading:
<biosReleaseDate value="20080923"/>

would be like reading:
<biosReleaseDate>20080923</biosReleaseDate>

There would not be any problem Smile.


Best regards
Iñaki
Re: ...nize class [message #36344 is a reply to message #36342] Mon, 21 May 2012 14:50 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
Well, but that exactly is hard to achieve IMO. See the code, perhaps you will find a way...
Re: ...nize class [message #36356 is a reply to message #36223] Tue, 22 May 2012 11:11 Go to previous message
koldo is currently offline  koldo
Messages: 3354
Registered: August 2008
Senior Veteran
Oh no.

I will use XmlizeByJsonize() in new classes.


Best regards
Iñaki
Previous Topic: CParser: proposal of new functions
Next Topic: Out of memory panic
Goto Forum:
  


Current Time: Thu Mar 28 13:25:45 CET 2024

Total time taken to generate the page: 0.01204 seconds