From 4a28c1e54ee71b75f592486241b09d815a50be8e Mon Sep 17 00:00:00 2001 From: openharmony_ci <120357966@qq.com> Date: Fri, 26 May 2023 02:31:01 +0000 Subject: [PATCH] =?UTF-8?q?=E5=9B=9E=E9=80=80=20'Pull=20Request=20!28=20:?= =?UTF-8?q?=20=E5=9B=9E=E9=80=80=20'Pull=20Request=20!24=20:=20=E7=BC=96?= =?UTF-8?q?=E8=AF=91=E9=97=AE=E9=A2=98=20fix''?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- framework/common/tlv_object.h | 10 ++++++++-- framework/common/tlv_util.cpp | 26 +++++++++++++++++++------- framework/common/tlv_util.h | 14 ++++++++++---- 3 files changed, 37 insertions(+), 13 deletions(-) diff --git a/framework/common/tlv_object.h b/framework/common/tlv_object.h index fd4b552..8e49abd 100755 --- a/framework/common/tlv_object.h +++ b/framework/common/tlv_object.h @@ -28,7 +28,8 @@ namespace UDMF { enum TAG : uint16_t { TAG_INT32 = 0x0000, TAG_INT64, - TAG_SIZE_T, + TAG_UINT32, + TAG_UINT64, TAG_BOOL, TAG_DOUBLE, TAG_STRING, @@ -66,7 +67,12 @@ public: return *buffer_; } - void Count(const size_t value) + void Count(const uint32_t value) + { + total_ += sizeof(value) + sizeof(TLVHead); + } + + void Count(const uint64_t value) { total_ += sizeof(value) + sizeof(TLVHead); } diff --git a/framework/common/tlv_util.cpp b/framework/common/tlv_util.cpp index 0402808..e7c8818 100644 --- a/framework/common/tlv_util.cpp +++ b/framework/common/tlv_util.cpp @@ -244,12 +244,6 @@ bool Writing(const int32_t &input, TLVObject &data) return data.WriteBasic(TAG_INT32, input); } -template<> -bool Writing(const size_t &input, TLVObject &data) -{ - return data.WriteBasic(TAG_SIZE_T, input); -} - template<> bool Reading(int32_t &output, TLVObject &data) { @@ -269,11 +263,29 @@ bool Reading(int64_t &output, TLVObject &data) } template<> -bool Reading(size_t &output, TLVObject &data) +bool Reading(uint32_t &output, TLVObject &data) { return data.ReadBasic(output); } +template<> +bool Writing(const uint32_t &input, TLVObject &data) +{ + return data.WriteBasic(TAG_UINT32, input); +} + +template<> +bool Reading(uint64_t &output, TLVObject &data) +{ + return data.ReadBasic(output); +} + +template<> +bool Writing(const uint64_t &input, TLVObject &data) +{ + return data.WriteBasic(TAG_UINT64, input); +} + template<> bool Writing(const bool &input, TLVObject &data) { diff --git a/framework/common/tlv_util.h b/framework/common/tlv_util.h index a36e73f..88cfc77 100755 --- a/framework/common/tlv_util.h +++ b/framework/common/tlv_util.h @@ -61,9 +61,6 @@ bool Writing(const int32_t &input, TLVObject &data); template<> bool Reading(int32_t &output, TLVObject &data); -template<> -bool Writing(const size_t &input, TLVObject &data); - template<> bool Writing(const int64_t &input, TLVObject &data); template<> @@ -75,7 +72,16 @@ template<> bool Reading(bool &output, TLVObject &data); template<> -bool Reading(size_t &output, TLVObject &data); +bool Reading(uint32_t &output, TLVObject &data); + +template<> +bool Writing(const uint32_t &input, TLVObject &data); + +template<> +bool Reading(uint64_t &output, TLVObject &data); + +template<> +bool Writing(const uint64_t &input, TLVObject &data); template<> bool Writing(const std::string &input, TLVObject &data); -- Gitee