aboutsummaryrefslogtreecommitdiff
path: root/src/platform
diff options
context:
space:
mode:
authorYuqian Yang <crupest@crupest.life>2025-09-07 03:34:56 +0800
committerYuqian Yang <crupest@crupest.life>2025-09-07 03:34:56 +0800
commit20123151d12a0b01453ab6a36c84e4d3e5ea9504 (patch)
tree27543f3e5bf6430298c94c38bad6ecc83dafdd47 /src/platform
parent227118866190a7fe17b42e8c589c475781c69f33 (diff)
downloadcru-20123151d12a0b01453ab6a36c84e4d3e5ea9504.tar.gz
cru-20123151d12a0b01453ab6a36c84e4d3e5ea9504.tar.bz2
cru-20123151d12a0b01453ab6a36c84e4d3e5ea9504.zip
Remove some usage of my format.
Diffstat (limited to 'src/platform')
-rw-r--r--src/platform/Exception.cpp61
-rw-r--r--src/platform/graphics/SvgGeometryBuilderMixin.cpp2
-rw-r--r--src/platform/gui/UiApplication.cpp2
3 files changed, 43 insertions, 22 deletions
diff --git a/src/platform/Exception.cpp b/src/platform/Exception.cpp
index 948345e0..d5ae4702 100644
--- a/src/platform/Exception.cpp
+++ b/src/platform/Exception.cpp
@@ -1,44 +1,61 @@
#include "cru/platform/Exception.h"
-#include "cru/base/Format.h"
+#include "cru/base/Exception.h"
+#include <format>
#include <optional>
+#include <string_view>
namespace cru::platform {
PlatformNotMatchException::PlatformNotMatchException(
- String resource_platform, String target_platform,
- std::optional<StringView> additional_message)
- : resource_platform_(std::move(resource_platform)),
+ std::string resource_platform, std::string target_platform,
+ std::optional<std::string> additional_message)
+ : PlatformException(std::format(
+ "Resource platform '{}' does not match target platform '{}'.",
+ resource_platform_, target_platform_)),
+ 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() {}
+PlatformNotMatchException::PlatformNotMatchException(
+ StringView resource_platform, StringView target_platform,
+ std::optional<StringView> additional_message)
+ : PlatformNotMatchException(
+ resource_platform.ToUtf8(), target_platform.ToUtf8(),
+ additional_message.has_value()
+ ? std::make_optional(additional_message->ToUtf8())
+ : std::nullopt) {}
-String PlatformNotMatchException::GetResourcePlatform() const {
- return resource_platform_;
-}
+PlatformNotMatchException::~PlatformNotMatchException() {}
-String PlatformNotMatchException::GetTargetPlatform() const {
- return target_platform_;
+PlatformUnsupportedException::PlatformUnsupportedException(
+ std::string platform, std::string operation,
+ std::optional<std::string_view> additional_message)
+ : PlatformException(
+ std::format("Operation '{}' is not supported on platform '{}'.",
+ operation, platform)),
+ platform_(std::move(platform)),
+ operation_(std::move(operation)) {
+ AppendMessage(additional_message);
}
PlatformUnsupportedException::PlatformUnsupportedException(
- String platform, String operation,
+ StringView platform, StringView 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(
+ platform.ToUtf8(), operation.ToUtf8(),
+ additional_message.has_value()
+ ? std::make_optional(additional_message->ToUtf8())
+ : std::nullopt) {}
PlatformUnsupportedException::~PlatformUnsupportedException() {}
-String PlatformUnsupportedException::GetPlatform() const { return platform_; }
+String PlatformUnsupportedException::GetPlatform() const {
+ return String::FromUtf8(platform_);
+}
-String PlatformUnsupportedException::GetOperation() const { return operation_; }
+String PlatformUnsupportedException::GetOperation() const {
+ return String::FromUtf8(operation_);
+}
} // namespace cru::platform
diff --git a/src/platform/graphics/SvgGeometryBuilderMixin.cpp b/src/platform/graphics/SvgGeometryBuilderMixin.cpp
index 3f8b48ad..bf5275c5 100644
--- a/src/platform/graphics/SvgGeometryBuilderMixin.cpp
+++ b/src/platform/graphics/SvgGeometryBuilderMixin.cpp
@@ -1,6 +1,8 @@
#include "cru/platform/graphics/SvgGeometryBuilderMixin.h"
#include "cru/platform/Exception.h"
+#include "cru/base/Format.h"
+
namespace cru::platform::graphics {
SvgGeometryBuilderMixin::SvgGeometryBuilderMixin() {}
diff --git a/src/platform/gui/UiApplication.cpp b/src/platform/gui/UiApplication.cpp
index e565ce49..4c6f5e1d 100644
--- a/src/platform/gui/UiApplication.cpp
+++ b/src/platform/gui/UiApplication.cpp
@@ -1,5 +1,7 @@
#include "cru/platform/gui/UiApplication.h"
+#include "cru/base/Exception.h"
+
namespace cru::platform::gui {
IUiApplication* IUiApplication::instance = nullptr;