aboutsummaryrefslogtreecommitdiff
path: root/include/cru/platform
diff options
context:
space:
mode:
Diffstat (limited to 'include/cru/platform')
-rw-r--r--include/cru/platform/Check.h30
-rw-r--r--include/cru/platform/Exception.h17
2 files changed, 0 insertions, 47 deletions
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,42 +2,12 @@
#include "Exception.h"
#include "Resource.h"
-#include "cru/base/String.h"
-
#include <memory>
#include <type_traits>
namespace cru::platform {
template <typename TTarget>
TTarget* CheckPlatform(IPlatformResource* resource,
- const String& target_platform) {
- if (resource == nullptr) return nullptr;
- const auto result = dynamic_cast<TTarget*>(resource);
- if (result == nullptr) {
- throw PlatformNotMatchException(
- resource->GetPlatformId(), target_platform,
- u"Try to convert resource to target platform failed.");
- }
- return result;
-}
-
-template <typename TTarget, typename TSource>
-std::shared_ptr<TTarget> CheckPlatform(const std::shared_ptr<TSource>& resource,
- const String& target_platform) {
- if (resource == nullptr) return nullptr;
- static_assert(std::is_base_of_v<IPlatformResource, TSource>,
- "TSource must be a subclass of INativeResource.");
- const auto result = std::dynamic_pointer_cast<TTarget>(resource);
- if (result == nullptr) {
- throw PlatformNotMatchException(
- resource->GetPlatformId(), target_platform,
- u"Try to convert resource to target platform failed.");
- }
- return result;
-}
-
-template <typename TTarget>
-TTarget* CheckPlatform(IPlatformResource* resource,
std::string target_platform) {
if (resource == nullptr) return nullptr;
const auto result = dynamic_cast<TTarget*>(resource);
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<std::string_view> additional_message = std::nullopt);
- PlatformNotMatchException(
- StringView resource_platform, StringView target_platform,
- std::optional<StringView> 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<std::string_view> additional_message);
- PlatformUnsupportedException(StringView platform, StringView operation,
- std::optional<StringView> 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_; }