ICU4X
International Components for Unicode
Loading...
Searching...
No Matches
LineSegmenter.hpp
Go to the documentation of this file.
1#ifndef ICU4X_LineSegmenter_HPP
2#define ICU4X_LineSegmenter_HPP
3
4#include "LineSegmenter.d.hpp"
5
6#include <stdio.h>
7#include <stdint.h>
8#include <stddef.h>
9#include <stdbool.h>
10#include <memory>
11#include <functional>
12#include <optional>
13#include <cstdlib>
14#include "DataError.hpp"
15#include "DataProvider.hpp"
20#include "Locale.hpp"
21#include "diplomat_runtime.hpp"
22
23
24namespace icu4x {
25namespace capi {
26 extern "C" {
27
28 icu4x::capi::LineSegmenter* icu4x_LineSegmenter_create_auto_mv1(void);
29
30 icu4x::capi::LineSegmenter* icu4x_LineSegmenter_create_lstm_mv1(void);
31
32 icu4x::capi::LineSegmenter* icu4x_LineSegmenter_create_dictionary_mv1(void);
33
34 icu4x::capi::LineSegmenter* icu4x_LineSegmenter_create_for_non_complex_scripts_mv1(void);
35
36 icu4x::capi::LineSegmenter* icu4x_LineSegmenter_create_auto_with_options_v2_mv1(const icu4x::capi::Locale* content_locale, icu4x::capi::LineBreakOptionsV2 options);
37
38 typedef struct icu4x_LineSegmenter_create_auto_with_options_v2_and_provider_mv1_result {union {icu4x::capi::LineSegmenter* ok; icu4x::capi::DataError err;}; bool is_ok;} icu4x_LineSegmenter_create_auto_with_options_v2_and_provider_mv1_result;
39 icu4x_LineSegmenter_create_auto_with_options_v2_and_provider_mv1_result icu4x_LineSegmenter_create_auto_with_options_v2_and_provider_mv1(const icu4x::capi::DataProvider* provider, const icu4x::capi::Locale* content_locale, icu4x::capi::LineBreakOptionsV2 options);
40
41 icu4x::capi::LineSegmenter* icu4x_LineSegmenter_create_lstm_with_options_v2_mv1(const icu4x::capi::Locale* content_locale, icu4x::capi::LineBreakOptionsV2 options);
42
43 typedef struct icu4x_LineSegmenter_create_lstm_with_options_v2_and_provider_mv1_result {union {icu4x::capi::LineSegmenter* ok; icu4x::capi::DataError err;}; bool is_ok;} icu4x_LineSegmenter_create_lstm_with_options_v2_and_provider_mv1_result;
44 icu4x_LineSegmenter_create_lstm_with_options_v2_and_provider_mv1_result icu4x_LineSegmenter_create_lstm_with_options_v2_and_provider_mv1(const icu4x::capi::DataProvider* provider, const icu4x::capi::Locale* content_locale, icu4x::capi::LineBreakOptionsV2 options);
45
46 icu4x::capi::LineSegmenter* icu4x_LineSegmenter_create_dictionary_with_options_v2_mv1(const icu4x::capi::Locale* content_locale, icu4x::capi::LineBreakOptionsV2 options);
47
48 typedef struct icu4x_LineSegmenter_create_dictionary_with_options_v2_and_provider_mv1_result {union {icu4x::capi::LineSegmenter* ok; icu4x::capi::DataError err;}; bool is_ok;} icu4x_LineSegmenter_create_dictionary_with_options_v2_and_provider_mv1_result;
49 icu4x_LineSegmenter_create_dictionary_with_options_v2_and_provider_mv1_result icu4x_LineSegmenter_create_dictionary_with_options_v2_and_provider_mv1(const icu4x::capi::DataProvider* provider, const icu4x::capi::Locale* content_locale, icu4x::capi::LineBreakOptionsV2 options);
50
51 icu4x::capi::LineSegmenter* icu4x_LineSegmenter_create_for_non_complex_scripts_with_options_v2_mv1(const icu4x::capi::Locale* content_locale, icu4x::capi::LineBreakOptionsV2 options);
52
53 typedef struct icu4x_LineSegmenter_create_for_non_complex_scripts_with_options_v2_and_provider_mv1_result {union {icu4x::capi::LineSegmenter* ok; icu4x::capi::DataError err;}; bool is_ok;} icu4x_LineSegmenter_create_for_non_complex_scripts_with_options_v2_and_provider_mv1_result;
54 icu4x_LineSegmenter_create_for_non_complex_scripts_with_options_v2_and_provider_mv1_result icu4x_LineSegmenter_create_for_non_complex_scripts_with_options_v2_and_provider_mv1(const icu4x::capi::DataProvider* provider, const icu4x::capi::Locale* content_locale, icu4x::capi::LineBreakOptionsV2 options);
55
56 icu4x::capi::LineBreakIteratorUtf8* icu4x_LineSegmenter_segment_utf8_mv1(const icu4x::capi::LineSegmenter* self, icu4x::diplomat::capi::DiplomatStringView input);
57
58 icu4x::capi::LineBreakIteratorUtf16* icu4x_LineSegmenter_segment_utf16_mv1(const icu4x::capi::LineSegmenter* self, icu4x::diplomat::capi::DiplomatString16View input);
59
60 icu4x::capi::LineBreakIteratorLatin1* icu4x_LineSegmenter_segment_latin1_mv1(const icu4x::capi::LineSegmenter* self, icu4x::diplomat::capi::DiplomatU8View input);
61
62 void icu4x_LineSegmenter_destroy_mv1(LineSegmenter* self);
63
64 } // extern "C"
65} // namespace capi
66} // namespace
67
68inline std::unique_ptr<icu4x::LineSegmenter> icu4x::LineSegmenter::create_auto() {
69 auto result = icu4x::capi::icu4x_LineSegmenter_create_auto_mv1();
70 return std::unique_ptr<icu4x::LineSegmenter>(icu4x::LineSegmenter::FromFFI(result));
71}
72
73inline std::unique_ptr<icu4x::LineSegmenter> icu4x::LineSegmenter::create_lstm() {
74 auto result = icu4x::capi::icu4x_LineSegmenter_create_lstm_mv1();
75 return std::unique_ptr<icu4x::LineSegmenter>(icu4x::LineSegmenter::FromFFI(result));
76}
77
78inline std::unique_ptr<icu4x::LineSegmenter> icu4x::LineSegmenter::create_dictionary() {
79 auto result = icu4x::capi::icu4x_LineSegmenter_create_dictionary_mv1();
80 return std::unique_ptr<icu4x::LineSegmenter>(icu4x::LineSegmenter::FromFFI(result));
81}
82
83inline std::unique_ptr<icu4x::LineSegmenter> icu4x::LineSegmenter::create_for_non_complex_scripts() {
84 auto result = icu4x::capi::icu4x_LineSegmenter_create_for_non_complex_scripts_mv1();
85 return std::unique_ptr<icu4x::LineSegmenter>(icu4x::LineSegmenter::FromFFI(result));
86}
87
88inline std::unique_ptr<icu4x::LineSegmenter> icu4x::LineSegmenter::create_auto_with_options_v2(const icu4x::Locale* content_locale, icu4x::LineBreakOptionsV2 options) {
89 auto result = icu4x::capi::icu4x_LineSegmenter_create_auto_with_options_v2_mv1(content_locale ? content_locale->AsFFI() : nullptr,
90 options.AsFFI());
91 return std::unique_ptr<icu4x::LineSegmenter>(icu4x::LineSegmenter::FromFFI(result));
92}
93
95 auto result = icu4x::capi::icu4x_LineSegmenter_create_auto_with_options_v2_and_provider_mv1(provider.AsFFI(),
96 content_locale ? content_locale->AsFFI() : nullptr,
97 options.AsFFI());
99}
100
101inline std::unique_ptr<icu4x::LineSegmenter> icu4x::LineSegmenter::create_lstm_with_options_v2(const icu4x::Locale* content_locale, icu4x::LineBreakOptionsV2 options) {
102 auto result = icu4x::capi::icu4x_LineSegmenter_create_lstm_with_options_v2_mv1(content_locale ? content_locale->AsFFI() : nullptr,
103 options.AsFFI());
104 return std::unique_ptr<icu4x::LineSegmenter>(icu4x::LineSegmenter::FromFFI(result));
105}
106
108 auto result = icu4x::capi::icu4x_LineSegmenter_create_lstm_with_options_v2_and_provider_mv1(provider.AsFFI(),
109 content_locale ? content_locale->AsFFI() : nullptr,
110 options.AsFFI());
112}
113
114inline std::unique_ptr<icu4x::LineSegmenter> icu4x::LineSegmenter::create_dictionary_with_options_v2(const icu4x::Locale* content_locale, icu4x::LineBreakOptionsV2 options) {
115 auto result = icu4x::capi::icu4x_LineSegmenter_create_dictionary_with_options_v2_mv1(content_locale ? content_locale->AsFFI() : nullptr,
116 options.AsFFI());
117 return std::unique_ptr<icu4x::LineSegmenter>(icu4x::LineSegmenter::FromFFI(result));
118}
119
121 auto result = icu4x::capi::icu4x_LineSegmenter_create_dictionary_with_options_v2_and_provider_mv1(provider.AsFFI(),
122 content_locale ? content_locale->AsFFI() : nullptr,
123 options.AsFFI());
125}
126
127inline std::unique_ptr<icu4x::LineSegmenter> icu4x::LineSegmenter::create_for_non_complex_scripts_with_options_v2(const icu4x::Locale* content_locale, icu4x::LineBreakOptionsV2 options) {
128 auto result = icu4x::capi::icu4x_LineSegmenter_create_for_non_complex_scripts_with_options_v2_mv1(content_locale ? content_locale->AsFFI() : nullptr,
129 options.AsFFI());
130 return std::unique_ptr<icu4x::LineSegmenter>(icu4x::LineSegmenter::FromFFI(result));
131}
132
134 auto result = icu4x::capi::icu4x_LineSegmenter_create_for_non_complex_scripts_with_options_v2_and_provider_mv1(provider.AsFFI(),
135 content_locale ? content_locale->AsFFI() : nullptr,
136 options.AsFFI());
138}
139
140inline std::unique_ptr<icu4x::LineBreakIteratorUtf8> icu4x::LineSegmenter::segment(std::string_view input) const {
141 auto result = icu4x::capi::icu4x_LineSegmenter_segment_utf8_mv1(this->AsFFI(),
142 {input.data(), input.size()});
143 return std::unique_ptr<icu4x::LineBreakIteratorUtf8>(icu4x::LineBreakIteratorUtf8::FromFFI(result));
144}
145
146inline std::unique_ptr<icu4x::LineBreakIteratorUtf16> icu4x::LineSegmenter::segment16(std::u16string_view input) const {
147 auto result = icu4x::capi::icu4x_LineSegmenter_segment_utf16_mv1(this->AsFFI(),
148 {input.data(), input.size()});
149 return std::unique_ptr<icu4x::LineBreakIteratorUtf16>(icu4x::LineBreakIteratorUtf16::FromFFI(result));
150}
151
152inline std::unique_ptr<icu4x::LineBreakIteratorLatin1> icu4x::LineSegmenter::segment_latin1(icu4x::diplomat::span<const uint8_t> input) const {
153 auto result = icu4x::capi::icu4x_LineSegmenter_segment_latin1_mv1(this->AsFFI(),
154 {input.data(), input.size()});
155 return std::unique_ptr<icu4x::LineBreakIteratorLatin1>(icu4x::LineBreakIteratorLatin1::FromFFI(result));
156}
157
158inline const icu4x::capi::LineSegmenter* icu4x::LineSegmenter::AsFFI() const {
159 return reinterpret_cast<const icu4x::capi::LineSegmenter*>(this);
160}
161
162inline icu4x::capi::LineSegmenter* icu4x::LineSegmenter::AsFFI() {
163 return reinterpret_cast<icu4x::capi::LineSegmenter*>(this);
164}
165
166inline const icu4x::LineSegmenter* icu4x::LineSegmenter::FromFFI(const icu4x::capi::LineSegmenter* ptr) {
167 return reinterpret_cast<const icu4x::LineSegmenter*>(ptr);
168}
169
170inline icu4x::LineSegmenter* icu4x::LineSegmenter::FromFFI(icu4x::capi::LineSegmenter* ptr) {
171 return reinterpret_cast<icu4x::LineSegmenter*>(ptr);
172}
173
174inline void icu4x::LineSegmenter::operator delete(void* ptr) {
175 icu4x::capi::icu4x_LineSegmenter_destroy_mv1(reinterpret_cast<icu4x::capi::LineSegmenter*>(ptr));
176}
177
178
179#endif // ICU4X_LineSegmenter_HPP
Definition DataError.d.hpp:37
Definition DataProvider.d.hpp:40
static std::unique_ptr< icu4x::LineSegmenter > create_dictionary_with_options_v2(const icu4x::Locale *content_locale, icu4x::LineBreakOptionsV2 options)
Definition LineSegmenter.hpp:114
std::unique_ptr< icu4x::LineBreakIteratorUtf16 > segment16(std::u16string_view input) const
Definition LineSegmenter.hpp:146
std::unique_ptr< icu4x::LineBreakIteratorUtf8 > segment(std::string_view input) const
Definition LineSegmenter.hpp:140
std::unique_ptr< icu4x::LineBreakIteratorLatin1 > segment_latin1(icu4x::diplomat::span< const uint8_t > input) const
Definition LineSegmenter.hpp:152
static std::unique_ptr< icu4x::LineSegmenter > create_auto_with_options_v2(const icu4x::Locale *content_locale, icu4x::LineBreakOptionsV2 options)
Definition LineSegmenter.hpp:88
static icu4x::diplomat::result< std::unique_ptr< icu4x::LineSegmenter >, icu4x::DataError > create_auto_with_options_v2_and_provider(const icu4x::DataProvider &provider, const icu4x::Locale *content_locale, icu4x::LineBreakOptionsV2 options)
Definition LineSegmenter.hpp:94
static std::unique_ptr< icu4x::LineSegmenter > create_lstm_with_options_v2(const icu4x::Locale *content_locale, icu4x::LineBreakOptionsV2 options)
Definition LineSegmenter.hpp:101
static icu4x::diplomat::result< std::unique_ptr< icu4x::LineSegmenter >, icu4x::DataError > create_dictionary_with_options_v2_and_provider(const icu4x::DataProvider &provider, const icu4x::Locale *content_locale, icu4x::LineBreakOptionsV2 options)
Definition LineSegmenter.hpp:120
static icu4x::diplomat::result< std::unique_ptr< icu4x::LineSegmenter >, icu4x::DataError > create_lstm_with_options_v2_and_provider(const icu4x::DataProvider &provider, const icu4x::Locale *content_locale, icu4x::LineBreakOptionsV2 options)
Definition LineSegmenter.hpp:107
static icu4x::diplomat::result< std::unique_ptr< icu4x::LineSegmenter >, icu4x::DataError > create_for_non_complex_scripts_with_options_v2_and_provider(const icu4x::DataProvider &provider, const icu4x::Locale *content_locale, icu4x::LineBreakOptionsV2 options)
Definition LineSegmenter.hpp:133
static std::unique_ptr< icu4x::LineSegmenter > create_dictionary()
Definition LineSegmenter.hpp:78
static std::unique_ptr< icu4x::LineSegmenter > create_lstm()
Definition LineSegmenter.hpp:73
static std::unique_ptr< icu4x::LineSegmenter > create_for_non_complex_scripts_with_options_v2(const icu4x::Locale *content_locale, icu4x::LineBreakOptionsV2 options)
Definition LineSegmenter.hpp:127
static std::unique_ptr< icu4x::LineSegmenter > create_for_non_complex_scripts()
Definition LineSegmenter.hpp:83
static std::unique_ptr< icu4x::LineSegmenter > create_auto()
Definition LineSegmenter.hpp:68
Definition Locale.d.hpp:33
Definition diplomat_runtime.hpp:166
Definition diplomat_runtime.hpp:252
constexpr T * data() const noexcept
Definition diplomat_runtime.hpp:263
constexpr size_t size() const noexcept
Definition diplomat_runtime.hpp:266
Definition Bidi.d.hpp:13
Definition LineBreakOptionsV2.d.hpp:38
Definition diplomat_runtime.hpp:146
Definition diplomat_runtime.hpp:128