ExceptionMessage.cpp 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. /*
  2. * Author: Patrick-Christopher Mattulat
  3. * Co-Author: Claude Sonnet 4.6 (LLM)
  4. * Company: Lynar Studios
  5. * E-Mail: webmaster@lynarstudios.com
  6. * Created: 2023-02-07
  7. * Changed: 2026-06-23
  8. *
  9. * */
  10. #include <cstring>
  11. #include <ls-std/core/exception/ExceptionMessage.hpp>
  12. using ls::standard::core::ExceptionMessage;
  13. using std::move;
  14. using std::string;
  15. ExceptionMessage::ExceptionMessage(string _message) : message(::move(_message)) // TODO: deprecated
  16. {}
  17. ExceptionMessage::~ExceptionMessage() = default;
  18. char *ExceptionMessage::toCharacterPointer()
  19. {
  20. char *rawPointerMessage{};
  21. if (!this->message.empty())
  22. {
  23. size_t initializationSize = this->message.size() + 1;
  24. rawPointerMessage = new char[initializationSize];
  25. #if defined(unix) || defined(__APPLE__)
  26. strcpy(rawPointerMessage, this->message.c_str());
  27. #endif
  28. #ifdef _WIN32
  29. strcpy_s(rawPointerMessage, initializationSize, this->message.c_str());
  30. #endif
  31. rawPointerMessage[this->message.size()] = '\0';
  32. }
  33. return rawPointerMessage;
  34. }