From f4d19fc898e9434e93f77843975369744e59350a Mon Sep 17 00:00:00 2001 From: "HuYingzhuo(hugo/hyzboy)" Date: Thu, 20 Apr 2023 21:46:04 +0800 Subject: [PATCH] upgraded codes because Map --- inc/hgl/util/xml/ElementParseKV.h | 10 +++++----- src/xml/ElementParseKV.cpp | 10 +++++----- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/inc/hgl/util/xml/ElementParseKV.h b/inc/hgl/util/xml/ElementParseKV.h index a0aed36..493b06c 100644 --- a/inc/hgl/util/xml/ElementParseKV.h +++ b/inc/hgl/util/xml/ElementParseKV.h @@ -16,7 +16,7 @@ namespace hgl protected: using AttrsMap=Map; - using AttrItem=Pair; + using AttrItem=KeyValue; AttrsMap attrs_map; @@ -24,9 +24,9 @@ namespace hgl const AttrItem *GetAttrItem(const UTF8String &name); - template const bool GetInteger (const UTF8String &name,T &value){const AttrItem *ai=GetAttrItem(name);return(ai?stoi(ai->right.c_str(),value):false);} - template const bool GetUInteger (const UTF8String &name,T &value){const AttrItem *ai=GetAttrItem(name);return(ai?stou(ai->right.c_str(),value):false);} - template const bool GetFloat (const UTF8String &name,T &value){const AttrItem *ai=GetAttrItem(name);return(ai?stof(ai->right.c_str(),value):false);} + template const bool GetInteger (const UTF8String &name,T &value){const AttrItem *ai=GetAttrItem(name);return(ai?stoi(ai->value.c_str(),value):false);} + template const bool GetUInteger (const UTF8String &name,T &value){const AttrItem *ai=GetAttrItem(name);return(ai?stou(ai->value.c_str(),value):false);} + template const bool GetFloat (const UTF8String &name,T &value){const AttrItem *ai=GetAttrItem(name);return(ai?stof(ai->value.c_str(),value):false);} public: @@ -38,7 +38,7 @@ namespace hgl const bool IsExist (const UTF8String &name)const{return attrs_map.KeyExist(name);} - const u8char * ToCString (const UTF8String &name){const AttrItem *ai=GetAttrItem(name);return(ai?ai->right.c_str():nullptr);} + const u8char * ToCString (const UTF8String &name){const AttrItem *ai=GetAttrItem(name);return(ai?ai->value.c_str():nullptr);} const u8char * operator[] (const UTF8String &name){return ToCString(name);} public: diff --git a/src/xml/ElementParseKV.cpp b/src/xml/ElementParseKV.cpp index 641fd0e..a1182ac 100644 --- a/src/xml/ElementParseKV.cpp +++ b/src/xml/ElementParseKV.cpp @@ -25,7 +25,7 @@ namespace hgl if(!ai)return(false); - str=ai->right; + str=ai->value; return(true); } @@ -35,7 +35,7 @@ namespace hgl if(!ai)return(false); - str=to_u16(ai->right); + str=to_u16(ai->value); return(true); } @@ -45,7 +45,7 @@ namespace hgl if(!ai)return(false); - ch=ai->right.GetFirstChar(); + ch=ai->value.GetFirstChar(); return(true); } @@ -53,7 +53,7 @@ namespace hgl { const AttrItem *ai=GetAttrItem(name); - return(ai?stob(ai->right.c_str(),value):false); + return(ai?stob(ai->value.c_str(),value):false); } const bool ElementParseKV::GetHexStr(const UTF8String &name,uint8 *data) @@ -62,7 +62,7 @@ namespace hgl if(!ai)return(false); - ParseHexStr(data,ai->right.c_str(),ai->right.Length()); + ParseHexStr(data,ai->value.c_str(),ai->value.Length()); return(true); } }//namespace xml