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
[solved] Extensions to Xmlize for arrays [message #32484] Fri, 20 May 2011 11:59 Go to previous message
cbpporter is currently offline  cbpporter
Messages: 1401
Registered: September 2007
Ultimate Contributor
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.

[Updated on: Tue, 31 July 2018 11:44]

Report message to a moderator

 
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: Thu Apr 18 10:44:50 CEST 2024

Total time taken to generate the page: 0.01256 seconds