| 1 |
#ifndef ICU4XCodePointMapData8_HPP |
| 2 |
#define ICU4XCodePointMapData8_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 "ICU4XCodePointMapData8.h" |
| 13 |
|
| 14 |
class CodePointRangeIterator; |
| 15 |
class ICU4XCodePointSetData; |
| 16 |
class ICU4XDataProvider; |
| 17 |
class ICU4XCodePointMapData8; |
| 18 |
#include "ICU4XError.hpp" |
| 19 |
|
| 20 |
/** |
| 21 |
* A destruction policy for using ICU4XCodePointMapData8 with std::unique_ptr. |
| 22 |
*/ |
| 23 |
struct ICU4XCodePointMapData8Deleter { |
| 24 |
void operator()(capi::ICU4XCodePointMapData8* l) const noexcept { |
| 25 |
capi::ICU4XCodePointMapData8_destroy(l); |
| 26 |
} |
| 27 |
}; |
| 28 |
|
| 29 |
/** |
| 30 |
* An ICU4X Unicode Map Property object, capable of querying whether a code point (key) to obtain the Unicode property value, for a specific Unicode property. |
| 31 |
* |
| 32 |
* For properties whose values fit into 8 bits. |
| 33 |
* |
| 34 |
* See the [Rust documentation for `properties`](https://docs.rs/icu/latest/icu/properties/index.html) for more information. |
| 35 |
* |
| 36 |
* See the [Rust documentation for `CodePointMapData`](https://docs.rs/icu/latest/icu/properties/maps/struct.CodePointMapData.html) for more information. |
| 37 |
* |
| 38 |
* See the [Rust documentation for `CodePointMapDataBorrowed`](https://docs.rs/icu/latest/icu/properties/maps/struct.CodePointMapDataBorrowed.html) for more information. |
| 39 |
*/ |
| 40 |
class ICU4XCodePointMapData8 { |
| 41 |
public: |
| 42 |
|
| 43 |
/** |
| 44 |
* Gets the value for a code point. |
| 45 |
* |
| 46 |
* See the [Rust documentation for `get`](https://docs.rs/icu/latest/icu/properties/maps/struct.CodePointMapDataBorrowed.html#method.get) for more information. |
| 47 |
*/ |
| 48 |
uint8_t get(char32_t cp) const; |
| 49 |
|
| 50 |
/** |
| 51 |
* Gets the value for a code point (specified as a 32 bit integer, in UTF-32) |
| 52 |
*/ |
| 53 |
uint8_t get32(uint32_t cp) const; |
| 54 |
|
| 55 |
/** |
| 56 |
* Converts a general category to its corresponding mask value |
| 57 |
* |
| 58 |
* Nonexistent general categories will map to the empty mask |
| 59 |
* |
| 60 |
* See the [Rust documentation for `GeneralCategoryGroup`](https://docs.rs/icu/latest/icu/properties/struct.GeneralCategoryGroup.html) for more information. |
| 61 |
*/ |
| 62 |
static uint32_t general_category_to_mask(uint8_t gc); |
| 63 |
|
| 64 |
/** |
| 65 |
* Produces an iterator over ranges of code points that map to `value` |
| 66 |
* |
| 67 |
* See the [Rust documentation for `iter_ranges_for_value`](https://docs.rs/icu/latest/icu/properties/maps/struct.CodePointMapDataBorrowed.html#method.iter_ranges_for_value) for more information. |
| 68 |
* |
| 69 |
* Lifetimes: `this` must live at least as long as the output. |
| 70 |
*/ |
| 71 |
CodePointRangeIterator iter_ranges_for_value(uint8_t value) const; |
| 72 |
|
| 73 |
/** |
| 74 |
* Produces an iterator over ranges of code points that do not map to `value` |
| 75 |
* |
| 76 |
* See the [Rust documentation for `iter_ranges_for_value_complemented`](https://docs.rs/icu/latest/icu/properties/maps/struct.CodePointMapDataBorrowed.html#method.iter_ranges_for_value_complemented) for more information. |
| 77 |
* |
| 78 |
* Lifetimes: `this` must live at least as long as the output. |
| 79 |
*/ |
| 80 |
CodePointRangeIterator iter_ranges_for_value_complemented(uint8_t value) const; |
| 81 |
|
| 82 |
/** |
| 83 |
* Given a mask value (the nth bit marks property value = n), produce an iterator over ranges of code points |
| 84 |
* whose property values are contained in the mask. |
| 85 |
* |
| 86 |
* The main mask property supported is that for General_Category, which can be obtained via `general_category_to_mask()` or |
| 87 |
* by using `ICU4XGeneralCategoryNameToMaskMapper` |
| 88 |
* |
| 89 |
* Should only be used on maps for properties with values less than 32 (like Generak_Category), |
| 90 |
* other maps will have unpredictable results |
| 91 |
* |
| 92 |
* See the [Rust documentation for `iter_ranges_for_group`](https://docs.rs/icu/latest/icu/properties/maps/struct.CodePointMapDataBorrowed.html#method.iter_ranges_for_group) for more information. |
| 93 |
* |
| 94 |
* Lifetimes: `this` must live at least as long as the output. |
| 95 |
*/ |
| 96 |
CodePointRangeIterator iter_ranges_for_mask(uint32_t mask) const; |
| 97 |
|
| 98 |
/** |
| 99 |
* Gets a [`ICU4XCodePointSetData`] representing all entries in this map that map to the given value |
| 100 |
* |
| 101 |
* See the [Rust documentation for `get_set_for_value`](https://docs.rs/icu/latest/icu/properties/maps/struct.CodePointMapDataBorrowed.html#method.get_set_for_value) for more information. |
| 102 |
*/ |
| 103 |
ICU4XCodePointSetData get_set_for_value(uint8_t value) const; |
| 104 |
|
| 105 |
/** |
| 106 |
* See the [Rust documentation for `general_category`](https://docs.rs/icu/latest/icu/properties/maps/fn.general_category.html) for more information. |
| 107 |
*/ |
| 108 |
static diplomat::result<ICU4XCodePointMapData8, ICU4XError> load_general_category(const ICU4XDataProvider& provider); |
| 109 |
|
| 110 |
/** |
| 111 |
* See the [Rust documentation for `bidi_class`](https://docs.rs/icu/latest/icu/properties/maps/fn.bidi_class.html) for more information. |
| 112 |
*/ |
| 113 |
static diplomat::result<ICU4XCodePointMapData8, ICU4XError> load_bidi_class(const ICU4XDataProvider& provider); |
| 114 |
|
| 115 |
/** |
| 116 |
* See the [Rust documentation for `east_asian_width`](https://docs.rs/icu/latest/icu/properties/maps/fn.east_asian_width.html) for more information. |
| 117 |
*/ |
| 118 |
static diplomat::result<ICU4XCodePointMapData8, ICU4XError> load_east_asian_width(const ICU4XDataProvider& provider); |
| 119 |
|
| 120 |
/** |
| 121 |
* See the [Rust documentation for `hangul_syllable_type`](https://docs.rs/icu/latest/icu/properties/maps/fn.hangul_syllable_type.html) for more information. |
| 122 |
*/ |
| 123 |
static diplomat::result<ICU4XCodePointMapData8, ICU4XError> load_hangul_syllable_type(const ICU4XDataProvider& provider); |
| 124 |
|
| 125 |
/** |
| 126 |
* See the [Rust documentation for `indic_syllabic_category`](https://docs.rs/icu/latest/icu/properties/maps/fn.indic_syllabic_category.html) for more information. |
| 127 |
*/ |
| 128 |
static diplomat::result<ICU4XCodePointMapData8, ICU4XError> load_indic_syllabic_category(const ICU4XDataProvider& provider); |
| 129 |
|
| 130 |
/** |
| 131 |
* See the [Rust documentation for `line_break`](https://docs.rs/icu/latest/icu/properties/maps/fn.line_break.html) for more information. |
| 132 |
*/ |
| 133 |
static diplomat::result<ICU4XCodePointMapData8, ICU4XError> load_line_break(const ICU4XDataProvider& provider); |
| 134 |
|
| 135 |
/** |
| 136 |
* See the [Rust documentation for `grapheme_cluster_break`](https://docs.rs/icu/latest/icu/properties/maps/fn.grapheme_cluster_break.html) for more information. |
| 137 |
*/ |
| 138 |
static diplomat::result<ICU4XCodePointMapData8, ICU4XError> try_grapheme_cluster_break(const ICU4XDataProvider& provider); |
| 139 |
|
| 140 |
/** |
| 141 |
* See the [Rust documentation for `word_break`](https://docs.rs/icu/latest/icu/properties/maps/fn.word_break.html) for more information. |
| 142 |
*/ |
| 143 |
static diplomat::result<ICU4XCodePointMapData8, ICU4XError> load_word_break(const ICU4XDataProvider& provider); |
| 144 |
|
| 145 |
/** |
| 146 |
* See the [Rust documentation for `sentence_break`](https://docs.rs/icu/latest/icu/properties/maps/fn.sentence_break.html) for more information. |
| 147 |
*/ |
| 148 |
static diplomat::result<ICU4XCodePointMapData8, ICU4XError> load_sentence_break(const ICU4XDataProvider& provider); |
| 149 |
|
| 150 |
/** |
| 151 |
* See the [Rust documentation for `joining_type`](https://docs.rs/icu/latest/icu/properties/maps/fn.joining_type.html) for more information. |
| 152 |
*/ |
| 153 |
static diplomat::result<ICU4XCodePointMapData8, ICU4XError> load_joining_type(const ICU4XDataProvider& provider); |
| 154 |
inline const capi::ICU4XCodePointMapData8* AsFFI() const { return this->inner.get(); } |
| 155 |
inline capi::ICU4XCodePointMapData8* AsFFIMut() { return this->inner.get(); } |
| 156 |
inline explicit ICU4XCodePointMapData8(capi::ICU4XCodePointMapData8* i) : inner(i) {} |
| 157 |
ICU4XCodePointMapData8() = default; |
| 158 |
ICU4XCodePointMapData8(ICU4XCodePointMapData8&&) noexcept = default; |
| 159 |
ICU4XCodePointMapData8& operator=(ICU4XCodePointMapData8&& other) noexcept = default; |
| 160 |
private: |
| 161 |
std::unique_ptr<capi::ICU4XCodePointMapData8, ICU4XCodePointMapData8Deleter> inner; |
| 162 |
}; |
| 163 |
|
| 164 |
#include "CodePointRangeIterator.hpp" |
| 165 |
#include "ICU4XCodePointSetData.hpp" |
| 166 |
#include "ICU4XDataProvider.hpp" |
| 167 |
|
| 168 |
inline uint8_t ICU4XCodePointMapData8::get(char32_t cp) const { |
| 169 |
return capi::ICU4XCodePointMapData8_get(this->inner.get(), cp); |
| 170 |
} |
| 171 |
inline uint8_t ICU4XCodePointMapData8::get32(uint32_t cp) const { |
| 172 |
return capi::ICU4XCodePointMapData8_get32(this->inner.get(), cp); |
| 173 |
} |
| 174 |
inline uint32_t ICU4XCodePointMapData8::general_category_to_mask(uint8_t gc) { |
| 175 |
return capi::ICU4XCodePointMapData8_general_category_to_mask(gc); |
| 176 |
} |
| 177 |
inline CodePointRangeIterator ICU4XCodePointMapData8::iter_ranges_for_value(uint8_t value) const { |
| 178 |
return CodePointRangeIterator(capi::ICU4XCodePointMapData8_iter_ranges_for_value(this->inner.get(), value)); |
| 179 |
} |
| 180 |
inline CodePointRangeIterator ICU4XCodePointMapData8::iter_ranges_for_value_complemented(uint8_t value) const { |
| 181 |
return CodePointRangeIterator(capi::ICU4XCodePointMapData8_iter_ranges_for_value_complemented(this->inner.get(), value)); |
| 182 |
} |
| 183 |
inline CodePointRangeIterator ICU4XCodePointMapData8::iter_ranges_for_mask(uint32_t mask) const { |
| 184 |
return CodePointRangeIterator(capi::ICU4XCodePointMapData8_iter_ranges_for_mask(this->inner.get(), mask)); |
| 185 |
} |
| 186 |
inline ICU4XCodePointSetData ICU4XCodePointMapData8::get_set_for_value(uint8_t value) const { |
| 187 |
return ICU4XCodePointSetData(capi::ICU4XCodePointMapData8_get_set_for_value(this->inner.get(), value)); |
| 188 |
} |
| 189 |
inline diplomat::result<ICU4XCodePointMapData8, ICU4XError> ICU4XCodePointMapData8::load_general_category(const ICU4XDataProvider& provider) { |
| 190 |
auto diplomat_result_raw_out_value = capi::ICU4XCodePointMapData8_load_general_category(provider.AsFFI()); |
| 191 |
diplomat::result<ICU4XCodePointMapData8, ICU4XError> diplomat_result_out_value; |
| 192 |
if (diplomat_result_raw_out_value.is_ok) { |
| 193 |
diplomat_result_out_value = diplomat::Ok<ICU4XCodePointMapData8>(ICU4XCodePointMapData8(diplomat_result_raw_out_value.ok)); |
| 194 |
} else { |
| 195 |
diplomat_result_out_value = diplomat::Err<ICU4XError>(static_cast<ICU4XError>(diplomat_result_raw_out_value.err)); |
| 196 |
} |
| 197 |
return diplomat_result_out_value; |
| 198 |
} |
| 199 |
inline diplomat::result<ICU4XCodePointMapData8, ICU4XError> ICU4XCodePointMapData8::load_bidi_class(const ICU4XDataProvider& provider) { |
| 200 |
auto diplomat_result_raw_out_value = capi::ICU4XCodePointMapData8_load_bidi_class(provider.AsFFI()); |
| 201 |
diplomat::result<ICU4XCodePointMapData8, ICU4XError> diplomat_result_out_value; |
| 202 |
if (diplomat_result_raw_out_value.is_ok) { |
| 203 |
diplomat_result_out_value = diplomat::Ok<ICU4XCodePointMapData8>(ICU4XCodePointMapData8(diplomat_result_raw_out_value.ok)); |
| 204 |
} else { |
| 205 |
diplomat_result_out_value = diplomat::Err<ICU4XError>(static_cast<ICU4XError>(diplomat_result_raw_out_value.err)); |
| 206 |
} |
| 207 |
return diplomat_result_out_value; |
| 208 |
} |
| 209 |
inline diplomat::result<ICU4XCodePointMapData8, ICU4XError> ICU4XCodePointMapData8::load_east_asian_width(const ICU4XDataProvider& provider) { |
| 210 |
auto diplomat_result_raw_out_value = capi::ICU4XCodePointMapData8_load_east_asian_width(provider.AsFFI()); |
| 211 |
diplomat::result<ICU4XCodePointMapData8, ICU4XError> diplomat_result_out_value; |
| 212 |
if (diplomat_result_raw_out_value.is_ok) { |
| 213 |
diplomat_result_out_value = diplomat::Ok<ICU4XCodePointMapData8>(ICU4XCodePointMapData8(diplomat_result_raw_out_value.ok)); |
| 214 |
} else { |
| 215 |
diplomat_result_out_value = diplomat::Err<ICU4XError>(static_cast<ICU4XError>(diplomat_result_raw_out_value.err)); |
| 216 |
} |
| 217 |
return diplomat_result_out_value; |
| 218 |
} |
| 219 |
inline diplomat::result<ICU4XCodePointMapData8, ICU4XError> ICU4XCodePointMapData8::load_hangul_syllable_type(const ICU4XDataProvider& provider) { |
| 220 |
auto diplomat_result_raw_out_value = capi::ICU4XCodePointMapData8_load_hangul_syllable_type(provider.AsFFI()); |
| 221 |
diplomat::result<ICU4XCodePointMapData8, ICU4XError> diplomat_result_out_value; |
| 222 |
if (diplomat_result_raw_out_value.is_ok) { |
| 223 |
diplomat_result_out_value = diplomat::Ok<ICU4XCodePointMapData8>(ICU4XCodePointMapData8(diplomat_result_raw_out_value.ok)); |
| 224 |
} else { |
| 225 |
diplomat_result_out_value = diplomat::Err<ICU4XError>(static_cast<ICU4XError>(diplomat_result_raw_out_value.err)); |
| 226 |
} |
| 227 |
return diplomat_result_out_value; |
| 228 |
} |
| 229 |
inline diplomat::result<ICU4XCodePointMapData8, ICU4XError> ICU4XCodePointMapData8::load_indic_syllabic_category(const ICU4XDataProvider& provider) { |
| 230 |
auto diplomat_result_raw_out_value = capi::ICU4XCodePointMapData8_load_indic_syllabic_category(provider.AsFFI()); |
| 231 |
diplomat::result<ICU4XCodePointMapData8, ICU4XError> diplomat_result_out_value; |
| 232 |
if (diplomat_result_raw_out_value.is_ok) { |
| 233 |
diplomat_result_out_value = diplomat::Ok<ICU4XCodePointMapData8>(ICU4XCodePointMapData8(diplomat_result_raw_out_value.ok)); |
| 234 |
} else { |
| 235 |
diplomat_result_out_value = diplomat::Err<ICU4XError>(static_cast<ICU4XError>(diplomat_result_raw_out_value.err)); |
| 236 |
} |
| 237 |
return diplomat_result_out_value; |
| 238 |
} |
| 239 |
inline diplomat::result<ICU4XCodePointMapData8, ICU4XError> ICU4XCodePointMapData8::load_line_break(const ICU4XDataProvider& provider) { |
| 240 |
auto diplomat_result_raw_out_value = capi::ICU4XCodePointMapData8_load_line_break(provider.AsFFI()); |
| 241 |
diplomat::result<ICU4XCodePointMapData8, ICU4XError> diplomat_result_out_value; |
| 242 |
if (diplomat_result_raw_out_value.is_ok) { |
| 243 |
diplomat_result_out_value = diplomat::Ok<ICU4XCodePointMapData8>(ICU4XCodePointMapData8(diplomat_result_raw_out_value.ok)); |
| 244 |
} else { |
| 245 |
diplomat_result_out_value = diplomat::Err<ICU4XError>(static_cast<ICU4XError>(diplomat_result_raw_out_value.err)); |
| 246 |
} |
| 247 |
return diplomat_result_out_value; |
| 248 |
} |
| 249 |
inline diplomat::result<ICU4XCodePointMapData8, ICU4XError> ICU4XCodePointMapData8::try_grapheme_cluster_break(const ICU4XDataProvider& provider) { |
| 250 |
auto diplomat_result_raw_out_value = capi::ICU4XCodePointMapData8_try_grapheme_cluster_break(provider.AsFFI()); |
| 251 |
diplomat::result<ICU4XCodePointMapData8, ICU4XError> diplomat_result_out_value; |
| 252 |
if (diplomat_result_raw_out_value.is_ok) { |
| 253 |
diplomat_result_out_value = diplomat::Ok<ICU4XCodePointMapData8>(ICU4XCodePointMapData8(diplomat_result_raw_out_value.ok)); |
| 254 |
} else { |
| 255 |
diplomat_result_out_value = diplomat::Err<ICU4XError>(static_cast<ICU4XError>(diplomat_result_raw_out_value.err)); |
| 256 |
} |
| 257 |
return diplomat_result_out_value; |
| 258 |
} |
| 259 |
inline diplomat::result<ICU4XCodePointMapData8, ICU4XError> ICU4XCodePointMapData8::load_word_break(const ICU4XDataProvider& provider) { |
| 260 |
auto diplomat_result_raw_out_value = capi::ICU4XCodePointMapData8_load_word_break(provider.AsFFI()); |
| 261 |
diplomat::result<ICU4XCodePointMapData8, ICU4XError> diplomat_result_out_value; |
| 262 |
if (diplomat_result_raw_out_value.is_ok) { |
| 263 |
diplomat_result_out_value = diplomat::Ok<ICU4XCodePointMapData8>(ICU4XCodePointMapData8(diplomat_result_raw_out_value.ok)); |
| 264 |
} else { |
| 265 |
diplomat_result_out_value = diplomat::Err<ICU4XError>(static_cast<ICU4XError>(diplomat_result_raw_out_value.err)); |
| 266 |
} |
| 267 |
return diplomat_result_out_value; |
| 268 |
} |
| 269 |
inline diplomat::result<ICU4XCodePointMapData8, ICU4XError> ICU4XCodePointMapData8::load_sentence_break(const ICU4XDataProvider& provider) { |
| 270 |
auto diplomat_result_raw_out_value = capi::ICU4XCodePointMapData8_load_sentence_break(provider.AsFFI()); |
| 271 |
diplomat::result<ICU4XCodePointMapData8, ICU4XError> diplomat_result_out_value; |
| 272 |
if (diplomat_result_raw_out_value.is_ok) { |
| 273 |
diplomat_result_out_value = diplomat::Ok<ICU4XCodePointMapData8>(ICU4XCodePointMapData8(diplomat_result_raw_out_value.ok)); |
| 274 |
} else { |
| 275 |
diplomat_result_out_value = diplomat::Err<ICU4XError>(static_cast<ICU4XError>(diplomat_result_raw_out_value.err)); |
| 276 |
} |
| 277 |
return diplomat_result_out_value; |
| 278 |
} |
| 279 |
inline diplomat::result<ICU4XCodePointMapData8, ICU4XError> ICU4XCodePointMapData8::load_joining_type(const ICU4XDataProvider& provider) { |
| 280 |
auto diplomat_result_raw_out_value = capi::ICU4XCodePointMapData8_load_joining_type(provider.AsFFI()); |
| 281 |
diplomat::result<ICU4XCodePointMapData8, ICU4XError> diplomat_result_out_value; |
| 282 |
if (diplomat_result_raw_out_value.is_ok) { |
| 283 |
diplomat_result_out_value = diplomat::Ok<ICU4XCodePointMapData8>(ICU4XCodePointMapData8(diplomat_result_raw_out_value.ok)); |
| 284 |
} else { |
| 285 |
diplomat_result_out_value = diplomat::Err<ICU4XError>(static_cast<ICU4XError>(diplomat_result_raw_out_value.err)); |
| 286 |
} |
| 287 |
return diplomat_result_out_value; |
| 288 |
} |
| 289 |
#endif |