| 1 |
#ifndef ICU4XWordBreakIteratorUtf16_HPP |
| 2 |
#define ICU4XWordBreakIteratorUtf16_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 "ICU4XWordBreakIteratorUtf16.h" |
| 13 |
|
| 14 |
#include "ICU4XSegmenterWordType.hpp" |
| 15 |
|
| 16 |
/** |
| 17 |
* A destruction policy for using ICU4XWordBreakIteratorUtf16 with std::unique_ptr. |
| 18 |
*/ |
| 19 |
struct ICU4XWordBreakIteratorUtf16Deleter { |
| 20 |
void operator()(capi::ICU4XWordBreakIteratorUtf16* l) const noexcept { |
| 21 |
capi::ICU4XWordBreakIteratorUtf16_destroy(l); |
| 22 |
} |
| 23 |
}; |
| 24 |
|
| 25 |
/** |
| 26 |
* See the [Rust documentation for `WordBreakIterator`](https://docs.rs/icu/latest/icu/segmenter/struct.WordBreakIterator.html) for more information. |
| 27 |
*/ |
| 28 |
class ICU4XWordBreakIteratorUtf16 { |
| 29 |
public: |
| 30 |
|
| 31 |
/** |
| 32 |
* Finds the next breakpoint. Returns -1 if at the end of the string or if the index is |
| 33 |
* out of range of a 32-bit signed integer. |
| 34 |
* |
| 35 |
* See the [Rust documentation for `next`](https://docs.rs/icu/latest/icu/segmenter/struct.WordBreakIterator.html#method.next) for more information. |
| 36 |
*/ |
| 37 |
int32_t next(); |
| 38 |
|
| 39 |
/** |
| 40 |
* Return the status value of break boundary. |
| 41 |
* |
| 42 |
* See the [Rust documentation for `word_type`](https://docs.rs/icu/latest/icu/segmenter/struct.WordBreakIterator.html#method.word_type) for more information. |
| 43 |
*/ |
| 44 |
ICU4XSegmenterWordType word_type() const; |
| 45 |
|
| 46 |
/** |
| 47 |
* Return true when break boundary is word-like such as letter/number/CJK |
| 48 |
* |
| 49 |
* See the [Rust documentation for `is_word_like`](https://docs.rs/icu/latest/icu/segmenter/struct.WordBreakIterator.html#method.is_word_like) for more information. |
| 50 |
*/ |
| 51 |
bool is_word_like() const; |
| 52 |
inline const capi::ICU4XWordBreakIteratorUtf16* AsFFI() const { return this->inner.get(); } |
| 53 |
inline capi::ICU4XWordBreakIteratorUtf16* AsFFIMut() { return this->inner.get(); } |
| 54 |
inline explicit ICU4XWordBreakIteratorUtf16(capi::ICU4XWordBreakIteratorUtf16* i) : inner(i) {} |
| 55 |
ICU4XWordBreakIteratorUtf16() = default; |
| 56 |
ICU4XWordBreakIteratorUtf16(ICU4XWordBreakIteratorUtf16&&) noexcept = default; |
| 57 |
ICU4XWordBreakIteratorUtf16& operator=(ICU4XWordBreakIteratorUtf16&& other) noexcept = default; |
| 58 |
private: |
| 59 |
std::unique_ptr<capi::ICU4XWordBreakIteratorUtf16, ICU4XWordBreakIteratorUtf16Deleter> inner; |
| 60 |
}; |
| 61 |
|
| 62 |
|
| 63 |
inline int32_t ICU4XWordBreakIteratorUtf16::next() { |
| 64 |
return capi::ICU4XWordBreakIteratorUtf16_next(this->inner.get()); |
| 65 |
} |
| 66 |
inline ICU4XSegmenterWordType ICU4XWordBreakIteratorUtf16::word_type() const { |
| 67 |
return static_cast<ICU4XSegmenterWordType>(capi::ICU4XWordBreakIteratorUtf16_word_type(this->inner.get())); |
| 68 |
} |
| 69 |
inline bool ICU4XWordBreakIteratorUtf16::is_word_like() const { |
| 70 |
return capi::ICU4XWordBreakIteratorUtf16_is_word_like(this->inner.get()); |
| 71 |
} |
| 72 |
#endif |