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 » [solved] Extensions to Xmlize for arrays
Re: Extensions to Xmlize for arrays [message #32501 is a reply to message #32484] Sun, 22 May 2011 19:18 Go to previous messageGo to previous message
mirek is currently offline  mirek
Messages: 14257
Registered: November 2005
Ultimate Member
cbpporter wrote on Fri, 20 May 2011 05:59

I have small problem with Xmlize and containers. The XML will look like this:

<cats>
    <item>...</item>
    <item>...</item>
    ...
</cats>


That is not very XMLish. I want:
<cats>
    <cat>...</cat>
    <cat>...</cat>
    ...
</cats>


Could we add this to XmlIO class:
class XmlIO {
...

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


and after:
template <class T>
void Xmlize(XmlIO xml, const char* itemtag, T& var)
{
	var.Xmlize(xml);
}

...

template <class T> XmlIO XmlIO::operator()(const char *tag, const char *itemtag, T& var) {
	XmlIO n(*this, tag);
	Xmlize(n, itemtag, var);
	return *this;
}

...

template<class T>
void Xmlize(XmlIO xml, const char* itemtag, Vector<T>& data)
{
	XmlizeContainer(xml, itemtag, data);
}

...

template<class T>
void Xmlize(XmlIO xml, const char* itemtag, Array<T>& data)
{
	XmlizeContainer(xml, itemtag, data);
}


This change is only meant for Array and Vector marshaling, but could be extended to rest of the containers.

So now I can do:

xml("cats", cats);


for the original XML format, or:

xml("cats", "cat", cats);

for the format I want.


I have no problem adding this. Could you post a complete patch please?

Mirek
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: ONE and assignement
Next Topic: Folder for configuration file
Goto Forum:
  


Current Time: Sun May 11 04:48:45 CEST 2025

Total time taken to generate the page: 0.01272 seconds