-
-
Notifications
You must be signed in to change notification settings - Fork 33
Expand file tree
/
Copy pathHybridWebImageFactorySpecSwift.hpp
More file actions
115 lines (101 loc) · 4.27 KB
/
Copy pathHybridWebImageFactorySpecSwift.hpp
File metadata and controls
115 lines (101 loc) · 4.27 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
///
/// HybridWebImageFactorySpecSwift.hpp
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
/// https://github.com/mrousavy/nitro
/// Copyright © Marc Rousavy @ Margelo
///
#pragma once
#include "HybridWebImageFactorySpec.hpp"
// Forward declaration of `HybridWebImageFactorySpec_cxx` to properly resolve imports.
namespace NitroWebImage { class HybridWebImageFactorySpec_cxx; }
// Forward declaration of `HybridImageLoaderSpec` to properly resolve imports.
namespace margelo::nitro::image { class HybridImageLoaderSpec; }
// Forward declaration of `AsyncImageLoadOptions` to properly resolve imports.
namespace margelo::nitro::web::image { struct AsyncImageLoadOptions; }
// Forward declaration of `AsyncImagePriority` to properly resolve imports.
namespace margelo::nitro::web::image { enum class AsyncImagePriority; }
// Forward declaration of `HybridImageSpec` to properly resolve imports.
namespace margelo::nitro::image { class HybridImageSpec; }
#include <memory>
#include <NitroImage/HybridImageLoaderSpec.hpp>
#include <string>
#include "AsyncImageLoadOptions.hpp"
#include <optional>
#include "AsyncImagePriority.hpp"
#include <NitroImage/HybridImageSpec.hpp>
#include <NitroModules/Promise.hpp>
#include "NitroWebImage-Swift-Cxx-Umbrella.hpp"
namespace margelo::nitro::web::image {
/**
* The C++ part of HybridWebImageFactorySpec_cxx.swift.
*
* HybridWebImageFactorySpecSwift (C++) accesses HybridWebImageFactorySpec_cxx (Swift), and might
* contain some additional bridging code for C++ <> Swift interop.
*
* Since this obviously introduces an overhead, I hope at some point in
* the future, HybridWebImageFactorySpec_cxx can directly inherit from the C++ class HybridWebImageFactorySpec
* to simplify the whole structure and memory management.
*/
class HybridWebImageFactorySpecSwift: public virtual HybridWebImageFactorySpec {
public:
// Constructor from a Swift instance
explicit HybridWebImageFactorySpecSwift(const NitroWebImage::HybridWebImageFactorySpec_cxx& swiftPart):
HybridObject(HybridWebImageFactorySpec::TAG),
_swiftPart(swiftPart) { }
public:
// Get the Swift part
inline NitroWebImage::HybridWebImageFactorySpec_cxx& getSwiftPart() noexcept {
return _swiftPart;
}
public:
inline size_t getExternalMemorySize() noexcept override {
return _swiftPart.getMemorySize();
}
bool equals(const std::shared_ptr<HybridObject>& other) override {
if (auto otherCast = std::dynamic_pointer_cast<HybridWebImageFactorySpecSwift>(other)) {
return _swiftPart.equals(otherCast->_swiftPart);
}
return false;
}
void dispose() noexcept override {
_swiftPart.dispose();
}
std::string toString() override {
return _swiftPart.toString();
}
public:
// Properties
inline double getMaxMemoryBytes() noexcept override {
return _swiftPart.getMaxMemoryBytes();
}
inline void setMaxMemoryBytes(double maxMemoryBytes) noexcept override {
_swiftPart.setMaxMemoryBytes(std::forward<decltype(maxMemoryBytes)>(maxMemoryBytes));
}
public:
// Methods
inline std::shared_ptr<margelo::nitro::image::HybridImageLoaderSpec> createWebImageLoader(const std::string& url, const std::optional<AsyncImageLoadOptions>& options) override {
auto __result = _swiftPart.createWebImageLoader(url, options);
if (__result.hasError()) [[unlikely]] {
std::rethrow_exception(__result.error());
}
auto __value = std::move(__result.value());
return __value;
}
inline std::shared_ptr<Promise<std::shared_ptr<margelo::nitro::image::HybridImageSpec>>> loadFromURLAsync(const std::string& url, const std::optional<AsyncImageLoadOptions>& options) override {
auto __result = _swiftPart.loadFromURLAsync(url, options);
if (__result.hasError()) [[unlikely]] {
std::rethrow_exception(__result.error());
}
auto __value = std::move(__result.value());
return __value;
}
inline void preload(const std::string& url) override {
auto __result = _swiftPart.preload(url);
if (__result.hasError()) [[unlikely]] {
std::rethrow_exception(__result.error());
}
}
private:
NitroWebImage::HybridWebImageFactorySpec_cxx _swiftPart;
};
} // namespace margelo::nitro::web::image