Debian Codegraph @

intl/icu_capi/bindings/cpp/ICU4XCaseMapCloser.hpp

raw
1 #ifndef ICU4XCaseMapCloser_HPP
2 #define ICU4XCaseMapCloser_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 "ICU4XCaseMapCloser.h"
13
14 class ICU4XDataProvider;
15 class ICU4XCaseMapCloser;
16 #include "ICU4XError.hpp"
17 class ICU4XCodePointSetBuilder;
18
19 /**
20 * A destruction policy for using ICU4XCaseMapCloser with std::unique_ptr.
21 */
22 struct ICU4XCaseMapCloserDeleter {
23 void operator()(capi::ICU4XCaseMapCloser* l) const noexcept {
24 capi::ICU4XCaseMapCloser_destroy(l);
25 }
26 };
27
28 /**
29 * See the [Rust documentation for `CaseMapCloser`](https://docs.rs/icu/latest/icu/casemap/struct.CaseMapCloser.html) for more information.
30 */
31 class ICU4XCaseMapCloser {
32 public:
33
34 /**
35 * Construct a new ICU4XCaseMapper instance
36 *
37 * See the [Rust documentation for `new`](https://docs.rs/icu/latest/icu/casemap/struct.CaseMapCloser.html#method.new) for more information.
38 */
39 static diplomat::result<ICU4XCaseMapCloser, ICU4XError> create(const ICU4XDataProvider& provider);
40
41 /**
42 * Adds all simple case mappings and the full case folding for `c` to `builder`.
43 * Also adds special case closure mappings.
44 *
45 * See the [Rust documentation for `add_case_closure_to`](https://docs.rs/icu/latest/icu/casemap/struct.CaseMapCloser.html#method.add_case_closure_to) for more information.
46 */
47 void add_case_closure_to(char32_t c, ICU4XCodePointSetBuilder& builder) const;
48
49 /**
50 * Finds all characters and strings which may casemap to `s` as their full case folding string
51 * and adds them to the set.
52 *
53 * Returns true if the string was found
54 *
55 * See the [Rust documentation for `add_string_case_closure_to`](https://docs.rs/icu/latest/icu/casemap/struct.CaseMapCloser.html#method.add_string_case_closure_to) for more information.
56 */
57 bool add_string_case_closure_to(const std::string_view s, ICU4XCodePointSetBuilder& builder) const;
58 inline const capi::ICU4XCaseMapCloser* AsFFI() const { return this->inner.get(); }
59 inline capi::ICU4XCaseMapCloser* AsFFIMut() { return this->inner.get(); }
60 inline explicit ICU4XCaseMapCloser(capi::ICU4XCaseMapCloser* i) : inner(i) {}
61 ICU4XCaseMapCloser() = default;
62 ICU4XCaseMapCloser(ICU4XCaseMapCloser&&) noexcept = default;
63 ICU4XCaseMapCloser& operator=(ICU4XCaseMapCloser&& other) noexcept = default;
64 private:
65 std::unique_ptr<capi::ICU4XCaseMapCloser, ICU4XCaseMapCloserDeleter> inner;
66 };
67
68 #include "ICU4XDataProvider.hpp"
69 #include "ICU4XCodePointSetBuilder.hpp"
70
71 inline diplomat::result<ICU4XCaseMapCloser, ICU4XError> ICU4XCaseMapCloser::create(const ICU4XDataProvider& provider) {
72 auto diplomat_result_raw_out_value = capi::ICU4XCaseMapCloser_create(provider.AsFFI());
73 diplomat::result<ICU4XCaseMapCloser, ICU4XError> diplomat_result_out_value;
74 if (diplomat_result_raw_out_value.is_ok) {
75 diplomat_result_out_value = diplomat::Ok<ICU4XCaseMapCloser>(ICU4XCaseMapCloser(diplomat_result_raw_out_value.ok));
76 } else {
77 diplomat_result_out_value = diplomat::Err<ICU4XError>(static_cast<ICU4XError>(diplomat_result_raw_out_value.err));
78 }
79 return diplomat_result_out_value;
80 }
81 inline void ICU4XCaseMapCloser::add_case_closure_to(char32_t c, ICU4XCodePointSetBuilder& builder) const {
82 capi::ICU4XCaseMapCloser_add_case_closure_to(this->inner.get(), c, builder.AsFFIMut());
83 }
84 inline bool ICU4XCaseMapCloser::add_string_case_closure_to(const std::string_view s, ICU4XCodePointSetBuilder& builder) const {
85 return capi::ICU4XCaseMapCloser_add_string_case_closure_to(this->inner.get(), s.data(), s.size(), builder.AsFFIMut());
86 }
87 #endif