From be9122db80512d3c046fe68b3b9948dd2078dec7 Mon Sep 17 00:00:00 2001 From: hyzboy Date: Wed, 22 Sep 2021 15:23:50 +0800 Subject: [PATCH] add Write functions at Hash class. --- inc/hgl/util/hash/Hash.h | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/inc/hgl/util/hash/Hash.h b/inc/hgl/util/hash/Hash.h index d49ed80..4ae1a7c 100644 --- a/inc/hgl/util/hash/Hash.h +++ b/inc/hgl/util/hash/Hash.h @@ -119,6 +119,18 @@ namespace hgl virtual void Init()=0; ///<初始化散列值计算 virtual void Update(const void *,uint)=0; ///<提交新的数据 virtual void Final(void *)=0; ///<结束并取得结果 + + template + void Write(const T &data) + { + Update(&data,sizeof(T)); + } + + template + void Write(const T *ptr,const uint count) + { + Update(ptr,sizeof(T)*count); + } };//class Hash template Hash *CreateHash(); ///<创建一个hash值计算类实例