Mercurial > projects > orange
diff orange/serialization/archives/XMLArchive.d @ 28:bffcbc8c392b experimental
Associative arrays are now treated as references.
author | Jacob Carlborg <doob@me.com> |
---|---|
date | Fri, 19 Nov 2010 11:55:04 +0100 |
parents | 78e5fef4bbf2 |
children | c422ff6477dd |
line wrap: on
line diff
--- a/orange/serialization/archives/XMLArchive.d Fri Nov 19 11:14:55 2010 +0100 +++ b/orange/serialization/archives/XMLArchive.d Fri Nov 19 11:55:04 2010 +0100 @@ -18,9 +18,9 @@ import orange.util._; import orange.xml.XMLDocument; -final class XMLArchive (U = char) : Archive!(U) +final class XMLArchive (U = char) : Base!(U) { - private alias IArchive.Id Id; + private alias Archive.Id Id; private struct Tags { @@ -180,7 +180,8 @@ .attribute(Attributes.keyTypeAttribute, toData(keyType)) .attribute(Attributes.valueTypeAttribute, toData(valueType)) .attribute(Attributes.lengthAttribute, toData(length)) - .attribute(Attributes.keyAttribute, key); + .attribute(Attributes.keyAttribute, key) + .attribute(Attributes.idAttribute, toData(id)); dg(); }; @@ -560,23 +561,29 @@ }; } - void unarchiveAssociativeArray (string key, void delegate (size_t length) dg) + Id unarchiveAssociativeArray (string key, void delegate (size_t length) dg) { - restore(lastElement) in { + return restore!(Id)(lastElement) in { auto element = getElement(Tags.associativeArrayTag, key); if (!element.isValid) - return; + return Id.max; - lastElement = element; + lastElement = element; auto len = getValueOfAttribute(Attributes.lengthAttribute); if (!len) - return; + return Id.max; auto length = fromData!(size_t)(len); + auto id = getValueOfAttribute(Attributes.idAttribute); + + if (!id) + return Id.max; dg(length); + + return id.toId(); }; }