SentenceSegmenter.d.hpp (4153B)
1 #ifndef icu4x_SentenceSegmenter_D_HPP 2 #define icu4x_SentenceSegmenter_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 DataProvider; } 16 class DataProvider; 17 namespace capi { struct Locale; } 18 class Locale; 19 namespace capi { struct SentenceBreakIteratorLatin1; } 20 class SentenceBreakIteratorLatin1; 21 namespace capi { struct SentenceBreakIteratorUtf16; } 22 class SentenceBreakIteratorUtf16; 23 namespace capi { struct SentenceBreakIteratorUtf8; } 24 class SentenceBreakIteratorUtf8; 25 namespace capi { struct SentenceSegmenter; } 26 class SentenceSegmenter; 27 class DataError; 28 } 29 30 31 namespace icu4x { 32 namespace capi { 33 struct SentenceSegmenter; 34 } // namespace capi 35 } // namespace 36 37 namespace icu4x { 38 /** 39 * An ICU4X sentence-break segmenter, capable of finding sentence breakpoints in strings. 40 * 41 * See the [Rust documentation for `SentenceSegmenter`](https://docs.rs/icu/latest/icu/segmenter/struct.SentenceSegmenter.html) for more information. 42 */ 43 class SentenceSegmenter { 44 public: 45 46 /** 47 * Construct a [`SentenceSegmenter`] using compiled data. This does not assume any content locale. 48 * 49 * See the [Rust documentation for `new`](https://docs.rs/icu/latest/icu/segmenter/struct.SentenceSegmenter.html#method.new) for more information. 50 */ 51 inline static std::unique_ptr<icu4x::SentenceSegmenter> create(); 52 53 /** 54 * Construct a [`SentenceSegmenter`] for content known to be of a given locale, using compiled data. 55 */ 56 inline static diplomat::result<std::unique_ptr<icu4x::SentenceSegmenter>, icu4x::DataError> create_with_content_locale(const icu4x::Locale& locale); 57 58 /** 59 * Construct a [`SentenceSegmenter`] for content known to be of a given locale, using a particular data source. 60 */ 61 inline static diplomat::result<std::unique_ptr<icu4x::SentenceSegmenter>, icu4x::DataError> create_with_content_locale_and_provider(const icu4x::DataProvider& provider, const icu4x::Locale& locale); 62 63 /** 64 * Segments a string. 65 * 66 * Ill-formed input is treated as if errors had been replaced with REPLACEMENT CHARACTERs according 67 * to the WHATWG Encoding Standard. 68 * 69 * See the [Rust documentation for `segment_utf8`](https://docs.rs/icu/latest/icu/segmenter/struct.SentenceSegmenterBorrowed.html#method.segment_utf8) for more information. 70 */ 71 inline std::unique_ptr<icu4x::SentenceBreakIteratorUtf8> segment(std::string_view input) const; 72 73 /** 74 * Segments a string. 75 * 76 * Ill-formed input is treated as if errors had been replaced with REPLACEMENT CHARACTERs according 77 * to the WHATWG Encoding Standard. 78 * 79 * See the [Rust documentation for `segment_utf16`](https://docs.rs/icu/latest/icu/segmenter/struct.SentenceSegmenterBorrowed.html#method.segment_utf16) for more information. 80 */ 81 inline std::unique_ptr<icu4x::SentenceBreakIteratorUtf16> segment16(std::u16string_view input) const; 82 83 /** 84 * Segments a Latin-1 string. 85 * 86 * See the [Rust documentation for `segment_latin1`](https://docs.rs/icu/latest/icu/segmenter/struct.SentenceSegmenterBorrowed.html#method.segment_latin1) for more information. 87 */ 88 inline std::unique_ptr<icu4x::SentenceBreakIteratorLatin1> segment_latin1(diplomat::span<const uint8_t> input) const; 89 90 inline const icu4x::capi::SentenceSegmenter* AsFFI() const; 91 inline icu4x::capi::SentenceSegmenter* AsFFI(); 92 inline static const icu4x::SentenceSegmenter* FromFFI(const icu4x::capi::SentenceSegmenter* ptr); 93 inline static icu4x::SentenceSegmenter* FromFFI(icu4x::capi::SentenceSegmenter* ptr); 94 inline static void operator delete(void* ptr); 95 private: 96 SentenceSegmenter() = delete; 97 SentenceSegmenter(const icu4x::SentenceSegmenter&) = delete; 98 SentenceSegmenter(icu4x::SentenceSegmenter&&) noexcept = delete; 99 SentenceSegmenter operator=(const icu4x::SentenceSegmenter&) = delete; 100 SentenceSegmenter operator=(icu4x::SentenceSegmenter&&) noexcept = delete; 101 static void operator delete[](void*, size_t) = delete; 102 }; 103 104 } // namespace 105 #endif // icu4x_SentenceSegmenter_D_HPP