From 21e2b6a9b571a1e492e558888a0ce78782ccc5bd Mon Sep 17 00:00:00 2001 From: hyzboy Date: Tue, 24 Dec 2024 22:41:09 +0800 Subject: [PATCH] Use U8String/U16String/WString instead of UTF8String/UTF16String/WideString --- inc/hgl/util/hash/Hash.h | 2 +- inc/hgl/util/json/JsonTool.h | 4 +-- inc/hgl/util/xml/ElementParseCreater.h | 40 +++++++++++------------ inc/hgl/util/xml/ElementParseKV.h | 44 +++++++++++++------------- inc/hgl/util/xml/XMLParse.h | 4 +-- src/xml/ElementCreater.cpp | 6 ++-- src/xml/ElementParseKV.cpp | 12 +++---- src/xml/XMLParseClass.cpp | 12 +++---- 8 files changed, 62 insertions(+), 62 deletions(-) diff --git a/inc/hgl/util/hash/Hash.h b/inc/hgl/util/hash/Hash.h index e2fd1ca..0732a2a 100644 --- a/inc/hgl/util/hash/Hash.h +++ b/inc/hgl/util/hash/Hash.h @@ -153,7 +153,7 @@ namespace hgl * @param litter 小写字母 * @return 是否计算成功 */ - //bool GetFileHash(const OSString &filename,HASH ha,UTF8String &hash_str,bool litter=true); + //bool GetFileHash(const OSString &filename,HASH ha,U8String &hash_str,bool litter=true); }//namespace util }//namespace hgl #endif//HGL_UTIL_HASH_INCLUDE diff --git a/inc/hgl/util/json/JsonTool.h b/inc/hgl/util/json/JsonTool.h index 364f323..72dfe5b 100644 --- a/inc/hgl/util/json/JsonTool.h +++ b/inc/hgl/util/json/JsonTool.h @@ -4,12 +4,12 @@ namespace hgl { - const UTF8String GetJsoncppVersion(); + const U8String GetJsoncppVersion(); /** * 转换Json数据类型到普通UTF8字符串 */ - bool JsonToString(const Json::Value &jv_root,UTF8String &str,OSString &error_info); + bool JsonToString(const Json::Value &jv_root,U8String &str,OSString &error_info); /** * 解释一个json数据流 diff --git a/inc/hgl/util/xml/ElementParseCreater.h b/inc/hgl/util/xml/ElementParseCreater.h index 0f67dc6..4f2c25c 100644 --- a/inc/hgl/util/xml/ElementParseCreater.h +++ b/inc/hgl/util/xml/ElementParseCreater.h @@ -13,21 +13,21 @@ namespace hgl { friend class ElementParseCreater; - UTF8String element_name; + U8String element_name; protected: - Map ecs_map; + Map ecs_map; - virtual ElementCreater *GetSubElementCreater(const UTF8String &sub_name); + virtual ElementCreater *GetSubElementCreater(const U8String &sub_name); public: - const UTF8String &GetElementName()const{return element_name;} + const U8String &GetElementName()const{return element_name;} public: - ElementCreater(const UTF8String &en){element_name=en;} + ElementCreater(const U8String &en){element_name=en;} virtual ~ElementCreater()=default; bool Registry(ElementCreater *ec); @@ -45,19 +45,19 @@ namespace hgl { protected: - UTF8String null_string; + U8String null_string; - Map attrs_list; + Map attrs_list; public: - ElementAttribute(const UTF8String &en):ElementCreater(en){} + ElementAttribute(const U8String &en):ElementCreater(en){} virtual ~ElementAttribute()=default; - const UTF8String operator[](const UTF8String &flag) + const U8String operator[](const U8String &flag) { - UTF8String key=flag.ToLowerCase(); - UTF8String info; + U8String key=flag.ToLowerCase(); + U8String info; if(attrs_list.Get(key,info)) return info; @@ -66,11 +66,11 @@ namespace hgl } #define TO_CONV(TYPE,FN,SFN,DEFAULT_VALUE) \ - const TYPE FN (const UTF8String &flag,const TYPE default_value=DEFAULT_VALUE) \ + const TYPE FN (const U8String &flag,const TYPE default_value=DEFAULT_VALUE) \ { \ - const UTF8String key=flag.ToLowerCase(); \ + const U8String key=flag.ToLowerCase(); \ \ - UTF8String info; \ + U8String info; \ \ if(!attrs_list.Get(key,info)) \ return default_value; \ @@ -88,11 +88,11 @@ namespace hgl #undef TO_CONV - const UTF8String ToString (const UTF8String &flag){return operator[](flag);} - const int ToSerial (const u8char **list,const UTF8String &flag,const int default_value) + const U8String ToString (const U8String &flag){return operator[](flag);} + const int ToSerial (const u8char **list,const U8String &flag,const int default_value) { - UTF8String key=flag.ToLowerCase(); - UTF8String info; + U8String key=flag.ToLowerCase(); + U8String info; if(!attrs_list.Get(key,info)) return default_value; @@ -118,7 +118,7 @@ namespace hgl virtual void Attr (const u8char *flag,const u8char *info) override///<节点属性 { - UTF8String key=flag; + U8String key=flag; key.LowerCase(); @@ -133,7 +133,7 @@ namespace hgl { Stack ecs_stack; - Map ecs_map; + Map ecs_map; ElementCreater *cur_ec; diff --git a/inc/hgl/util/xml/ElementParseKV.h b/inc/hgl/util/xml/ElementParseKV.h index 8ea3832..de6d3d9 100644 --- a/inc/hgl/util/xml/ElementParseKV.h +++ b/inc/hgl/util/xml/ElementParseKV.h @@ -15,18 +15,18 @@ namespace hgl { protected: - using AttrsMap=Map; - using AttrItem=KeyValue; + using AttrsMap=Map; + using AttrItem=KeyValue; AttrsMap attrs_map; protected: - const AttrItem *GetAttrItem(const UTF8String &name); + const AttrItem *GetAttrItem(const U8String &name); - 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);} + template const bool GetInteger (const U8String &name,T &value){const AttrItem *ai=GetAttrItem(name);return(ai?stoi(ai->value.c_str(),value):false);} + template const bool GetUInteger (const U8String &name,T &value){const AttrItem *ai=GetAttrItem(name);return(ai?stou(ai->value.c_str(),value):false);} + template const bool GetFloat (const U8String &name,T &value){const AttrItem *ai=GetAttrItem(name);return(ai?stof(ai->value.c_str(),value):false);} public: @@ -36,28 +36,28 @@ namespace hgl public: - const bool Contains (const UTF8String &name)const{return attrs_map.ContainsKey(name);} + const bool Contains (const U8String &name)const{return attrs_map.ContainsKey(name);} - 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);} + const u8char * ToCString (const U8String &name){const AttrItem *ai=GetAttrItem(name);return(ai?ai->value.c_str():nullptr);} + const u8char * operator[] (const U8String &name){return ToCString(name);} public: - const bool Get(const UTF8String &name,UTF8String &str); - const bool Get(const UTF8String &name,UTF16String &str); - const bool Get(const UTF8String &name,u8char &ch); - const bool Get(const UTF8String &name,bool &value); + const bool Get(const U8String &name,U8String &str); + const bool Get(const U8String &name,U16String &str); + const bool Get(const U8String &name,u8char &ch); + const bool Get(const U8String &name,bool &value); - const bool Get(const UTF8String &name, int8 &value){return GetInteger < int8 >(name,value);} - const bool Get(const UTF8String &name,uint8 &value){return GetUInteger(name,value);} - const bool Get(const UTF8String &name, int16 &value){return GetInteger < int16>(name,value);} - const bool Get(const UTF8String &name,uint16 &value){return GetUInteger(name,value);} - const bool Get(const UTF8String &name, int32 &value){return GetInteger < int32>(name,value);} - const bool Get(const UTF8String &name,uint32 &value){return GetUInteger(name,value);} - const bool Get(const UTF8String &name, int64 &value){return GetInteger < int64>(name,value);} - const bool Get(const UTF8String &name,uint64 &value){return GetUInteger(name,value);} + const bool Get(const U8String &name, int8 &value){return GetInteger < int8 >(name,value);} + const bool Get(const U8String &name,uint8 &value){return GetUInteger(name,value);} + const bool Get(const U8String &name, int16 &value){return GetInteger < int16>(name,value);} + const bool Get(const U8String &name,uint16 &value){return GetUInteger(name,value);} + const bool Get(const U8String &name, int32 &value){return GetInteger < int32>(name,value);} + const bool Get(const U8String &name,uint32 &value){return GetUInteger(name,value);} + const bool Get(const U8String &name, int64 &value){return GetInteger < int64>(name,value);} + const bool Get(const U8String &name,uint64 &value){return GetUInteger(name,value);} - const bool GetHexStr(const UTF8String &name,uint8 *data); + const bool GetHexStr(const U8String &name,uint8 *data); };//class ElementParseKV:public ElementParse }//namespace xml }//namespace hgl diff --git a/inc/hgl/util/xml/XMLParse.h b/inc/hgl/util/xml/XMLParse.h index 7be3e41..1962f41 100644 --- a/inc/hgl/util/xml/XMLParse.h +++ b/inc/hgl/util/xml/XMLParse.h @@ -25,7 +25,7 @@ namespace hgl namespace xml { - const UTF8String GetExpatVersion(); + const U8String GetExpatVersion(); const char *GetExpatError(int); constexpr int XML_PARSE_BUFFER_SIZE=HGL_SIZE_1KB*128; ///GetElementName().ToLowerCase(); + const U8String &name=ec->GetElementName().ToLowerCase(); if(name.IsEmpty())return(false); if(ecs_map.ContainsKey(name))return(false); @@ -17,13 +17,13 @@ namespace hgl return(true); } - ElementCreater *ElementCreater::GetSubElementCreater(const UTF8String &sub_name) + ElementCreater *ElementCreater::GetSubElementCreater(const U8String &sub_name) { if(sub_name.IsEmpty())return(nullptr); ElementCreater *ec; - const UTF8String &sn=sub_name.ToLowerCase(); + const U8String &sn=sub_name.ToLowerCase(); if(!ecs_map.Get(sn,ec)) return(nullptr); diff --git a/src/xml/ElementParseKV.cpp b/src/xml/ElementParseKV.cpp index 5983e07..42baa36 100644 --- a/src/xml/ElementParseKV.cpp +++ b/src/xml/ElementParseKV.cpp @@ -5,7 +5,7 @@ namespace hgl { namespace xml { - const ElementParseKV::AttrItem *ElementParseKV::GetAttrItem(const UTF8String &name) + const ElementParseKV::AttrItem *ElementParseKV::GetAttrItem(const U8String &name) { const int pos=attrs_map.FindPos(name); @@ -19,7 +19,7 @@ namespace hgl attrs_map.Add(flag,info); } - const bool ElementParseKV::Get(const UTF8String &name,UTF8String &str) + const bool ElementParseKV::Get(const U8String &name,U8String &str) { const AttrItem *ai=GetAttrItem(name); @@ -29,7 +29,7 @@ namespace hgl return(true); } - const bool ElementParseKV::Get(const UTF8String &name,UTF16String &str) + const bool ElementParseKV::Get(const U8String &name,U16String &str) { const AttrItem *ai=GetAttrItem(name); @@ -39,7 +39,7 @@ namespace hgl return(true); } - const bool ElementParseKV::Get(const UTF8String &name,u8char &ch) + const bool ElementParseKV::Get(const U8String &name,u8char &ch) { const AttrItem *ai=GetAttrItem(name); @@ -49,14 +49,14 @@ namespace hgl return(true); } - const bool ElementParseKV::Get(const UTF8String &name,bool &value) + const bool ElementParseKV::Get(const U8String &name,bool &value) { const AttrItem *ai=GetAttrItem(name); return(ai?stob(ai->value.c_str(),value):false); } - const bool ElementParseKV::GetHexStr(const UTF8String &name,uint8 *data) + const bool ElementParseKV::GetHexStr(const U8String &name,uint8 *data) { const AttrItem *ai=GetAttrItem(name); diff --git a/src/xml/XMLParseClass.cpp b/src/xml/XMLParseClass.cpp index 513abe4..08ea610 100644 --- a/src/xml/XMLParseClass.cpp +++ b/src/xml/XMLParseClass.cpp @@ -64,13 +64,13 @@ namespace hgl }; }//namespace - const UTF8String GetExpatVersion() + const U8String GetExpatVersion() { - return( UTF8String::numberOf(XML_MAJOR_VERSION)+ - UTF8String(U8_TEXT("."))+ - UTF8String::numberOf(XML_MINOR_VERSION)+ - UTF8String(U8_TEXT("."))+ - UTF8String::numberOf(XML_MICRO_VERSION)); + return( U8String::numberOf(XML_MAJOR_VERSION)+ + U8String(U8_TEXT("."))+ + U8String::numberOf(XML_MINOR_VERSION)+ + U8String(U8_TEXT("."))+ + U8String::numberOf(XML_MICRO_VERSION)); } const char *GetExpatError(int code)