From 7489f5133a0eeb39196958454ffeac074a91f452 Mon Sep 17 00:00:00 2001 From: hyzboy Date: Fri, 11 Sep 2020 15:41:20 +0800 Subject: [PATCH] add xml::ElementAttribute class --- inc/hgl/util/xml/ElementParseCreater.h | 31 ++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/inc/hgl/util/xml/ElementParseCreater.h b/inc/hgl/util/xml/ElementParseCreater.h index 1f5829e..65e5d7a 100644 --- a/inc/hgl/util/xml/ElementParseCreater.h +++ b/inc/hgl/util/xml/ElementParseCreater.h @@ -41,6 +41,37 @@ namespace hgl virtual void End (){} ///<节点结束 };//class ElementCreater + class ElementAttribute:public ElementCreater + { + protected: + + UTF8String null_string; + + Map attrs_list; + + public: + + ElementAttribute(const UTF8String &en):ElementCreater(en){} + virtual ~ElementAttribute()=default; + + const UTF8String operator[](const UTF8String &flag) + { + UTF8String info; + + if(attrs_list.Get(flag,info)) + return info; + else + return null_string; + } + + public: + + virtual void Attr (const u8char *flag,const u8char *info) override///<节点属性 + { + attrs_list.Add(flag,info); + } + };//class ElementAttribute:public ElementCreater + /** * Creater模式XML节点解析器 */