From 7dcd903140304e7c8e4fb3946a3574e0cacff69e Mon Sep 17 00:00:00 2001 From: karutoh Date: Thu, 21 Dec 2023 18:51:51 -0800 Subject: [PATCH] Changed Util::IsEqual to Util::Compare. --- CMakeLists.txt | 2 +- include/Array.h | 4 ++-- include/Serializer.h | 4 ++-- include/Str.h | 14 +++++++------- include/Util.h | 8 +++++--- include/Vector.h | 4 ++-- src/Type.cpp | 4 ++-- src/Util.cpp | 11 ++++++++++- 8 files changed, 31 insertions(+), 20 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index ee5828a..49a9708 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -230,7 +230,7 @@ add_executable(StrToHash src/StrToHash.cpp) set(CMAKE_INSTALL_PREFIX "${USER_HOME_DIRECTORY}/Libraries/EHS") install(TARGETS EHS DESTINATION lib) -install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/include/ DESTINATION include) +install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/include/ DESTINATION include/ehs) install(TARGETS StrToHash DESTINATION bin) diff --git a/include/Array.h b/include/Array.h index fe52663..f8bdfe3 100644 --- a/include/Array.h +++ b/include/Array.h @@ -159,7 +159,7 @@ namespace ehs if (size != in.size) return false; - return Util::IsEqual(data, in.data, size); + return Util::Compare(data, in.data, size); } bool operator!=(const Array& in) const @@ -167,7 +167,7 @@ namespace ehs if (size != in.size) return true; - return !Util::IsEqual(data, in.data, size); + return !Util::Compare(data, in.data, size); } /// Adds a given array object at the end of the array. diff --git a/include/Serializer.h b/include/Serializer.h index eabc389..7f58f92 100644 --- a/include/Serializer.h +++ b/include/Serializer.h @@ -124,7 +124,7 @@ namespace ehs if (size != in.size) return false; - return Util::IsEqual(data, in.data, size); + return Util::Compare(data, in.data, size); } bool operator!=(const Serializer& in) const @@ -132,7 +132,7 @@ namespace ehs if (size != in.size) return true; - return !Util::IsEqual(data, in.data, size); + return !Util::Compare(data, in.data, size); } Serializer& operator+=(const N size) diff --git a/include/Str.h b/include/Str.h index 3f91b7f..dc05684 100644 --- a/include/Str.h +++ b/include/Str.h @@ -449,7 +449,7 @@ namespace ehs if (size != Len(str)) return false; - return Util::IsEqual(data, str, Size(true)); + return Util::Compare(data, str, Size(true)); } /// Compares with a C-style string. First comparing sizes. @@ -460,7 +460,7 @@ namespace ehs if (size != Len(str)) return false; - return Util::IsEqual(data, str, Size(true)); + return Util::Compare(data, str, Size(true)); } /// Compares with a string object. First comparing sizes. @@ -471,7 +471,7 @@ namespace ehs if (size != str.size) return false; - return Util::IsEqual(data, str, Size(true)); + return Util::Compare(data, str, Size(true)); } /// Compares with a C-style string. First comparing sizes. @@ -482,7 +482,7 @@ namespace ehs if (size != Len(str)) return true; - return !Util::IsEqual(data, str, Size(true)); + return !Util::Compare(data, str, Size(true)); } /// Compares with a string object. First comparing sizes. @@ -493,7 +493,7 @@ namespace ehs if (size != str.size) return true; - return !Util::IsEqual(data, str, Size(true)); + return !Util::Compare(data, str, Size(true)); } /// Retrieves the raw C-style string from casting a string object. @@ -1842,7 +1842,7 @@ bool operator==(const T* const first, const ehs::Str& second) if (second.Size() != inSize) return false; - return ehs::Util::IsEqual(first, second, second.Size(true)); + return ehs::Util::Compare(first, second, second.Size(true)); } template @@ -1852,7 +1852,7 @@ bool operator!=(const T* const first, const ehs::Str& second) if (second.Size() != inSize) return true; - return !ehs::Util::IsEqual(first, second, second.Size(true)); + return !ehs::Util::Compare(first, second, second.Size(true)); } /// Concatenates a C-style string with a string. diff --git a/include/Util.h b/include/Util.h index a87a975..c9b23f9 100644 --- a/include/Util.h +++ b/include/Util.h @@ -7,10 +7,12 @@ namespace ehs class Util { public: - static bool IsEqual(const void* const a, const void* const b, const UInt_64 size); + static bool Compare(const void* a, const void* b, UInt_64 size); - static void Copy(void* const out, const void* const in, const UInt_64 size); + static void Copy(void* out, const void* in, UInt_64 size); - static void Zero(void* const in, const UInt_64 size); + static void Fill(void* out, UInt_64 outSize, const void* in, UInt_64 inSize); + + static void Zero(void* in, UInt_64 size); }; } diff --git a/include/Vector.h b/include/Vector.h index 1c9192e..80b9e83 100644 --- a/include/Vector.h +++ b/include/Vector.h @@ -164,7 +164,7 @@ namespace ehs if (size != in.size) return false; - return Util::IsEqual(data, in.data, size); + return Util::Compare(data, in.data, size); } bool operator!=(const Vector& in) const @@ -172,7 +172,7 @@ namespace ehs if (size != in.size) return true; - return !Util::IsEqual(data, in.data, size); + return !Util::Compare(data, in.data, size); } /// Adds a given initializer list at the end of the vector. diff --git a/src/Type.cpp b/src/Type.cpp index db6c172..118a438 100644 --- a/src/Type.cpp +++ b/src/Type.cpp @@ -37,7 +37,7 @@ namespace ehs if (size != CalcSize(inStr)) return false; - return Util::IsEqual(id, inStr, size); + return Util::Compare(id, inStr, size); } bool Type::operator!=(const Char_8* const inStr) const @@ -45,7 +45,7 @@ namespace ehs if (size != CalcSize(inStr)) return true; - return !Util::IsEqual(id, inStr, size); + return !Util::Compare(id, inStr, size); } UInt_64 Type::GetSize() const diff --git a/src/Util.cpp b/src/Util.cpp index 585598e..c0cbed8 100644 --- a/src/Util.cpp +++ b/src/Util.cpp @@ -2,7 +2,7 @@ namespace ehs { - bool Util::IsEqual(const void* const a, const void* const b, const UInt_64 size) + bool Util::Compare(const void* const a, const void* const b, const UInt_64 size) { Byte* aBytes = (Byte*)a; Byte* bBytes = (Byte*)b; @@ -79,6 +79,15 @@ namespace ehs } } + void Util::Fill(void* const out, const UInt_64 outSize, const void* const in, const UInt_64 inSize) + { + if (outSize % inSize) + return; + + for (UInt_64 i = 0; i < outSize; i += inSize) + Copy(&((Byte*)out)[i], in, inSize); + } + void Util::Zero(void* const in, const UInt_64 size) { Byte* inB = (Byte*)in;