/*
* Author:          Patrick-Christopher Mattulat
* Co-Author:       Claude Sonnet 4.6 (LLM)
* Company:         Lynar Studios
* E-Mail:          webmaster@lynarstudios.com
* Created:         2023-02-07
* Changed:         2026-06-23
*
* */

#include <cstring>
#include <ls-std/core/exception/ExceptionMessage.hpp>

using ls::standard::core::ExceptionMessage;
using std::move;
using std::string;

ExceptionMessage::ExceptionMessage(string _message) : message(::move(_message)) // TODO: deprecated
{}

ExceptionMessage::~ExceptionMessage() = default;

char *ExceptionMessage::toCharacterPointer()
{
  char *rawPointerMessage{};

  if (!this->message.empty())
  {
    size_t initializationSize = this->message.size() + 1;
    rawPointerMessage = new char[initializationSize];
#if defined(unix) || defined(__APPLE__)
    strcpy(rawPointerMessage, this->message.c_str());
#endif
#ifdef _WIN32
    strcpy_s(rawPointerMessage, initializationSize, this->message.c_str());
#endif
    rawPointerMessage[this->message.size()] = '\0';
  }

  return rawPointerMessage;
}
