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