Home » U++ Library support » U++ Core » ValueArray behaviour / inconsistantcy / BUG?
Re: ValueArray behaviour / inconsistantcy / BUG? [message #29478 is a reply to message #29474] |
Fri, 22 October 2010 13:52   |
 |
kohait00
Messages: 939 Registered: July 2009 Location: Germany
|
Experienced Contributor |
|
|
ValueMap is sure more complicated. i tried it..realizing btw. that Index and ArrayIndex are not Xmlize'able yet. because they dont export API to access the hash separetely, so one can't cleanly xmlize it, only under assumption that hashes have been created from the objects them selves; nevertheless, code explains more.
and another bug (dunno, could be): XmlizeMap does not Clear() the container at the beginning, like XmlizeContainer does.
NAMESPACE_UPP
//old version without preparaton for hashfn awareness
#if 0
template<class T>
void Xmlize(XmlIO xml, Index<T>& data)
{
if(xml.IsStoring())
{
XmlizeStore(xml, data.GetKeys()); //FIXME xmlize with hashfn awareness
}
if(xml.IsLoading())
{
data.Clear();
Vector<T> keys;
::Xmlize(xml, keys); //FIXME dexmlize with hashfn awareness
data = Index<T>(keys);
}
}
#endif
template<class K, class T>
void XmlizeIndex(XmlIO xml, const char *keytag, const char *valuetag, T& data)
{
if(xml.IsStoring()) {
for(int i = 0; i < data.GetCount(); i++)
if(!data.IsUnlinked(i)) {
//XmlizeStore(xml.Add(keytag), data.GetKey(i)); //FIXME xmlize with hashfn awareness
XmlizeStore(xml.Add(valuetag), data[i]);
}
}
else {
data.Clear();
int i = 0;
//while(i < xml->GetCount() - 1 && xml->Node(i).IsTag(keytag) && xml->Node(i + 1).IsTag(valuetag)) {
while(i < xml->GetCount() && xml->Node(i).IsTag(valuetag)) {
//K key;
//Xmlize(xml.At(i++), key); //FIXME dexmlize with hashfn awareness
K k;
::Xmlize(xml.At(i++), data.Add(k));
}
}
}
template<class K, class H>
void Xmlize(XmlIO xml, Index<K, H>& data)
{
XmlizeIndex<K>(xml, "key", "value", data);
}
template<class K, class H>
void Xmlize(XmlIO xml, ArrayIndex<K, H>& data)
{
XmlizeIndex<K>(xml, "key", "value", data);
}
template<> void Xmlize(XmlIO xml, ValueArray& v)
{
if(xml.IsStoring())
{
XmlizeStore(xml, v.Get());
}
if(xml.IsLoading())
{
Vector<Value> vv;
::Xmlize(xml, vv);
v = ValueArray(vv);
}
}
template<> void Xmlize(XmlIO xml, ValueMap& v)
{
if(xml.IsStoring())
{
XmlizeStore(xml, v.GetKeys());
XmlizeStore(xml, v.GetValues());
}
if(xml.IsLoading())
{
Index<Value> vv;
::Xmlize(xml, vv);
ValueArray va;
::Xmlize(xml, va);
ASSERT(vv.GetCount() == va.GetCount());
ValueMap vm;
for(int i = 0; i < vv.GetCount(); i++)
vm.Add(vv[i], va[i]);
}
}
END_UPP_NAMESPACE
|
|
|
 |
|
ValueArray behaviour / inconsistantcy / BUG?
By: kohait00 on Wed, 20 October 2010 09:33
|
 |
|
Re: ValueArray behaviour / inconsistantcy / BUG?
By: kohait00 on Wed, 20 October 2010 10:45
|
 |
|
Re: ValueArray behaviour / inconsistantcy / BUG?
By: kohait00 on Wed, 20 October 2010 16:00
|
 |
|
Re: ValueArray behaviour / inconsistantcy / BUG?
By: mirek on Thu, 21 October 2010 22:40
|
 |
|
Re: ValueArray behaviour / inconsistantcy / BUG?
By: mirek on Thu, 21 October 2010 23:08
|
 |
|
Re: ValueArray behaviour / inconsistantcy / BUG?
By: mirek on Thu, 21 October 2010 23:12
|
 |
|
Re: ValueArray behaviour / inconsistantcy / BUG?
By: kohait00 on Thu, 21 October 2010 23:32
|
 |
|
Re: ValueArray behaviour / inconsistantcy / BUG?
By: mirek on Fri, 22 October 2010 00:09
|
 |
|
Re: ValueArray behaviour / inconsistantcy / BUG?
By: kohait00 on Fri, 22 October 2010 07:30
|
 |
|
Re: ValueArray behaviour / inconsistantcy / BUG?
By: mirek on Fri, 22 October 2010 09:53
|
 |
|
Re: ValueArray behaviour / inconsistantcy / BUG?
By: kohait00 on Fri, 22 October 2010 10:12
|
 |
|
Re: ValueArray behaviour / inconsistantcy / BUG?
By: kohait00 on Fri, 22 October 2010 10:17
|
 |
|
Re: ValueArray behaviour / inconsistantcy / BUG?
By: mirek on Fri, 22 October 2010 11:01
|
 |
|
Re: ValueArray behaviour / inconsistantcy / BUG?
By: kohait00 on Fri, 22 October 2010 13:52
|
 |
|
Re: ValueArray behaviour / inconsistantcy / BUG?
By: kohait00 on Mon, 25 October 2010 13:59
|
 |
|
Re: ValueArray behaviour / inconsistantcy / BUG?
By: mirek on Wed, 27 October 2010 19:32
|
 |
|
Re: ValueArray behaviour / inconsistantcy / BUG?
By: kohait00 on Thu, 28 October 2010 07:45
|
 |
|
Re: ValueArray behaviour / inconsistantcy / BUG?
By: mirek on Thu, 28 October 2010 10:10
|
 |
|
Re: ValueArray behaviour / inconsistantcy / BUG?
By: kohait00 on Thu, 28 October 2010 18:20
|
 |
|
Re: ValueArray behaviour / inconsistantcy / BUG?
By: mirek on Fri, 29 October 2010 08:37
|
 |
|
Re: ValueArray behaviour / inconsistantcy / BUG?
By: kohait00 on Fri, 29 October 2010 12:13
|
Goto Forum:
Current Time: Tue Jun 17 19:07:49 CEST 2025
Total time taken to generate the page: 0.05286 seconds
|