ExceptionMessage.cpp 996 B

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