Debian Codegraph @

intl/icu_capi/bindings/cpp/ICU4XGeneralCategoryNameToMaskMapper.hpp

raw
1 #ifndef ICU4XGeneralCategoryNameToMaskMapper_HPP
2 #define ICU4XGeneralCategoryNameToMaskMapper_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 "ICU4XGeneralCategoryNameToMaskMapper.h"
13
14 class ICU4XDataProvider;
15 class ICU4XGeneralCategoryNameToMaskMapper;
16 #include "ICU4XError.hpp"
17
18 /**
19 * A destruction policy for using ICU4XGeneralCategoryNameToMaskMapper with std::unique_ptr.
20 */
21 struct ICU4XGeneralCategoryNameToMaskMapperDeleter {
22 void operator()(capi::ICU4XGeneralCategoryNameToMaskMapper* l) const noexcept {
23 capi::ICU4XGeneralCategoryNameToMaskMapper_destroy(l);
24 }
25 };
26
27 /**
28 * A type capable of looking up General Category mask values from a string name.
29 *
30 * See the [Rust documentation for `name_to_enum_mapper`](https://docs.rs/icu/latest/icu/properties/struct.GeneralCategoryGroup.html#method.name_to_enum_mapper) for more information.
31 *
32 * See the [Rust documentation for `PropertyValueNameToEnumMapper`](https://docs.rs/icu/latest/icu/properties/names/struct.PropertyValueNameToEnumMapper.html) for more information.
33 */
34 class ICU4XGeneralCategoryNameToMaskMapper {
35 public:
36
37 /**
38 * Get the mask value matching the given name, using strict matching
39 *
40 * Returns 0 if the name is unknown for this property
41 */
42 uint32_t get_strict(const std::string_view name) const;
43
44 /**
45 * Get the mask value matching the given name, using loose matching
46 *
47 * Returns 0 if the name is unknown for this property
48 */
49 uint32_t get_loose(const std::string_view name) const;
50
51 /**
52 * See the [Rust documentation for `name_to_enum_mapper`](https://docs.rs/icu/latest/icu/properties/struct.GeneralCategoryGroup.html#method.name_to_enum_mapper) for more information.
53 */
54 static diplomat::result<ICU4XGeneralCategoryNameToMaskMapper, ICU4XError> load(const ICU4XDataProvider& provider);
55 inline const capi::ICU4XGeneralCategoryNameToMaskMapper* AsFFI() const { return this->inner.get(); }
56 inline capi::ICU4XGeneralCategoryNameToMaskMapper* AsFFIMut() { return this->inner.get(); }
57 inline explicit ICU4XGeneralCategoryNameToMaskMapper(capi::ICU4XGeneralCategoryNameToMaskMapper* i) : inner(i) {}
58 ICU4XGeneralCategoryNameToMaskMapper() = default;
59 ICU4XGeneralCategoryNameToMaskMapper(ICU4XGeneralCategoryNameToMaskMapper&&) noexcept = default;
60 ICU4XGeneralCategoryNameToMaskMapper& operator=(ICU4XGeneralCategoryNameToMaskMapper&& other) noexcept = default;
61 private:
62 std::unique_ptr<capi::ICU4XGeneralCategoryNameToMaskMapper, ICU4XGeneralCategoryNameToMaskMapperDeleter> inner;
63 };
64
65 #include "ICU4XDataProvider.hpp"
66
67 inline uint32_t ICU4XGeneralCategoryNameToMaskMapper::get_strict(const std::string_view name) const {
68 return capi::ICU4XGeneralCategoryNameToMaskMapper_get_strict(this->inner.get(), name.data(), name.size());
69 }
70 inline uint32_t ICU4XGeneralCategoryNameToMaskMapper::get_loose(const std::string_view name) const {
71 return capi::ICU4XGeneralCategoryNameToMaskMapper_get_loose(this->inner.get(), name.data(), name.size());
72 }
73 inline diplomat::result<ICU4XGeneralCategoryNameToMaskMapper, ICU4XError> ICU4XGeneralCategoryNameToMaskMapper::load(const ICU4XDataProvider& provider) {
74 auto diplomat_result_raw_out_value = capi::ICU4XGeneralCategoryNameToMaskMapper_load(provider.AsFFI());
75 diplomat::result<ICU4XGeneralCategoryNameToMaskMapper, ICU4XError> diplomat_result_out_value;
76 if (diplomat_result_raw_out_value.is_ok) {
77 diplomat_result_out_value = diplomat::Ok<ICU4XGeneralCategoryNameToMaskMapper>(ICU4XGeneralCategoryNameToMaskMapper(diplomat_result_raw_out_value.ok));
78 } else {
79 diplomat_result_out_value = diplomat::Err<ICU4XError>(static_cast<ICU4XError>(diplomat_result_raw_out_value.err));
80 }
81 return diplomat_result_out_value;
82 }
83 #endif