Debian Codegraph @

intl/icu_capi/bindings/cpp/ICU4XCodePointMapData16.hpp

raw
1 #ifndef ICU4XCodePointMapData16_HPP
2 #define ICU4XCodePointMapData16_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 "ICU4XCodePointMapData16.h"
13
14 class CodePointRangeIterator;
15 class ICU4XCodePointSetData;
16 class ICU4XDataProvider;
17 class ICU4XCodePointMapData16;
18 #include "ICU4XError.hpp"
19
20 /**
21 * A destruction policy for using ICU4XCodePointMapData16 with std::unique_ptr.
22 */
23 struct ICU4XCodePointMapData16Deleter {
24 void operator()(capi::ICU4XCodePointMapData16* l) const noexcept {
25 capi::ICU4XCodePointMapData16_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 16 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 ICU4XCodePointMapData16 {
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 uint16_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 uint16_t get32(uint32_t cp) const;
54
55 /**
56 * Produces an iterator over ranges of code points that map to `value`
57 *
58 * 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.
59 *
60 * Lifetimes: `this` must live at least as long as the output.
61 */
62 CodePointRangeIterator iter_ranges_for_value(uint16_t value) const;
63
64 /**
65 * Produces an iterator over ranges of code points that do not map to `value`
66 *
67 * 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.
68 *
69 * Lifetimes: `this` must live at least as long as the output.
70 */
71 CodePointRangeIterator iter_ranges_for_value_complemented(uint16_t value) const;
72
73 /**
74 * Gets a [`ICU4XCodePointSetData`] representing all entries in this map that map to the given value
75 *
76 * 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.
77 */
78 ICU4XCodePointSetData get_set_for_value(uint16_t value) const;
79
80 /**
81 * See the [Rust documentation for `script`](https://docs.rs/icu/latest/icu/properties/maps/fn.script.html) for more information.
82 */
83 static diplomat::result<ICU4XCodePointMapData16, ICU4XError> load_script(const ICU4XDataProvider& provider);
84 inline const capi::ICU4XCodePointMapData16* AsFFI() const { return this->inner.get(); }
85 inline capi::ICU4XCodePointMapData16* AsFFIMut() { return this->inner.get(); }
86 inline explicit ICU4XCodePointMapData16(capi::ICU4XCodePointMapData16* i) : inner(i) {}
87 ICU4XCodePointMapData16() = default;
88 ICU4XCodePointMapData16(ICU4XCodePointMapData16&&) noexcept = default;
89 ICU4XCodePointMapData16& operator=(ICU4XCodePointMapData16&& other) noexcept = default;
90 private:
91 std::unique_ptr<capi::ICU4XCodePointMapData16, ICU4XCodePointMapData16Deleter> inner;
92 };
93
94 #include "CodePointRangeIterator.hpp"
95 #include "ICU4XCodePointSetData.hpp"
96 #include "ICU4XDataProvider.hpp"
97
98 inline uint16_t ICU4XCodePointMapData16::get(char32_t cp) const {
99 return capi::ICU4XCodePointMapData16_get(this->inner.get(), cp);
100 }
101 inline uint16_t ICU4XCodePointMapData16::get32(uint32_t cp) const {
102 return capi::ICU4XCodePointMapData16_get32(this->inner.get(), cp);
103 }
104 inline CodePointRangeIterator ICU4XCodePointMapData16::iter_ranges_for_value(uint16_t value) const {
105 return CodePointRangeIterator(capi::ICU4XCodePointMapData16_iter_ranges_for_value(this->inner.get(), value));
106 }
107 inline CodePointRangeIterator ICU4XCodePointMapData16::iter_ranges_for_value_complemented(uint16_t value) const {
108 return CodePointRangeIterator(capi::ICU4XCodePointMapData16_iter_ranges_for_value_complemented(this->inner.get(), value));
109 }
110 inline ICU4XCodePointSetData ICU4XCodePointMapData16::get_set_for_value(uint16_t value) const {
111 return ICU4XCodePointSetData(capi::ICU4XCodePointMapData16_get_set_for_value(this->inner.get(), value));
112 }
113 inline diplomat::result<ICU4XCodePointMapData16, ICU4XError> ICU4XCodePointMapData16::load_script(const ICU4XDataProvider& provider) {
114 auto diplomat_result_raw_out_value = capi::ICU4XCodePointMapData16_load_script(provider.AsFFI());
115 diplomat::result<ICU4XCodePointMapData16, ICU4XError> diplomat_result_out_value;
116 if (diplomat_result_raw_out_value.is_ok) {
117 diplomat_result_out_value = diplomat::Ok<ICU4XCodePointMapData16>(ICU4XCodePointMapData16(diplomat_result_raw_out_value.ok));
118 } else {
119 diplomat_result_out_value = diplomat::Err<ICU4XError>(static_cast<ICU4XError>(diplomat_result_raw_out_value.err));
120 }
121 return diplomat_result_out_value;
122 }
123 #endif