2026-11-03 20:11:31 +01:00
|
|
|
// Tóth Dániel Mátyás | IFPQYY | v1
|
|
|
|
|
#include "CMyStringException.h"
|
2026-11-05 12:43:22 +01:00
|
|
|
|
|
|
|
|
static int strLength(const char* str) {
|
|
|
|
|
if (str == nullptr)
|
|
|
|
|
{
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
int cnt = 0;
|
|
|
|
|
while (str[cnt])
|
|
|
|
|
{
|
|
|
|
|
cnt++;
|
|
|
|
|
}
|
|
|
|
|
return cnt;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void CopyStr(char* dest, const char* src, size_t length) {
|
|
|
|
|
if (dest == nullptr || src == nullptr) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
size_t i;
|
|
|
|
|
for (i = 0; i < length; i++)
|
|
|
|
|
{
|
|
|
|
|
dest[i] = src[i];
|
|
|
|
|
}
|
|
|
|
|
dest[i] = '\0';
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
CMyStringException::CMyStringException(const char* input) {
|
|
|
|
|
int len = strLength(input);
|
|
|
|
|
msg = unique_ptr<char[]>(new char[len+1]);
|
|
|
|
|
CopyStr(msg.get(), input, len);
|
|
|
|
|
}
|
2026-11-06 11:36:52 +01:00
|
|
|
const char* CMyStringException::what() const {
|
2026-11-05 12:43:22 +01:00
|
|
|
return msg.get();
|
|
|
|
|
}
|