split Start&Init from Start in XMLParse
This commit is contained in:
parent
120b6b449c
commit
3f09d59ceb
@ -15,8 +15,9 @@ namespace hgl
|
||||
|
||||
virtual ~ElementParse()=default;
|
||||
|
||||
virtual bool Start (const u8char *element_name) {return(true);}
|
||||
virtual bool Init (const u8char *element_name) {return(true);}
|
||||
virtual void Attr (const u8char *flag,const u8char *info) {}
|
||||
virtual bool Start () {return(true);}
|
||||
virtual void CharData (const u8char *str,const int str_length){}
|
||||
virtual void End (const u8char *element_name) {}
|
||||
};//class ElementParse
|
||||
|
@ -34,13 +34,13 @@ namespace hgl
|
||||
|
||||
public:
|
||||
|
||||
virtual bool Start (){return true;}
|
||||
virtual void Attr (const u8char *flag,const u8char *info){}
|
||||
virtual void CharData (const u8char *str,const int str_length){}
|
||||
|
||||
virtual void End (){}
|
||||
virtual bool Init (){return true;} ///<初始化节点
|
||||
virtual void Attr (const u8char *flag,const u8char *info){} ///<节点属性
|
||||
virtual bool Start (){return true;} ///<开始内部数据解晰
|
||||
virtual void CharData (const u8char *str,const int str_length){} ///<文本数据
|
||||
virtual void End (){} ///<节点结束
|
||||
};//class ElementCreater
|
||||
|
||||
|
||||
/**
|
||||
* Creater模式XML节点解析器
|
||||
*/
|
||||
@ -67,10 +67,11 @@ namespace hgl
|
||||
|
||||
public:
|
||||
|
||||
bool Start (const u8char *element_name) override;
|
||||
void Attr (const u8char *flag,const u8char *info) override;
|
||||
void CharData (const u8char *str,const int str_length) override;
|
||||
void End (const u8char *element_name) override;
|
||||
virtual bool Init (const u8char *element_name) override;
|
||||
virtual void Attr (const u8char *flag,const u8char *info) override;
|
||||
virtual bool Start () override;
|
||||
virtual void CharData (const u8char *str,const int str_length) override;
|
||||
virtual void End (const u8char *element_name) override;
|
||||
};//class ElementParseCreater:public ElementParse
|
||||
}//namespace xml
|
||||
}//namespace hgl
|
||||
|
@ -11,7 +11,7 @@ namespace hgl
|
||||
return ecs_map.Add(ec->GetElementName(),ec);
|
||||
}
|
||||
|
||||
bool ElementParseCreater::Start (const u8char *element_name)
|
||||
bool ElementParseCreater::Init(const u8char *element_name)
|
||||
{
|
||||
if(!element_name||!*element_name)return(false);
|
||||
|
||||
@ -39,7 +39,7 @@ namespace hgl
|
||||
|
||||
if(ec)
|
||||
{
|
||||
if(ec->Start())
|
||||
if(ec->Init())
|
||||
cur_ec=ec;
|
||||
else
|
||||
delete ec;
|
||||
@ -55,6 +55,13 @@ namespace hgl
|
||||
cur_ec->Attr(flag,info);
|
||||
}
|
||||
|
||||
bool ElementParseCreater::Start()
|
||||
{
|
||||
if(!cur_ec)return(false);
|
||||
|
||||
return cur_ec->Start();
|
||||
}
|
||||
|
||||
void ElementParseCreater::CharData(const u8char *str,const int str_length)
|
||||
{
|
||||
if(!cur_ec)return;
|
||||
|
@ -13,7 +13,7 @@ namespace hgl
|
||||
{
|
||||
void XMLStartElement(ElementParse *ep,const XML_Char *name,const XML_Char **atts)
|
||||
{
|
||||
if(!ep->Start((const u8char *)name))
|
||||
if(!ep->Init((const u8char *)name))
|
||||
return;
|
||||
|
||||
const u8char *flag;
|
||||
@ -26,6 +26,8 @@ namespace hgl
|
||||
|
||||
ep->Attr(flag,info);
|
||||
}
|
||||
|
||||
ep->Start();
|
||||
}
|
||||
|
||||
void XMLCharData(ElementParse *ep,const XML_Char *str,int len)
|
||||
|
Loading…
x
Reference in New Issue
Block a user