diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/common/Exception.cpp | 9 | ||||
-rw-r--r-- | src/platform/CMakeLists.txt | 1 | ||||
-rw-r--r-- | src/platform/Exception.cpp | 44 | ||||
-rw-r--r-- | src/platform/graphics/SvgGeometry.cpp | 6 |
4 files changed, 60 insertions, 0 deletions
diff --git a/src/common/Exception.cpp b/src/common/Exception.cpp index b0053bac..e1e3e128 100644 --- a/src/common/Exception.cpp +++ b/src/common/Exception.cpp @@ -19,6 +19,15 @@ const char* Exception::what() const noexcept { return utf8_message_.c_str(); } +void Exception::AppendMessage(StringView additional_message) { + message_ += u" "; + message_ += additional_message; +} + +void Exception::AppendMessage(std::optional<StringView> additional_message) { + if (additional_message) AppendMessage(*additional_message); +} + ErrnoException::ErrnoException(const String& message) : ErrnoException(message, errno) {} diff --git a/src/platform/CMakeLists.txt b/src/platform/CMakeLists.txt index 3f85adbc..4779bb57 100644 --- a/src/platform/CMakeLists.txt +++ b/src/platform/CMakeLists.txt @@ -1,6 +1,7 @@ add_library(CruPlatformBase ForDllExport.cpp Color.cpp + Exception.cpp GraphicsBase.cpp ) target_link_libraries(CruPlatformBase PUBLIC CruBase) diff --git a/src/platform/Exception.cpp b/src/platform/Exception.cpp new file mode 100644 index 00000000..7aef3b7f --- /dev/null +++ b/src/platform/Exception.cpp @@ -0,0 +1,44 @@ +#include "cru/platform/Exception.h" +#include "cru/common/Format.h" + +#include <optional> + +namespace cru::platform { +PlatformNotMatchException::PlatformNotMatchException( + String resource_platform, String target_platform, + std::optional<StringView> additional_message) + : resource_platform_(std::move(resource_platform)), + target_platform_(std::move(target_platform)) { + SetMessage( + Format(u"Resource platform '{}' does not match target platform '{}'.", + resource_platform_, target_platform_)); + + AppendMessage(additional_message); +} + +PlatformNotMatchException::~PlatformNotMatchException() {} + +String PlatformNotMatchException::GetResourcePlatform() const { + return resource_platform_; +} + +String PlatformNotMatchException::GetTargetPlatform() const { + return target_platform_; +} + +PlatformUnsupportedException::PlatformUnsupportedException( + String platform, String operation, + std::optional<StringView> additional_message) + : platform_(std::move(platform)), operation_(std::move(operation)) { + SetMessage(Format(u"Operation '{}' is not supported on platform '{}'.", + operation_, platform_)); + AppendMessage(additional_message); +} + +PlatformUnsupportedException::~PlatformUnsupportedException() {} + +String PlatformUnsupportedException::GetPlatform() const { return platform_; } + +String PlatformUnsupportedException::GetOperation() const { return operation_; } + +} // namespace cru::platform diff --git a/src/platform/graphics/SvgGeometry.cpp b/src/platform/graphics/SvgGeometry.cpp index 149c4bb6..b757c520 100644 --- a/src/platform/graphics/SvgGeometry.cpp +++ b/src/platform/graphics/SvgGeometry.cpp @@ -1 +1,7 @@ #include "cru/platform/graphics/SvgGeometry.h" + +namespace cru::platform::graphics { +SvgGeometryBuilder::SvgGeometryBuilder() {} + +SvgGeometryBuilder::~SvgGeometryBuilder() {} +} // namespace cru::platform::graphics |