| 1 |
#ifndef ICU4XScriptExtensionsSet_HPP |
| 2 |
#define ICU4XScriptExtensionsSet_HPP |
| 3 |
#include <stdint.h> |
| 4 |
#include <stddef.h> |
| 5 |
#include <stdbool.h> |
| 6 |
#include <algorithm> |
| 7 |
#include <memory> |
| 8 |
#include <variant> |
| 9 |
#include <optional> |
| 10 |
#include "diplomat_runtime.hpp" |
| 11 |
|
| 12 |
#include "ICU4XScriptExtensionsSet.h" |
| 13 |
|
| 14 |
|
| 15 |
/** |
| 16 |
* A destruction policy for using ICU4XScriptExtensionsSet with std::unique_ptr. |
| 17 |
*/ |
| 18 |
struct ICU4XScriptExtensionsSetDeleter { |
| 19 |
void operator()(capi::ICU4XScriptExtensionsSet* l) const noexcept { |
| 20 |
capi::ICU4XScriptExtensionsSet_destroy(l); |
| 21 |
} |
| 22 |
}; |
| 23 |
|
| 24 |
/** |
| 25 |
* An object that represents the Script_Extensions property for a single character |
| 26 |
* |
| 27 |
* See the [Rust documentation for `ScriptExtensionsSet`](https://docs.rs/icu/latest/icu/properties/script/struct.ScriptExtensionsSet.html) for more information. |
| 28 |
*/ |
| 29 |
class ICU4XScriptExtensionsSet { |
| 30 |
public: |
| 31 |
|
| 32 |
/** |
| 33 |
* Check if the Script_Extensions property of the given code point covers the given script |
| 34 |
* |
| 35 |
* See the [Rust documentation for `contains`](https://docs.rs/icu/latest/icu/properties/script/struct.ScriptExtensionsSet.html#method.contains) for more information. |
| 36 |
*/ |
| 37 |
bool contains(uint16_t script) const; |
| 38 |
|
| 39 |
/** |
| 40 |
* Get the number of scripts contained in here |
| 41 |
* |
| 42 |
* See the [Rust documentation for `iter`](https://docs.rs/icu/latest/icu/properties/script/struct.ScriptExtensionsSet.html#method.iter) for more information. |
| 43 |
*/ |
| 44 |
size_t count() const; |
| 45 |
|
| 46 |
/** |
| 47 |
* Get script at index |
| 48 |
* |
| 49 |
* See the [Rust documentation for `iter`](https://docs.rs/icu/latest/icu/properties/script/struct.ScriptExtensionsSet.html#method.iter) for more information. |
| 50 |
*/ |
| 51 |
diplomat::result<uint16_t, std::monostate> script_at(size_t index) const; |
| 52 |
inline const capi::ICU4XScriptExtensionsSet* AsFFI() const { return this->inner.get(); } |
| 53 |
inline capi::ICU4XScriptExtensionsSet* AsFFIMut() { return this->inner.get(); } |
| 54 |
inline explicit ICU4XScriptExtensionsSet(capi::ICU4XScriptExtensionsSet* i) : inner(i) {} |
| 55 |
ICU4XScriptExtensionsSet() = default; |
| 56 |
ICU4XScriptExtensionsSet(ICU4XScriptExtensionsSet&&) noexcept = default; |
| 57 |
ICU4XScriptExtensionsSet& operator=(ICU4XScriptExtensionsSet&& other) noexcept = default; |
| 58 |
private: |
| 59 |
std::unique_ptr<capi::ICU4XScriptExtensionsSet, ICU4XScriptExtensionsSetDeleter> inner; |
| 60 |
}; |
| 61 |
|
| 62 |
|
| 63 |
inline bool ICU4XScriptExtensionsSet::contains(uint16_t script) const { |
| 64 |
return capi::ICU4XScriptExtensionsSet_contains(this->inner.get(), script); |
| 65 |
} |
| 66 |
inline size_t ICU4XScriptExtensionsSet::count() const { |
| 67 |
return capi::ICU4XScriptExtensionsSet_count(this->inner.get()); |
| 68 |
} |
| 69 |
inline diplomat::result<uint16_t, std::monostate> ICU4XScriptExtensionsSet::script_at(size_t index) const { |
| 70 |
auto diplomat_result_raw_out_value = capi::ICU4XScriptExtensionsSet_script_at(this->inner.get(), index); |
| 71 |
diplomat::result<uint16_t, std::monostate> diplomat_result_out_value; |
| 72 |
if (diplomat_result_raw_out_value.is_ok) { |
| 73 |
diplomat_result_out_value = diplomat::Ok<uint16_t>(diplomat_result_raw_out_value.ok); |
| 74 |
} else { |
| 75 |
diplomat_result_out_value = diplomat::Err<std::monostate>(std::monostate()); |
| 76 |
} |
| 77 |
return diplomat_result_out_value; |
| 78 |
} |
| 79 |
#endif |