diff --git a/inc/hgl/type/IDName.h b/inc/hgl/type/IDName.h index 5aec4ea..4caa3ad 100644 --- a/inc/hgl/type/IDName.h +++ b/inc/hgl/type/IDName.h @@ -6,7 +6,7 @@ namespace hgl { template - bool RegistryIDName(const char *IDNameTag,ConstStringView &csv,const SC *name_string,const int name_length); + bool RegistryIDName(const size_t hash_code,ConstStringView &csv,const SC *name_string,const int name_length); /** * 顺序ID+名称数据结构模板
@@ -39,7 +39,7 @@ namespace hgl return; } - RegistryIDName(IDNAME_TAG,csv,name_string,name_length); + RegistryIDName(typeid(SelfClass).hash_code(),csv,name_string,name_length); } public: diff --git a/src/Type/IDName.cpp b/src/Type/IDName.cpp index 974f8af..234efce 100644 --- a/src/Type/IDName.cpp +++ b/src/Type/IDName.cpp @@ -3,24 +3,22 @@ namespace hgl { template - bool RegistryIDName(const char *tag,ConstStringView &csv,const SC *name_string,const int name_length) + bool RegistryIDName(const size_t hash_code,ConstStringView &csv,const SC *name_string,const int name_length) { - static ObjectMap> css_map; + static ObjectMap> css_map; ConstStringSet *css; - const AnsiString IDNameTag=tag; - - if(!css_map.Get(IDNameTag,css)) + if(!css_map.Get(hash_code,css)) { css=new ConstStringSet; - css_map.Add(IDNameTag,css); + css_map.Add(hash_code,css); } return(css->AddString(csv,name_string,name_length)>=0); } -#define REGISTRY_ID_NAME(type) bool RegistryIDName_##type(const char *tag,ConstStringView &csv,const type *name,const int length){return RegistryIDName(tag,csv,name,length);} +#define REGISTRY_ID_NAME(type) bool RegistryIDName_##type(const size_t hash_code,ConstStringView &csv,const type *name,const int length){return RegistryIDName(hash_code,csv,name,length);} REGISTRY_ID_NAME(char) REGISTRY_ID_NAME(wchar_t)