| 1 |
#ifndef ICU4XLocaleFallbackerWithConfig_HPP |
| 2 |
#define ICU4XLocaleFallbackerWithConfig_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 "ICU4XLocaleFallbackerWithConfig.h" |
| 13 |
|
| 14 |
class ICU4XLocale; |
| 15 |
class ICU4XLocaleFallbackIterator; |
| 16 |
|
| 17 |
/** |
| 18 |
* A destruction policy for using ICU4XLocaleFallbackerWithConfig with std::unique_ptr. |
| 19 |
*/ |
| 20 |
struct ICU4XLocaleFallbackerWithConfigDeleter { |
| 21 |
void operator()(capi::ICU4XLocaleFallbackerWithConfig* l) const noexcept { |
| 22 |
capi::ICU4XLocaleFallbackerWithConfig_destroy(l); |
| 23 |
} |
| 24 |
}; |
| 25 |
|
| 26 |
/** |
| 27 |
* An object that runs the ICU4X locale fallback algorithm with specific configurations. |
| 28 |
* |
| 29 |
* See the [Rust documentation for `LocaleFallbacker`](https://docs.rs/icu/latest/icu/locid_transform/fallback/struct.LocaleFallbacker.html) for more information. |
| 30 |
* |
| 31 |
* See the [Rust documentation for `LocaleFallbackerWithConfig`](https://docs.rs/icu/latest/icu/locid_transform/fallback/struct.LocaleFallbackerWithConfig.html) for more information. |
| 32 |
*/ |
| 33 |
class ICU4XLocaleFallbackerWithConfig { |
| 34 |
public: |
| 35 |
|
| 36 |
/** |
| 37 |
* Creates an iterator from a locale with each step of fallback. |
| 38 |
* |
| 39 |
* See the [Rust documentation for `fallback_for`](https://docs.rs/icu/latest/icu/locid_transform/fallback/struct.LocaleFallbacker.html#method.fallback_for) for more information. |
| 40 |
* |
| 41 |
* Lifetimes: `this` must live at least as long as the output. |
| 42 |
*/ |
| 43 |
ICU4XLocaleFallbackIterator fallback_for_locale(const ICU4XLocale& locale) const; |
| 44 |
inline const capi::ICU4XLocaleFallbackerWithConfig* AsFFI() const { return this->inner.get(); } |
| 45 |
inline capi::ICU4XLocaleFallbackerWithConfig* AsFFIMut() { return this->inner.get(); } |
| 46 |
inline explicit ICU4XLocaleFallbackerWithConfig(capi::ICU4XLocaleFallbackerWithConfig* i) : inner(i) {} |
| 47 |
ICU4XLocaleFallbackerWithConfig() = default; |
| 48 |
ICU4XLocaleFallbackerWithConfig(ICU4XLocaleFallbackerWithConfig&&) noexcept = default; |
| 49 |
ICU4XLocaleFallbackerWithConfig& operator=(ICU4XLocaleFallbackerWithConfig&& other) noexcept = default; |
| 50 |
private: |
| 51 |
std::unique_ptr<capi::ICU4XLocaleFallbackerWithConfig, ICU4XLocaleFallbackerWithConfigDeleter> inner; |
| 52 |
}; |
| 53 |
|
| 54 |
#include "ICU4XLocale.hpp" |
| 55 |
#include "ICU4XLocaleFallbackIterator.hpp" |
| 56 |
|
| 57 |
inline ICU4XLocaleFallbackIterator ICU4XLocaleFallbackerWithConfig::fallback_for_locale(const ICU4XLocale& locale) const { |
| 58 |
return ICU4XLocaleFallbackIterator(capi::ICU4XLocaleFallbackerWithConfig_fallback_for_locale(this->inner.get(), locale.AsFFI())); |
| 59 |
} |
| 60 |
#endif |