diff --git a/uppsrc/Core/InVector.h b/uppsrc/Core/InVector.h index 5b9243144..ce0719a70 100644 --- a/uppsrc/Core/InVector.h +++ b/uppsrc/Core/InVector.h @@ -39,7 +39,7 @@ private: uint16 slave; InVectorSlave__ *Slave() { return (InVectorSlave__ *)((byte *)this + slave); } - void SetSlave(InVectorSlave__ *s) { slave = (byte *)s - (byte *)this; } + void SetSlave(InVectorSlave__ *s) { slave = (uint16)((byte *)s - (byte *)this); } void SetCache(int blki, int offset) const; void ClearCache() const; diff --git a/uppsrc/Core/XML.cpp b/uppsrc/Core/XML.cpp index a1adc4f84..8dcf2a0a6 100644 --- a/uppsrc/Core/XML.cpp +++ b/uppsrc/Core/XML.cpp @@ -739,17 +739,31 @@ int XmlNode::AttrInt(const char *id, int def) const return p.IsInt() ? p.ReadInt() : def; } +XmlNode& XmlNode::SetAttr(const char *id, const String& text) +{ + if(!attr) + attr.Create(); + attr->GetAdd(id) = text; + return *this; +} + +void XmlNode::SetAttrsPick(pick_ VectorMap& a) +{ + if(a.GetCount() == 0) + attr.Clear(); + else { + if(!attr) + attr.Create(); + *attr = a; + } +} + XmlNode& XmlNode::SetAttr(const char *id, int i) { SetAttr(id, AsString(i)); return *this; } -XmlNode& XmlNode::SetAttr(const char *id, const String& text) -{ - attr.GetAdd(id) = text; - return *this; -} bool Ignore(XmlParser& p, dword style) { diff --git a/uppsrc/Core/XML.h b/uppsrc/Core/XML.h index d00b7cfb5..6da8f095c 100644 --- a/uppsrc/Core/XML.h +++ b/uppsrc/Core/XML.h @@ -134,10 +134,10 @@ public: }; class XmlNode { - int type; - String text; - VectorMap attr; - Array node; + int type; + String text; + Array node; + One< VectorMap > attr; public: static const XmlNode& Void(); @@ -176,15 +176,15 @@ public: String GatherText() const; String operator~() const { return GatherText(); } - int GetAttrCount() const { return attr.GetCount(); } - String AttrId(int i) const { return attr.GetKey(i); } - String Attr(int i) const { return attr[i]; } - String Attr(const char *id) const { return attr.Get(id, Null); } + int GetAttrCount() const { return attr ? attr->GetCount() : 0; } + String AttrId(int i) const { return attr->GetKey(i); } + String Attr(int i) const { return (*attr)[i]; } + String Attr(const char *id) const { return attr ? attr->Get(id, Null) : String(); } XmlNode& SetAttr(const char *id, const String& val); int AttrInt(const char *id, int def = Null) const; XmlNode& SetAttr(const char *id, int val); - void SetAttrsPick(pick_ VectorMap& a) { attr = a; } + void SetAttrsPick(pick_ VectorMap& a); XmlNode() { type = XML_DOC; } };