Changed Util::IsEqual to Util::Compare.

This commit is contained in:
Arron David Nelson 2023-12-21 18:51:51 -08:00
parent 49f69372a9
commit 7dcd903140
8 changed files with 31 additions and 20 deletions

View File

@ -230,7 +230,7 @@ add_executable(StrToHash src/StrToHash.cpp)
set(CMAKE_INSTALL_PREFIX "${USER_HOME_DIRECTORY}/Libraries/EHS") set(CMAKE_INSTALL_PREFIX "${USER_HOME_DIRECTORY}/Libraries/EHS")
install(TARGETS EHS DESTINATION lib) 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) install(TARGETS StrToHash DESTINATION bin)

View File

@ -159,7 +159,7 @@ namespace ehs
if (size != in.size) if (size != in.size)
return false; return false;
return Util::IsEqual(data, in.data, size); return Util::Compare(data, in.data, size);
} }
bool operator!=(const Array& in) const bool operator!=(const Array& in) const
@ -167,7 +167,7 @@ namespace ehs
if (size != in.size) if (size != in.size)
return true; 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. /// Adds a given array object at the end of the array.

View File

@ -124,7 +124,7 @@ namespace ehs
if (size != in.size) if (size != in.size)
return false; return false;
return Util::IsEqual(data, in.data, size); return Util::Compare(data, in.data, size);
} }
bool operator!=(const Serializer& in) const bool operator!=(const Serializer& in) const
@ -132,7 +132,7 @@ namespace ehs
if (size != in.size) if (size != in.size)
return true; return true;
return !Util::IsEqual(data, in.data, size); return !Util::Compare(data, in.data, size);
} }
Serializer& operator+=(const N size) Serializer& operator+=(const N size)

View File

@ -449,7 +449,7 @@ namespace ehs
if (size != Len(str)) if (size != Len(str))
return false; 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. /// Compares with a C-style string. First comparing sizes.
@ -460,7 +460,7 @@ namespace ehs
if (size != Len(str)) if (size != Len(str))
return false; return false;
return Util::IsEqual(data, str, Size(true)); return Util::Compare(data, str, Size(true));
} }
/// Compares with a string object. First comparing sizes. /// Compares with a string object. First comparing sizes.
@ -471,7 +471,7 @@ namespace ehs
if (size != str.size) if (size != str.size)
return false; 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. /// Compares with a C-style string. First comparing sizes.
@ -482,7 +482,7 @@ namespace ehs
if (size != Len(str)) if (size != Len(str))
return true; return true;
return !Util::IsEqual(data, str, Size(true)); return !Util::Compare(data, str, Size(true));
} }
/// Compares with a string object. First comparing sizes. /// Compares with a string object. First comparing sizes.
@ -493,7 +493,7 @@ namespace ehs
if (size != str.size) if (size != str.size)
return true; 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. /// Retrieves the raw C-style string from casting a string object.
@ -1842,7 +1842,7 @@ bool operator==(const T* const first, const ehs::Str<T, N>& second)
if (second.Size() != inSize) if (second.Size() != inSize)
return false; return false;
return ehs::Util::IsEqual(first, second, second.Size(true)); return ehs::Util::Compare(first, second, second.Size(true));
} }
template<typename T = ehs::Char_8, typename N = ehs::UInt_64> template<typename T = ehs::Char_8, typename N = ehs::UInt_64>
@ -1852,7 +1852,7 @@ bool operator!=(const T* const first, const ehs::Str<T, N>& second)
if (second.Size() != inSize) if (second.Size() != inSize)
return true; 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. /// Concatenates a C-style string with a string.

View File

@ -7,10 +7,12 @@ namespace ehs
class Util class Util
{ {
public: 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);
}; };
} }

View File

@ -164,7 +164,7 @@ namespace ehs
if (size != in.size) if (size != in.size)
return false; return false;
return Util::IsEqual(data, in.data, size); return Util::Compare(data, in.data, size);
} }
bool operator!=(const Vector& in) const bool operator!=(const Vector& in) const
@ -172,7 +172,7 @@ namespace ehs
if (size != in.size) if (size != in.size)
return true; 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. /// Adds a given initializer list at the end of the vector.

View File

@ -37,7 +37,7 @@ namespace ehs
if (size != CalcSize(inStr)) if (size != CalcSize(inStr))
return false; return false;
return Util::IsEqual(id, inStr, size); return Util::Compare(id, inStr, size);
} }
bool Type::operator!=(const Char_8* const inStr) const bool Type::operator!=(const Char_8* const inStr) const
@ -45,7 +45,7 @@ namespace ehs
if (size != CalcSize(inStr)) if (size != CalcSize(inStr))
return true; return true;
return !Util::IsEqual(id, inStr, size); return !Util::Compare(id, inStr, size);
} }
UInt_64 Type::GetSize() const UInt_64 Type::GetSize() const

View File

@ -2,7 +2,7 @@
namespace ehs 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* aBytes = (Byte*)a;
Byte* bBytes = (Byte*)b; 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) void Util::Zero(void* const in, const UInt_64 size)
{ {
Byte* inB = (Byte*)in; Byte* inB = (Byte*)in;