Added and adjusted docs for Str class.

This commit is contained in:
Arron David Nelson 2024-02-01 17:04:57 -08:00
parent 449f1c1496
commit 6fa7729253
2 changed files with 141 additions and 75 deletions

View File

@ -221,7 +221,7 @@ add_executable(StrToHash src/StrToHash.cpp)
target_include_directories(EHS PUBLIC ${PROJECT_SOURCE_DIR}/include) target_include_directories(EHS PUBLIC ${PROJECT_SOURCE_DIR}/include)
set(CMAKE_INSTALL_PREFIX "${USER_HOME_DIRECTORY}/Libraries/EHS") set(CMAKE_INSTALL_PREFIX "/usr/local")
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)

View File

@ -33,7 +33,7 @@ namespace ehs
public: public:
/// Frees any data created on the heap. /// Frees any data created on the heap.
~Str() ~Str() override
{ {
delete[] data; delete[] data;
} }
@ -84,6 +84,7 @@ namespace ehs
AddType("Str"); AddType("Str");
} }
/// A move constructor.
Str(Str&& str) noexcept Str(Str&& str) noexcept
: BaseObj((BaseObj&&)str), size(str.size), data(str.data) : BaseObj((BaseObj&&)str), size(str.size), data(str.data)
{ {
@ -158,7 +159,7 @@ namespace ehs
/// Concatenates with the given C-style string. /// Concatenates with the given C-style string.
/// @param [in] str The given C-style string. /// @param [in] str The given C-style string.
/// @returns The result. /// @returns The resulting string object.
Str<T, N>& operator+=(const T* const str) Str<T, N>& operator+=(const T* const str)
{ {
N inputSize = Len(str); N inputSize = Len(str);
@ -180,7 +181,7 @@ namespace ehs
/// Concatenates with the given string object. /// Concatenates with the given string object.
/// @param [in] str The given string object. /// @param [in] str The given string object.
/// @returns The result. /// @returns The resulting string object.
Str<T, N>& operator+=(const Str<T, N>& str) Str<T, N>& operator+=(const Str<T, N>& str)
{ {
T* result = new T[size + str.size + 1]; T* result = new T[size + str.size + 1];
@ -200,7 +201,7 @@ namespace ehs
/// Concatenates with the given number. /// Concatenates with the given number.
/// @param [in] num The given number to concatenate. /// @param [in] num The given number to concatenate.
/// @returns The result. /// @returns The resulting string object.
Str<T, N>& operator+=(const SInt_64 num) Str<T, N>& operator+=(const SInt_64 num)
{ {
return operator+=(FromNum(num)); return operator+=(FromNum(num));
@ -208,7 +209,7 @@ namespace ehs
/// Concatenates with the given number. /// Concatenates with the given number.
/// @param [in] num The given number to concatenate. /// @param [in] num The given number to concatenate.
/// @returns The result. /// @returns The resulting string object.
Str<T, N>& operator+=(const UInt_64 num) Str<T, N>& operator+=(const UInt_64 num)
{ {
return operator+=(FromNum(num)); return operator+=(FromNum(num));
@ -216,7 +217,7 @@ namespace ehs
/// Concatenates with the given number. /// Concatenates with the given number.
/// @param [in] num The given number to concatenate. /// @param [in] num The given number to concatenate.
/// @returns The result. /// @returns The resulting string object.
Str<T, N>& operator+=(const SInt_32 num) Str<T, N>& operator+=(const SInt_32 num)
{ {
return operator+=(FromNum(num)); return operator+=(FromNum(num));
@ -224,7 +225,7 @@ namespace ehs
/// Concatenates with the given number. /// Concatenates with the given number.
/// @param [in] num The given number to concatenate. /// @param [in] num The given number to concatenate.
/// @returns The result. /// @returns The resulting string object.
Str<T, N>& operator+=(const UInt_32 num) Str<T, N>& operator+=(const UInt_32 num)
{ {
return operator+=(FromNum(num)); return operator+=(FromNum(num));
@ -232,7 +233,7 @@ namespace ehs
/// Concatenates with the given number. /// Concatenates with the given number.
/// @param [in] num The given number to concatenate. /// @param [in] num The given number to concatenate.
/// @returns The result. /// @returns The resulting string object.
Str<T, N>& operator+=(const SInt_16 num) Str<T, N>& operator+=(const SInt_16 num)
{ {
return operator+=(FromNum(num)); return operator+=(FromNum(num));
@ -240,7 +241,7 @@ namespace ehs
/// Concatenates with the given number. /// Concatenates with the given number.
/// @param [in] num The given number to concatenate. /// @param [in] num The given number to concatenate.
/// @returns The result. /// @returns The resulting string object.
Str<T, N>& operator+=(const UInt_16 num) Str<T, N>& operator+=(const UInt_16 num)
{ {
return operator+=(FromNum(num)); return operator+=(FromNum(num));
@ -248,7 +249,7 @@ namespace ehs
/// Concatenates with the given number. /// Concatenates with the given number.
/// @param [in] num The given number to concatenate. /// @param [in] num The given number to concatenate.
/// @returns The result. /// @returns The resulting string object.
Str<T, N>& operator+=(const SInt_8 num) Str<T, N>& operator+=(const SInt_8 num)
{ {
return operator+=(FromNum(num)); return operator+=(FromNum(num));
@ -256,7 +257,7 @@ namespace ehs
/// Concatenates with the given number. /// Concatenates with the given number.
/// @param [in] num The given number to concatenate. /// @param [in] num The given number to concatenate.
/// @returns The result. /// @returns The resulting string object.
Str<T, N>& operator+=(const UInt_8 num) Str<T, N>& operator+=(const UInt_8 num)
{ {
return operator+=(FromNum(num)); return operator+=(FromNum(num));
@ -282,7 +283,7 @@ namespace ehs
/// Concatenates with the given number. /// Concatenates with the given number.
/// @param [in] num The given number to concatenate. /// @param [in] num The given number to concatenate.
/// @returns The result. /// @returns The resulting string object.
Str<T, N>& operator+=(const float num) Str<T, N>& operator+=(const float num)
{ {
return operator+=(FromNum(num)); return operator+=(FromNum(num));
@ -290,7 +291,7 @@ namespace ehs
/// Concatenates with the given number. /// Concatenates with the given number.
/// @param [in] num The given number to concatenate. /// @param [in] num The given number to concatenate.
/// @returns The result. /// @returns The resulting string object.
Str<T, N>& operator+=(const double num) Str<T, N>& operator+=(const double num)
{ {
return operator+=(FromNum(num)); return operator+=(FromNum(num));
@ -298,7 +299,7 @@ namespace ehs
/// Concatenates with the given number. /// Concatenates with the given number.
/// @param [in] num The given number to concatenate. /// @param [in] num The given number to concatenate.
/// @returns The result. /// @returns The resulting string object.
Str<T, N>& operator+=(const long double num) Str<T, N>& operator+=(const long double num)
{ {
return operator+=(FromNum(num)); return operator+=(FromNum(num));
@ -306,7 +307,7 @@ namespace ehs
/// Concatenates with the given C-style string. /// Concatenates with the given C-style string.
/// @param [in] str The given C-style string. /// @param [in] str The given C-style string.
/// @returns The result. /// @returns The resulting string object.
Str<T, N> operator+(const T* const str) const Str<T, N> operator+(const T* const str) const
{ {
N inSize = Len(str); N inSize = Len(str);
@ -324,7 +325,7 @@ namespace ehs
/// Concatenates with the given string object. /// Concatenates with the given string object.
/// @param [in] str The given string object. /// @param [in] str The given string object.
/// @returns The result. /// @returns The resulting string object.
Str<T, N> operator+(const Str<T, N>& str) const Str<T, N> operator+(const Str<T, N>& str) const
{ {
Str<T, N> result(size + str.size); Str<T, N> result(size + str.size);
@ -339,64 +340,64 @@ namespace ehs
} }
/// Concatenates with the given number. /// Concatenates with the given number.
/// @param [in] str The given number to Concatenate. /// @param [in] num The given number to Concatenate.
/// @returns The result. /// @returns The resulting string object.
Str<T, N> operator+(const SInt_64 num) const Str<T, N> operator+(const SInt_64 num) const
{ {
return operator+(FromNum(num)); return operator+(FromNum(num));
} }
/// Concatenates with the given number. /// Concatenates with the given number.
/// @param [in] str The given number to Concatenate. /// @param [in] num The given number to Concatenate.
/// @returns The result. /// @returns The resulting string object.
Str<T, N> operator+(const UInt_64 num) const Str<T, N> operator+(const UInt_64 num) const
{ {
return operator+(FromNum(num)); return operator+(FromNum(num));
} }
/// Concatenates with the given number. /// Concatenates with the given number.
/// @param [in] str The given number to Concatenate. /// @param [in] num The given number to Concatenate.
/// @returns The result. /// @returns The resulting string object.
Str<T, N> operator+(const SInt_32 num) const Str<T, N> operator+(const SInt_32 num) const
{ {
return operator+(FromNum(num)); return operator+(FromNum(num));
} }
/// Concatenates with the given number. /// Concatenates with the given number.
/// @param [in] str The given number to Concatenate. /// @param [in] num The given number to Concatenate.
/// @returns The result. /// @returns The resulting string object.
Str<T, N> operator+(const UInt_32 num) const Str<T, N> operator+(const UInt_32 num) const
{ {
return operator+(FromNum(num)); return operator+(FromNum(num));
} }
/// Concatenates with the given number. /// Concatenates with the given number.
/// @param [in] str The given number to Concatenate. /// @param [in] num The given number to Concatenate.
/// @returns The result. /// @returns The resulting string object.
Str<T, N> operator+(const SInt_16 num) const Str<T, N> operator+(const SInt_16 num) const
{ {
return operator+(FromNum(num)); return operator+(FromNum(num));
} }
/// Concatenates with the given number. /// Concatenates with the given number.
/// @param [in] str The given number to Concatenate. /// @param [in] num The given number to Concatenate.
/// @returns The result. /// @returns The resulting string object.
Str<T, N> operator+(const UInt_16 num) const Str<T, N> operator+(const UInt_16 num) const
{ {
return operator+(FromNum(num)); return operator+(FromNum(num));
} }
/// Concatenates with the given number. /// Concatenates with the given number.
/// @param [in] str The given number to Concatenate. /// @param [in] num The given number to Concatenate.
/// @returns The result. /// @returns The resulting string object.
Str<T, N> operator+(const SInt_8 num) const Str<T, N> operator+(const SInt_8 num) const
{ {
return operator+(FromNum(num)); return operator+(FromNum(num));
} }
/// Concatenates with the given number. /// Concatenates with the given number.
/// @param [in] str The given number to Concatenate. /// @param [in] num The given number to Concatenate.
/// @returns The result. /// @returns The resulting string object.
Str<T, N> operator+(const UInt_8 num) const Str<T, N> operator+(const UInt_8 num) const
{ {
return operator+(FromNum(num)); return operator+(FromNum(num));
@ -421,29 +422,32 @@ namespace ehs
#endif #endif
/// Concatenates with the given number. /// Concatenates with the given number.
/// @param [in] str The given number to Concatenate. /// @param [in] num The given number to Concatenate.
/// @returns The result. /// @returns The resulting string object.
Str<T, N> operator+(const float num) const Str<T, N> operator+(const float num) const
{ {
return operator+(FromNum(num)); return operator+(FromNum(num));
} }
/// Concatenates with the given number. /// Concatenates with the given number.
/// @param [in] str The given number to Concatenate. /// @param [in] num The given number to Concatenate.
/// @returns The result. /// @returns The resulting string object.
Str<T, N> operator+(const double num) const Str<T, N> operator+(const double num) const
{ {
return operator+(FromNum(num)); return operator+(FromNum(num));
} }
/// Concatenates with the given number. /// Concatenates with the given number.
/// @param [in] str The given number to Concatenate. /// @param [in] num The given number to Concatenate.
/// @returns The result. /// @returns The resulting string object.
Str<T, N> operator+(const long double num) const Str<T, N> operator+(const long double num) const
{ {
return operator+(FromNum(num)); return operator+(FromNum(num));
} }
/// Compares with a another string. First comparing sizes.
/// @param [in] str The string object to compare with.
/// @returns Whether or not they are equal.
bool operator==(T* str) const bool operator==(T* str) const
{ {
if (size != Len(str)) if (size != Len(str))
@ -535,7 +539,7 @@ namespace ehs
return size; return size;
} }
/// Finds a null terminator in the string and makes it the exact size if greater than. /// Finds the null terminator in the string and makes it the exact size if greater than.
void ExactSize() void ExactSize()
{ {
size = Len(data); size = Len(data);
@ -594,6 +598,9 @@ namespace ehs
Util::Copy(data[dstOffset], src, srcSize * sizeof(T)); Util::Copy(data[dstOffset], src, srcSize * sizeof(T));
} }
/// Inserts a string at a specified index.
/// @param [in] index The index to insert the string at.
/// @param [in] value The string to insert.
void Insert(const N index, const Str& value) void Insert(const N index, const Str& value)
{ {
if (!value.size) if (!value.size)
@ -616,6 +623,9 @@ namespace ehs
size = newSize; size = newSize;
} }
/// Inserts a character at a specified index.
/// @param [in] index The index to insert the character at.
/// @param [in] value The character to insert.
void Insert(const N index, const T value) void Insert(const N index, const T value)
{ {
N newSize = 0; N newSize = 0;
@ -641,6 +651,10 @@ namespace ehs
size = newSize; size = newSize;
} }
/// Removes characters withing the given range.
/// @param [in] start The index to start.
/// @param [in] end The index to end.
/// @returns The removed string object.
Str Remove(const N start, const N end) Str Remove(const N start, const N end)
{ {
if (!size || start >= size || end > size || end <= start) if (!size || start >= size || end > size || end <= start)
@ -664,6 +678,9 @@ namespace ehs
return popped; return popped;
} }
/// Removes a character at the given index.
/// @param [in] index The index to remove a character.
/// @returns The character removed.
T Remove(const N index) T Remove(const N index)
{ {
T popped = {}; T popped = {};
@ -691,7 +708,6 @@ namespace ehs
/// Adds a value at the end of the string. /// Adds a value at the end of the string.
/// @param [in] value The character to push to the end of the string. /// @param [in] value The character to push to the end of the string.
/// @note Automatically moves the null terminator after the value is pushed.
void Push(const Str<T, N> &value) void Push(const Str<T, N> &value)
{ {
T* result = new T[size + value.size + 1]; T* result = new T[size + value.size + 1];
@ -709,7 +725,6 @@ namespace ehs
/// Adds a value at the end of the string. /// Adds a value at the end of the string.
/// @param [in] value The C-style string to push to the end of the string. /// @param [in] value The C-style string to push to the end of the string.
/// @param [in] size The size of the given C-style string. /// @param [in] size The size of the given C-style string.
/// @note Automatically moves the null terminator after the value is pushed.
void Push(const T* const value, const N size) void Push(const T* const value, const N size)
{ {
T* result = new T[this->size + size + 1]; T* result = new T[this->size + size + 1];
@ -726,7 +741,6 @@ namespace ehs
/// Adds a value at the end of the string. /// Adds a value at the end of the string.
/// @param [in] value The C-style string to push to the end of the string. /// @param [in] value The C-style string to push to the end of the string.
/// @note Automatically moves the null terminator after the value is pushed.
void Push(const T* const value) void Push(const T* const value)
{ {
N inSize = Len(value); N inSize = Len(value);
@ -745,7 +759,6 @@ namespace ehs
/// Adds a value at the end of the string. /// Adds a value at the end of the string.
/// @param [in] value The character to push to the end of the string. /// @param [in] value The character to push to the end of the string.
/// @note Automatically moves the null terminator after the value is pushed.
void Push(const T value) void Push(const T value)
{ {
T* result = new T[size + 2]; T* result = new T[size + 2];
@ -761,7 +774,7 @@ namespace ehs
++size; ++size;
} }
/// Removes a value at the end of the array. /// Removes the value at the end of the array.
/// @returns The value that was popped. /// @returns The value that was popped.
T Pop() T Pop()
{ {
@ -794,7 +807,7 @@ namespace ehs
return (Byte*)data; return (Byte*)data;
} }
/// Changes all upper-case ASCII characters to lower-case. /// Converts all upper-case ASCII characters to lower-case.
void ToLower() void ToLower()
{ {
for (N i = 0; i < size; ++i) for (N i = 0; i < size; ++i)
@ -802,8 +815,8 @@ namespace ehs
data[i] += 32; data[i] += 32;
} }
/// Changes all upper-case ASCII characters to lower-case. /// Converts all upper-case ASCII characters to lower-case.
/// @returns The result. /// @returns The resulting string object.
Str<T, N> GetLower() const Str<T, N> GetLower() const
{ {
Str<T, N> result(size); Str<T, N> result(size);
@ -817,7 +830,7 @@ namespace ehs
return result; return result;
} }
/// Changes all lower-case ASCII characters to upper-case. /// Converts all lower-case ASCII characters to upper-case.
void ToUpper() void ToUpper()
{ {
for (N i = 0; i < size; ++i) for (N i = 0; i < size; ++i)
@ -825,8 +838,8 @@ namespace ehs
data[i] -= 32; data[i] -= 32;
} }
/// Changes all lower-case ASCII characters to upper-case. /// Converts all lower-case ASCII characters to upper-case.
/// @returns The result. /// @returns The resulting string object.
Str<T, N> GetUpper() const Str<T, N> GetUpper() const
{ {
Str<T, N> result(size); Str<T, N> result(size);
@ -840,7 +853,7 @@ namespace ehs
return result; return result;
} }
/// Reverses the entire referenced string object. /// Reverses the entire string object.
void Reverse() void Reverse()
{ {
if (size <= 1 || !data) if (size <= 1 || !data)
@ -859,7 +872,7 @@ namespace ehs
} }
/// Reverses the entire string object. /// Reverses the entire string object.
/// @returns The result. /// @returns The resulting string object.
Str<T, N> GetReverse() Str<T, N> GetReverse()
{ {
if (size <= 1 || !data) if (size <= 1 || !data)
@ -876,7 +889,7 @@ namespace ehs
/// Clips the string at the given index and with the given size. /// Clips the string at the given index and with the given size.
/// @param [in] index The index to clip at. /// @param [in] index The index to clip at.
/// @param [in] size The size for the clip starting from the index. /// @param [in] size The size for the clip starting from the index.
/// @returns The result. /// @returns The resulting string object.
Str<T, N> Sub(const N index, const N size = 0) const Str<T, N> Sub(const N index, const N size = 0) const
{ {
if (index >= this->size) if (index >= this->size)
@ -911,10 +924,10 @@ namespace ehs
} }
} }
/// Splits a string into an array with the given separator. /// Splits a string into a Vector with the given separator.
/// @param [in] ide The given string as the separator. /// @param [in] ide The given string as the separator.
/// @param [in] max The max amount of times to split the string. /// @param [in] max The max amount of times to split the string.
/// @returns The result. /// @returns The resulting string object.
Vector<Str<T, N>, N> Split(const Str<T, N>& ide, const N max = 0) const Vector<Str<T, N>, N> Split(const Str<T, N>& ide, const N max = 0) const
{ {
Vector<Str<T, N>, N> result(0, 5); Vector<Str<T, N>, N> result(0, 5);
@ -952,9 +965,9 @@ namespace ehs
return result; return result;
} }
/// Removes all instances of the given string object. /// Removes all instances of the ide.
/// @param [in] ide The string to look for. /// @param [in] ide The string to look for.
/// @returns The result. /// @returns The resulting string object.
Str<T, N> RemoveAll(const Str<T, N>& ide) const Str<T, N> RemoveAll(const Str<T, N>& ide) const
{ {
Str<T, N> result(size); Str<T, N> result(size);
@ -981,6 +994,10 @@ namespace ehs
return result; return result;
} }
/// Replaces all instances of ide with the replacer.
/// @param [in] ide The string to look for.
/// @param [in] replacer The string placed.
/// @returns The resulting string object.
Str ReplaceAll(const Str& ide, const Str& replacer) const Str ReplaceAll(const Str& ide, const Str& replacer) const
{ {
Str<T, N> result; Str<T, N> result;
@ -1068,6 +1085,10 @@ namespace ehs
return false; return false;
} }
/// Checks if the current string contains the given ide.
/// @param [in] ide The given ide to check for.
/// @param [in] pattern The search pattern to use.
/// @returns True if the current string does contain the ide.
bool Contains(const Str<T, N>& ide, const SearchPattern pattern = SearchPattern::LEFT_RIGHT) const bool Contains(const Str<T, N>& ide, const SearchPattern pattern = SearchPattern::LEFT_RIGHT) const
{ {
if (pattern == SearchPattern::LEFT_RIGHT) if (pattern == SearchPattern::LEFT_RIGHT)
@ -1117,6 +1138,10 @@ namespace ehs
return true; return true;
} }
/// Converts a number into hexadecimal string representation.
/// @tparam I The data type of the number given.
/// @param [in] num The number to convert.
/// @returns The resulting hexadecimal.
template<typename I = int> template<typename I = int>
static Str NumToHex(const I num) static Str NumToHex(const I num)
{ {
@ -1133,6 +1158,10 @@ namespace ehs
return result; return result;
} }
/// Converts a string hexadecimal into a number.
/// @tparam I The data type of the number outputted.
/// @param [in] in The string to convert.
/// @returns The resulting number.
template<typename I = int> template<typename I = int>
static I HexToNum(const Str& in) static I HexToNum(const Str& in)
{ {
@ -1173,6 +1202,9 @@ namespace ehs
return neg ? -acc : acc; return neg ? -acc : acc;
} }
/// Converts the current string from hexadecimal into a number.
/// @tparam I The data type of the number outputted.
/// @returns The resulting number.
template<typename I = int> template<typename I = int>
I HexToNum() const I HexToNum() const
{ {
@ -1216,7 +1248,7 @@ namespace ehs
/// Converts the string into a number. /// Converts the string into a number.
/// @tparam I The resulting number's data type. /// @tparam I The resulting number's data type.
/// @returns The result. /// @returns The result.
/// @note Use "IsNum" before this if the referenced string object will not always be a number. /// @note Use "IsNum" before this if the string object is not guaranteed to be a number.
template<typename I = N> template<typename I = N>
I ToDecimal() const I ToDecimal() const
{ {
@ -1234,6 +1266,9 @@ namespace ehs
return r; return r;
} }
/// Converts the string into a floating point number.
/// @returns The resulting float.
/// @note Use "IsNum" before this if the string object is not guaranteed to be a number.
float ToFloat() const float ToFloat() const
{ {
N decPoint = size; N decPoint = size;
@ -1257,6 +1292,9 @@ namespace ehs
return result; return result;
} }
/// Converts the string into a double floating point number.
/// @returns The resulting double.
/// @note Use "IsNum" before this if the string object is not guaranteed to be a number.
double ToDouble() const double ToDouble() const
{ {
N decPoint = size; N decPoint = size;
@ -1280,6 +1318,9 @@ namespace ehs
return result; return result;
} }
/// Converts the string into a long double floating point number.
/// @returns The resulting long double.
/// @note Use "IsNum" before this if the string object is not guaranteed to be a number.
long double ToLDouble() const long double ToLDouble() const
{ {
N decPoint = size; N decPoint = size;
@ -1304,7 +1345,8 @@ namespace ehs
} }
/// Converts the given number into a string. /// Converts the given number into a string.
/// @returns The result. /// @param [in] num The given number to convert.
/// @returns The resulting string representation.
static Str<T, N> FromNum(const SInt_64 num) static Str<T, N> FromNum(const SInt_64 num)
{ {
if (num == 0) if (num == 0)
@ -1339,7 +1381,8 @@ namespace ehs
} }
/// Converts the given number into a string. /// Converts the given number into a string.
/// @returns The result. /// @param [in] num The given number to convert.
/// @returns The resulting string representation.
static Str<T, N> FromNum(const UInt_64 num) static Str<T, N> FromNum(const UInt_64 num)
{ {
if (num == 0) if (num == 0)
@ -1367,7 +1410,8 @@ namespace ehs
} }
/// Converts the given number into a string. /// Converts the given number into a string.
/// @returns The result. /// @param [in] num The given number to convert.
/// @returns The resulting string representation.
static Str<T, N> FromNum(const SInt_32 num) static Str<T, N> FromNum(const SInt_32 num)
{ {
if (num == 0) if (num == 0)
@ -1402,7 +1446,8 @@ namespace ehs
} }
/// Converts the given number into a string. /// Converts the given number into a string.
/// @returns The result. /// @param [in] num The given number to convert.
/// @returns The resulting string representation.
static Str<T, N> FromNum(const UInt_32 num) static Str<T, N> FromNum(const UInt_32 num)
{ {
if (num == 0) if (num == 0)
@ -1430,7 +1475,8 @@ namespace ehs
} }
/// Converts the given number into a string. /// Converts the given number into a string.
/// @returns The result. /// @param [in] num The given number to convert.
/// @returns The resulting string representation.
static Str<T, N> FromNum(const SInt_16 num) static Str<T, N> FromNum(const SInt_16 num)
{ {
if (num == 0) if (num == 0)
@ -1465,7 +1511,8 @@ namespace ehs
} }
/// Converts the given number into a string. /// Converts the given number into a string.
/// @returns The result. /// @param [in] num The given number to convert.
/// @returns The resulting string representation.
static Str<T, N> FromNum(const UInt_16 num) static Str<T, N> FromNum(const UInt_16 num)
{ {
if (num == 0) if (num == 0)
@ -1493,7 +1540,8 @@ namespace ehs
} }
/// Converts the given number into a string. /// Converts the given number into a string.
/// @returns The result. /// @param [in] num The given number to convert.
/// @returns The resulting string representation.
static Str<T, N> FromNum(const SInt_8 num) static Str<T, N> FromNum(const SInt_8 num)
{ {
if (num == 0) if (num == 0)
@ -1528,7 +1576,8 @@ namespace ehs
} }
/// Converts the given number into a string. /// Converts the given number into a string.
/// @returns The result. /// @param [in] num The given number to convert.
/// @returns The resulting string representation.
static Str<T, N> FromNum(const UInt_8 num) static Str<T, N> FromNum(const UInt_8 num)
{ {
if (num == 0) if (num == 0)
@ -1620,8 +1669,10 @@ namespace ehs
} }
#endif #endif
/// Converts the given float into a string. /// Converts the given floating point into a string.
/// @returns The result. /// @param [in] num The given floating point to convert.
/// @param [in] maxDecimals The max decimal places to add.
/// @returns The resulting string representation.
static Str<T, N> FromNum(const float num, const UInt_8 maxDecimals = 5) static Str<T, N> FromNum(const float num, const UInt_8 maxDecimals = 5)
{ {
SInt_64 whole = (SInt_64)num; SInt_64 whole = (SInt_64)num;
@ -1660,8 +1711,10 @@ namespace ehs
return result; return result;
} }
/// Converts the given double into a string. /// Converts the given double floating point into a string.
/// @returns The result. /// @param [in] num The given double floating point to convert.
/// @param [in] maxDecimals The max decimal places to add.
/// @returns The resulting string representation.
static Str<T, N> FromNum(const double num, const UInt_8 maxDecimals = 5) static Str<T, N> FromNum(const double num, const UInt_8 maxDecimals = 5)
{ {
SInt_64 whole = (SInt_64)num; SInt_64 whole = (SInt_64)num;
@ -1700,8 +1753,10 @@ namespace ehs
return result; return result;
} }
/// Converts the given long double into a string. /// Converts the given long double floating point into a string.
/// @returns The result. /// @param [in] num The given long double floating point to convert.
/// @param [in] maxDecimals The max decimal places to add.
/// @returns The resulting string representation.
static Str<T, N> FromNum(const long double num, const UInt_8 maxDecimals = 5) static Str<T, N> FromNum(const long double num, const UInt_8 maxDecimals = 5)
{ {
SInt_64 whole = (SInt_64)num; SInt_64 whole = (SInt_64)num;
@ -1742,7 +1797,7 @@ namespace ehs
/// A 32-bit FNV-1a hash algorithm. /// A 32-bit FNV-1a hash algorithm.
/// @param [in] str The string to hash. /// @param [in] str The string to hash.
/// @returns The resulting hash. /// @returns The resulting hash. Zero if string does not contain any characters.
static UInt_32 Hash_32(const Str<T, N>& str) static UInt_32 Hash_32(const Str<T, N>& str)
{ {
if (!str.Size()) if (!str.Size())
@ -1758,6 +1813,8 @@ namespace ehs
return hash; return hash;
} }
/// A 32-bit FNV-1a hash algorithm.
/// @returns The resulting hash. Zero if string does not contain any characters.
UInt_32 Hash_32() const UInt_32 Hash_32() const
{ {
if (!size) if (!size)
@ -1775,7 +1832,7 @@ namespace ehs
/// A 64-bit FNV-1a hash algorithm. /// A 64-bit FNV-1a hash algorithm.
/// @param [in] str The string to hash. /// @param [in] str The string to hash.
/// @returns The resulting hash. /// @returns The resulting hash. Zero if string does not contain any characters.
static UInt_64 Hash_64(const Str<T, N>& str) static UInt_64 Hash_64(const Str<T, N>& str)
{ {
if (!str.Size()) if (!str.Size())
@ -1791,6 +1848,8 @@ namespace ehs
return hash; return hash;
} }
/// A 64-bit FNV-1a hash algorithm.
/// @returns The resulting hash. Zero if string does not contain any characters.
UInt_64 Hash_64() const UInt_64 Hash_64() const
{ {
if (!size) if (!size)
@ -1806,6 +1865,9 @@ namespace ehs
return hash; return hash;
} }
/// Calculates the length of a C-Style string.
/// @param [in] str The C-Style string to calculate.
/// @returns The character count.
static N Len(const T* const str) static N Len(const T* const str)
{ {
N count = 0; N count = 0;
@ -1814,6 +1876,10 @@ namespace ehs
return count; return count;
} }
/// Compares two C-style string with each other.
/// @param [in] a The first C-style string to compare.
/// @param [in] b The second C-style string to compare.
/// @returns True if both C-style strings are equal.
static bool Cmp(const T* const a, const T* const b) static bool Cmp(const T* const a, const T* const b)
{ {
N aSize = Len(a); N aSize = Len(a);