ComposingNormalizer.d.hpp (5347B)
1 #ifndef icu4x_ComposingNormalizer_D_HPP 2 #define icu4x_ComposingNormalizer_D_HPP 3 4 #include <stdio.h> 5 #include <stdint.h> 6 #include <stddef.h> 7 #include <stdbool.h> 8 #include <memory> 9 #include <functional> 10 #include <optional> 11 #include <cstdlib> 12 #include "../diplomat_runtime.hpp" 13 14 namespace icu4x { 15 namespace capi { struct ComposingNormalizer; } 16 class ComposingNormalizer; 17 namespace capi { struct DataProvider; } 18 class DataProvider; 19 class DataError; 20 } 21 22 23 namespace icu4x { 24 namespace capi { 25 struct ComposingNormalizer; 26 } // namespace capi 27 } // namespace 28 29 namespace icu4x { 30 /** 31 * See the [Rust documentation for `ComposingNormalizer`](https://docs.rs/icu/latest/icu/normalizer/struct.ComposingNormalizer.html) for more information. 32 */ 33 class ComposingNormalizer { 34 public: 35 36 /** 37 * Construct a new ComposingNormalizer instance for NFC using compiled data. 38 * 39 * See the [Rust documentation for `new_nfc`](https://docs.rs/icu/latest/icu/normalizer/struct.ComposingNormalizer.html#method.new_nfc) for more information. 40 */ 41 inline static std::unique_ptr<icu4x::ComposingNormalizer> create_nfc(); 42 43 /** 44 * Construct a new ComposingNormalizer instance for NFC using a particular data source. 45 * 46 * See the [Rust documentation for `new_nfc`](https://docs.rs/icu/latest/icu/normalizer/struct.ComposingNormalizer.html#method.new_nfc) for more information. 47 */ 48 inline static diplomat::result<std::unique_ptr<icu4x::ComposingNormalizer>, icu4x::DataError> create_nfc_with_provider(const icu4x::DataProvider& provider); 49 50 /** 51 * Construct a new ComposingNormalizer instance for NFKC using compiled data. 52 * 53 * See the [Rust documentation for `new_nfkc`](https://docs.rs/icu/latest/icu/normalizer/struct.ComposingNormalizer.html#method.new_nfkc) for more information. 54 */ 55 inline static std::unique_ptr<icu4x::ComposingNormalizer> create_nfkc(); 56 57 /** 58 * Construct a new ComposingNormalizer instance for NFKC using a particular data source. 59 * 60 * See the [Rust documentation for `new_nfkc`](https://docs.rs/icu/latest/icu/normalizer/struct.ComposingNormalizer.html#method.new_nfkc) for more information. 61 */ 62 inline static diplomat::result<std::unique_ptr<icu4x::ComposingNormalizer>, icu4x::DataError> create_nfkc_with_provider(const icu4x::DataProvider& provider); 63 64 /** 65 * Normalize a string 66 * 67 * Ill-formed input is treated as if errors had been replaced with REPLACEMENT CHARACTERs according 68 * to the WHATWG Encoding Standard. 69 * 70 * See the [Rust documentation for `normalize_utf8`](https://docs.rs/icu/latest/icu/normalizer/struct.ComposingNormalizerBorrowed.html#method.normalize_utf8) for more information. 71 */ 72 inline std::string normalize(std::string_view s) const; 73 74 /** 75 * Check if a string is normalized 76 * 77 * Ill-formed input is treated as if errors had been replaced with REPLACEMENT CHARACTERs according 78 * to the WHATWG Encoding Standard. 79 * 80 * See the [Rust documentation for `is_normalized_utf8`](https://docs.rs/icu/latest/icu/normalizer/struct.ComposingNormalizerBorrowed.html#method.is_normalized_utf8) for more information. 81 */ 82 inline bool is_normalized(std::string_view s) const; 83 84 /** 85 * Check if a string is normalized 86 * 87 * Ill-formed input is treated as if errors had been replaced with REPLACEMENT CHARACTERs according 88 * to the WHATWG Encoding Standard. 89 * 90 * See the [Rust documentation for `is_normalized_utf16`](https://docs.rs/icu/latest/icu/normalizer/struct.ComposingNormalizerBorrowed.html#method.is_normalized_utf16) for more information. 91 */ 92 inline bool is_normalized16(std::u16string_view s) const; 93 94 /** 95 * Return the index a slice of potentially-invalid UTF-8 is normalized up to 96 * 97 * See the [Rust documentation for `split_normalized_utf8`](https://docs.rs/icu/latest/icu/normalizer/struct.ComposingNormalizerBorrowed.html#method.split_normalized_utf8) for more information. 98 * 99 * See the [Rust documentation for `split_normalized`](https://docs.rs/icu/latest/icu/normalizer/struct.ComposingNormalizerBorrowed.html#method.split_normalized) for more information. 100 */ 101 inline size_t is_normalized_up_to(std::string_view s) const; 102 103 /** 104 * Return the index a slice of potentially-invalid UTF-16 is normalized up to 105 * 106 * See the [Rust documentation for `split_normalized_utf16`](https://docs.rs/icu/latest/icu/normalizer/struct.ComposingNormalizerBorrowed.html#method.split_normalized_utf16) for more information. 107 */ 108 inline size_t is_normalized16_up_to(std::u16string_view s) const; 109 110 inline const icu4x::capi::ComposingNormalizer* AsFFI() const; 111 inline icu4x::capi::ComposingNormalizer* AsFFI(); 112 inline static const icu4x::ComposingNormalizer* FromFFI(const icu4x::capi::ComposingNormalizer* ptr); 113 inline static icu4x::ComposingNormalizer* FromFFI(icu4x::capi::ComposingNormalizer* ptr); 114 inline static void operator delete(void* ptr); 115 private: 116 ComposingNormalizer() = delete; 117 ComposingNormalizer(const icu4x::ComposingNormalizer&) = delete; 118 ComposingNormalizer(icu4x::ComposingNormalizer&&) noexcept = delete; 119 ComposingNormalizer operator=(const icu4x::ComposingNormalizer&) = delete; 120 ComposingNormalizer operator=(icu4x::ComposingNormalizer&&) noexcept = delete; 121 static void operator delete[](void*, size_t) = delete; 122 }; 123 124 } // namespace 125 #endif // icu4x_ComposingNormalizer_D_HPP