From 3c8d5c8f732239a8b50418be27464e30b9dddeae Mon Sep 17 00:00:00 2001 From: Yuqian Yang Date: Fri, 17 Oct 2025 08:37:30 +0800 Subject: Exception remove string. --- include/cru/platform/Check.h | 30 ------------------------------ include/cru/platform/Exception.h | 17 ----------------- 2 files changed, 47 deletions(-) (limited to 'include/cru/platform') diff --git a/include/cru/platform/Check.h b/include/cru/platform/Check.h index 202ee86e..b36b7fc1 100644 --- a/include/cru/platform/Check.h +++ b/include/cru/platform/Check.h @@ -2,40 +2,10 @@ #include "Exception.h" #include "Resource.h" -#include "cru/base/String.h" - #include #include namespace cru::platform { -template -TTarget* CheckPlatform(IPlatformResource* resource, - const String& target_platform) { - if (resource == nullptr) return nullptr; - const auto result = dynamic_cast(resource); - if (result == nullptr) { - throw PlatformNotMatchException( - resource->GetPlatformId(), target_platform, - u"Try to convert resource to target platform failed."); - } - return result; -} - -template -std::shared_ptr CheckPlatform(const std::shared_ptr& resource, - const String& target_platform) { - if (resource == nullptr) return nullptr; - static_assert(std::is_base_of_v, - "TSource must be a subclass of INativeResource."); - const auto result = std::dynamic_pointer_cast(resource); - if (result == nullptr) { - throw PlatformNotMatchException( - resource->GetPlatformId(), target_platform, - u"Try to convert resource to target platform failed."); - } - return result; -} - template TTarget* CheckPlatform(IPlatformResource* resource, std::string target_platform) { diff --git a/include/cru/platform/Exception.h b/include/cru/platform/Exception.h index f8ed5b0c..f43162d1 100644 --- a/include/cru/platform/Exception.h +++ b/include/cru/platform/Exception.h @@ -16,17 +16,8 @@ class CRU_PLATFORM_API PlatformNotMatchException : public PlatformException { std::string resource_platform, std::string target_platform, std::optional additional_message = std::nullopt); - PlatformNotMatchException( - StringView resource_platform, StringView target_platform, - std::optional additional_message = std::nullopt); - ~PlatformNotMatchException() override; - [[deprecated("Use GetResourcePlatformUtf8 instead.")]] - String GetResourcePlatform() const; - [[deprecated("Use GetTargetPlatform instead.")]] - String GetTargetPlatform() const; - std::string GetResourcePlatformUtf8() const { return resource_platform_; } std::string GetTargetPlatformUtf8() const { return target_platform_; } @@ -52,16 +43,8 @@ class CRU_PLATFORM_API PlatformUnsupportedException : public PlatformException { std::string platform, std::string operation, std::optional additional_message); - PlatformUnsupportedException(StringView platform, StringView operation, - std::optional additional_message); - ~PlatformUnsupportedException() override; - [[deprecated("Use GetPlatformUtf8 instead.")]] - String GetPlatform() const; - [[deprecated("Use GetOperationUtf8 instead.")]] - String GetOperation() const; - std::string GetPlatformUtf8() const { return platform_; } std::string GetOperationUtf8() const { return operation_; } -- cgit v1.2.3