use u8char instead char in XMLParse

This commit is contained in:
2020-08-25 21:47:05 +08:00
parent e79ac1ca03
commit 44f897d608
7 changed files with 61 additions and 56 deletions

View File

@@ -4,16 +4,20 @@ namespace hgl
{
namespace xml
{
bool ElementCreater::Registry(const AnsiString &name,ElementCreater *ec)
bool ElementCreater::Registry(ElementCreater *ec)
{
if(name.Length()<=0||!ec)return(false);
if(!ec)return(false);
const UTF8String &name=ec->GetElementName();
if(name.IsEmpty())return(false);
if(ecs_map.KeyExist(name))return(false);
ecs_map.Add(name,ec);
return(true);
}
ElementCreater *ElementCreater::GetSubElementCreater(const AnsiString &sub_name)
ElementCreater *ElementCreater::GetSubElementCreater(const UTF8String &sub_name)
{
if(sub_name.IsEmpty())return(nullptr);

View File

@@ -4,7 +4,7 @@ namespace hgl
{
namespace xml
{
bool ElementParseCreater::Start (const char *element_name)
bool ElementParseCreater::Start (const u8char *element_name)
{
if(!element_name||!*element_name)return(false);
@@ -27,21 +27,21 @@ namespace hgl
return(cur_ec);
}
void ElementParseCreater::Attr(const char *flag,const char *info)
void ElementParseCreater::Attr(const u8char *flag,const u8char *info)
{
if(!cur_ec)return;
cur_ec->Attr(flag,info);
}
void ElementParseCreater::CharData(const char *str,const int str_length)
void ElementParseCreater::CharData(const u8char *str,const int str_length)
{
if(!cur_ec)return;
cur_ec->CharData(str,str_length);
}
void ElementParseCreater::End(const char *element_name)
void ElementParseCreater::End(const u8char *element_name)
{
if(cur_ec)
{

View File

@@ -5,7 +5,7 @@ namespace hgl
{
namespace xml
{
const ElementParseKV::AttrItem *ElementParseKV::GetAttrItem(const AnsiString &name)
const ElementParseKV::AttrItem *ElementParseKV::GetAttrItem(const UTF8String &name)
{
const int pos=attrs_map.FindPos(name);
@@ -19,7 +19,7 @@ namespace hgl
attrs_map.Add(flag,info);
}
const bool ElementParseKV::Get(const AnsiString &name,AnsiString &str)
const bool ElementParseKV::Get(const UTF8String &name,UTF8String &str)
{
const AttrItem *ai=GetAttrItem(name);
@@ -29,7 +29,7 @@ namespace hgl
return(true);
}
const bool ElementParseKV::Get(const AnsiString &name,UTF16String &str)
const bool ElementParseKV::Get(const UTF8String &name,UTF16String &str)
{
const AttrItem *ai=GetAttrItem(name);
@@ -39,7 +39,7 @@ namespace hgl
return(true);
}
const bool ElementParseKV::Get(const AnsiString &name,char &ch)
const bool ElementParseKV::Get(const UTF8String &name,char &ch)
{
const AttrItem *ai=GetAttrItem(name);
@@ -49,14 +49,14 @@ namespace hgl
return(true);
}
const bool ElementParseKV::Get(const AnsiString &name,bool &value)
const bool ElementParseKV::Get(const UTF8String &name,bool &value)
{
const AttrItem *ai=GetAttrItem(name);
return(ai?stob<char>(ai->right.c_str(),value):false);
}
const bool ElementParseKV::GetHexStr(const AnsiString &name,uint8 *data)
const bool ElementParseKV::GetHexStr(const UTF8String &name,uint8 *data)
{
const AttrItem *ai=GetAttrItem(name);

View File

@@ -13,11 +13,11 @@ namespace hgl
{
void XMLStartElement(ElementParse *ep,const XML_Char *name,const XML_Char **atts)
{
if(!ep->Start(name))
if(!ep->Start((const u8char *)name))
return;
const char *flag;
const char *info;
const u8char *flag;
const u8char *info;
while(*atts)
{
@@ -30,12 +30,12 @@ namespace hgl
void XMLCharData(ElementParse *ep,const XML_Char *str,int len)
{
ep->CharData(str,len);
ep->CharData((const u8char *)str,len);
}
void XMLEndElement(ElementParse *ep,const XML_Char *name)
{
ep->End(name);
ep->End((const u8char *)name);
}
}//namespace