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  |
cbpporter
Messages: 1427 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:
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
|
|
|
Re: Extensions to Xmlize for arrays [message #32489 is a reply to message #32484] |
Fri, 20 May 2011 17:20   |
|
cbpporter wrote on Fri, 20 May 2011 12:59 |
This change is only meant for Array and Vector marshaling, but could be extended to rest of the containers.
So now I can do:
for the original XML format, or:
xml("cats", "cat", cats);
for the format I want.
|
What about if your Array cats have items with array type?
|
|
|
Re: Extensions to Xmlize for arrays [message #32501 is a reply to message #32484] |
Sun, 22 May 2011 19:18   |
 |
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:
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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Goto Forum:
Current Time: Fri May 09 20:01:51 CEST 2025
Total time taken to generate the page: 0.03129 seconds
|