ICU4X
International Components for Unicode
Loading...
Searching...
No Matches
CaseMapper.hpp
Go to the documentation of this file.
1#ifndef icu4x_CaseMapper_HPP
2#define icu4x_CaseMapper_HPP
3
4#include "CaseMapper.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>
16#include "DataError.hpp"
17#include "DataProvider.hpp"
18#include "Locale.hpp"
20
21
22namespace icu4x {
23namespace capi {
24 extern "C" {
25
26 icu4x::capi::CaseMapper* icu4x_CaseMapper_create_mv1(void);
27
28 typedef struct icu4x_CaseMapper_create_with_provider_mv1_result {union {icu4x::capi::CaseMapper* ok; icu4x::capi::DataError err;}; bool is_ok;} icu4x_CaseMapper_create_with_provider_mv1_result;
29 icu4x_CaseMapper_create_with_provider_mv1_result icu4x_CaseMapper_create_with_provider_mv1(const icu4x::capi::DataProvider* provider);
30
31 void icu4x_CaseMapper_lowercase_mv1(const icu4x::capi::CaseMapper* self, diplomat::capi::DiplomatStringView s, const icu4x::capi::Locale* locale, diplomat::capi::DiplomatWrite* write);
32
33 void icu4x_CaseMapper_uppercase_mv1(const icu4x::capi::CaseMapper* self, diplomat::capi::DiplomatStringView s, const icu4x::capi::Locale* locale, diplomat::capi::DiplomatWrite* write);
34
35 void icu4x_CaseMapper_lowercase_with_compiled_data_mv1(diplomat::capi::DiplomatStringView s, const icu4x::capi::Locale* locale, diplomat::capi::DiplomatWrite* write);
36
37 void icu4x_CaseMapper_uppercase_with_compiled_data_mv1(diplomat::capi::DiplomatStringView s, const icu4x::capi::Locale* locale, diplomat::capi::DiplomatWrite* write);
38
39 void icu4x_CaseMapper_titlecase_segment_with_only_case_data_v1_mv1(const icu4x::capi::CaseMapper* self, diplomat::capi::DiplomatStringView s, const icu4x::capi::Locale* locale, icu4x::capi::TitlecaseOptionsV1 options, diplomat::capi::DiplomatWrite* write);
40
41 void icu4x_CaseMapper_fold_mv1(const icu4x::capi::CaseMapper* self, diplomat::capi::DiplomatStringView s, diplomat::capi::DiplomatWrite* write);
42
43 void icu4x_CaseMapper_fold_turkic_mv1(const icu4x::capi::CaseMapper* self, diplomat::capi::DiplomatStringView s, diplomat::capi::DiplomatWrite* write);
44
45 void icu4x_CaseMapper_add_case_closure_to_mv1(const icu4x::capi::CaseMapper* self, char32_t c, icu4x::capi::CodePointSetBuilder* builder);
46
47 char32_t icu4x_CaseMapper_simple_lowercase_mv1(const icu4x::capi::CaseMapper* self, char32_t ch);
48
49 char32_t icu4x_CaseMapper_simple_uppercase_mv1(const icu4x::capi::CaseMapper* self, char32_t ch);
50
51 char32_t icu4x_CaseMapper_simple_titlecase_mv1(const icu4x::capi::CaseMapper* self, char32_t ch);
52
53 char32_t icu4x_CaseMapper_simple_fold_mv1(const icu4x::capi::CaseMapper* self, char32_t ch);
54
55 char32_t icu4x_CaseMapper_simple_fold_turkic_mv1(const icu4x::capi::CaseMapper* self, char32_t ch);
56
57 void icu4x_CaseMapper_destroy_mv1(CaseMapper* self);
58
59 } // extern "C"
60} // namespace capi
61} // namespace
62
63inline std::unique_ptr<icu4x::CaseMapper> icu4x::CaseMapper::create() {
64 auto result = icu4x::capi::icu4x_CaseMapper_create_mv1();
65 return std::unique_ptr<icu4x::CaseMapper>(icu4x::CaseMapper::FromFFI(result));
66}
67
69 auto result = icu4x::capi::icu4x_CaseMapper_create_with_provider_mv1(provider.AsFFI());
70 return result.is_ok ? diplomat::result<std::unique_ptr<icu4x::CaseMapper>, icu4x::DataError>(diplomat::Ok<std::unique_ptr<icu4x::CaseMapper>>(std::unique_ptr<icu4x::CaseMapper>(icu4x::CaseMapper::FromFFI(result.ok)))) : diplomat::result<std::unique_ptr<icu4x::CaseMapper>, icu4x::DataError>(diplomat::Err<icu4x::DataError>(icu4x::DataError::FromFFI(result.err)));
71}
72
74 if (!diplomat::capi::diplomat_is_str(s.data(), s.size())) {
76 }
77 std::string output;
78 diplomat::capi::DiplomatWrite write = diplomat::WriteFromString(output);
79 icu4x::capi::icu4x_CaseMapper_lowercase_mv1(this->AsFFI(),
80 {s.data(), s.size()},
81 locale.AsFFI(),
82 &write);
83 return diplomat::Ok<std::string>(std::move(output));
84}
85
87 if (!diplomat::capi::diplomat_is_str(s.data(), s.size())) {
89 }
90 std::string output;
91 diplomat::capi::DiplomatWrite write = diplomat::WriteFromString(output);
92 icu4x::capi::icu4x_CaseMapper_uppercase_mv1(this->AsFFI(),
93 {s.data(), s.size()},
94 locale.AsFFI(),
95 &write);
96 return diplomat::Ok<std::string>(std::move(output));
97}
98
100 if (!diplomat::capi::diplomat_is_str(s.data(), s.size())) {
102 }
103 std::string output;
104 diplomat::capi::DiplomatWrite write = diplomat::WriteFromString(output);
105 icu4x::capi::icu4x_CaseMapper_lowercase_with_compiled_data_mv1({s.data(), s.size()},
106 locale.AsFFI(),
107 &write);
108 return diplomat::Ok<std::string>(std::move(output));
109}
110
112 if (!diplomat::capi::diplomat_is_str(s.data(), s.size())) {
114 }
115 std::string output;
116 diplomat::capi::DiplomatWrite write = diplomat::WriteFromString(output);
117 icu4x::capi::icu4x_CaseMapper_uppercase_with_compiled_data_mv1({s.data(), s.size()},
118 locale.AsFFI(),
119 &write);
120 return diplomat::Ok<std::string>(std::move(output));
121}
122
124 if (!diplomat::capi::diplomat_is_str(s.data(), s.size())) {
126 }
127 std::string output;
128 diplomat::capi::DiplomatWrite write = diplomat::WriteFromString(output);
129 icu4x::capi::icu4x_CaseMapper_titlecase_segment_with_only_case_data_v1_mv1(this->AsFFI(),
130 {s.data(), s.size()},
131 locale.AsFFI(),
132 options.AsFFI(),
133 &write);
134 return diplomat::Ok<std::string>(std::move(output));
135}
136
138 if (!diplomat::capi::diplomat_is_str(s.data(), s.size())) {
140 }
141 std::string output;
142 diplomat::capi::DiplomatWrite write = diplomat::WriteFromString(output);
143 icu4x::capi::icu4x_CaseMapper_fold_mv1(this->AsFFI(),
144 {s.data(), s.size()},
145 &write);
146 return diplomat::Ok<std::string>(std::move(output));
147}
148
150 if (!diplomat::capi::diplomat_is_str(s.data(), s.size())) {
152 }
153 std::string output;
154 diplomat::capi::DiplomatWrite write = diplomat::WriteFromString(output);
155 icu4x::capi::icu4x_CaseMapper_fold_turkic_mv1(this->AsFFI(),
156 {s.data(), s.size()},
157 &write);
158 return diplomat::Ok<std::string>(std::move(output));
159}
160
162 icu4x::capi::icu4x_CaseMapper_add_case_closure_to_mv1(this->AsFFI(),
163 c,
164 builder.AsFFI());
165}
166
167inline char32_t icu4x::CaseMapper::simple_lowercase(char32_t ch) const {
168 auto result = icu4x::capi::icu4x_CaseMapper_simple_lowercase_mv1(this->AsFFI(),
169 ch);
170 return result;
171}
172
173inline char32_t icu4x::CaseMapper::simple_uppercase(char32_t ch) const {
174 auto result = icu4x::capi::icu4x_CaseMapper_simple_uppercase_mv1(this->AsFFI(),
175 ch);
176 return result;
177}
178
179inline char32_t icu4x::CaseMapper::simple_titlecase(char32_t ch) const {
180 auto result = icu4x::capi::icu4x_CaseMapper_simple_titlecase_mv1(this->AsFFI(),
181 ch);
182 return result;
183}
184
185inline char32_t icu4x::CaseMapper::simple_fold(char32_t ch) const {
186 auto result = icu4x::capi::icu4x_CaseMapper_simple_fold_mv1(this->AsFFI(),
187 ch);
188 return result;
189}
190
191inline char32_t icu4x::CaseMapper::simple_fold_turkic(char32_t ch) const {
192 auto result = icu4x::capi::icu4x_CaseMapper_simple_fold_turkic_mv1(this->AsFFI(),
193 ch);
194 return result;
195}
196
197inline const icu4x::capi::CaseMapper* icu4x::CaseMapper::AsFFI() const {
198 return reinterpret_cast<const icu4x::capi::CaseMapper*>(this);
199}
200
201inline icu4x::capi::CaseMapper* icu4x::CaseMapper::AsFFI() {
202 return reinterpret_cast<icu4x::capi::CaseMapper*>(this);
203}
204
205inline const icu4x::CaseMapper* icu4x::CaseMapper::FromFFI(const icu4x::capi::CaseMapper* ptr) {
206 return reinterpret_cast<const icu4x::CaseMapper*>(ptr);
207}
208
209inline icu4x::CaseMapper* icu4x::CaseMapper::FromFFI(icu4x::capi::CaseMapper* ptr) {
210 return reinterpret_cast<icu4x::CaseMapper*>(ptr);
211}
212
213inline void icu4x::CaseMapper::operator delete(void* ptr) {
214 icu4x::capi::icu4x_CaseMapper_destroy_mv1(reinterpret_cast<icu4x::capi::CaseMapper*>(ptr));
215}
216
217
218#endif // icu4x_CaseMapper_HPP
Definition diplomat_runtime.hpp:140
static std::unique_ptr< icu4x::CaseMapper > create()
Definition CaseMapper.hpp:63
diplomat::result< std::string, diplomat::Utf8Error > uppercase(std::string_view s, const icu4x::Locale &locale) const
Definition CaseMapper.hpp:86
diplomat::result< std::string, diplomat::Utf8Error > fold_turkic(std::string_view s) const
Definition CaseMapper.hpp:149
char32_t simple_fold(char32_t ch) const
Definition CaseMapper.hpp:185
diplomat::result< std::string, diplomat::Utf8Error > lowercase(std::string_view s, const icu4x::Locale &locale) const
Definition CaseMapper.hpp:73
char32_t simple_titlecase(char32_t ch) const
Definition CaseMapper.hpp:179
void add_case_closure_to(char32_t c, icu4x::CodePointSetBuilder &builder) const
Definition CaseMapper.hpp:161
diplomat::result< std::string, diplomat::Utf8Error > fold(std::string_view s) const
Definition CaseMapper.hpp:137
static diplomat::result< std::string, diplomat::Utf8Error > uppercase_with_compiled_data(std::string_view s, const icu4x::Locale &locale)
Definition CaseMapper.hpp:111
char32_t simple_fold_turkic(char32_t ch) const
Definition CaseMapper.hpp:191
static diplomat::result< std::string, diplomat::Utf8Error > lowercase_with_compiled_data(std::string_view s, const icu4x::Locale &locale)
Definition CaseMapper.hpp:99
char32_t simple_lowercase(char32_t ch) const
Definition CaseMapper.hpp:167
static diplomat::result< std::unique_ptr< icu4x::CaseMapper >, icu4x::DataError > create_with_provider(const icu4x::DataProvider &provider)
Definition CaseMapper.hpp:68
diplomat::result< std::string, diplomat::Utf8Error > titlecase_segment_with_only_case_data_v1(std::string_view s, const icu4x::Locale &locale, icu4x::TitlecaseOptionsV1 options) const
Definition CaseMapper.hpp:123
char32_t simple_uppercase(char32_t ch) const
Definition CaseMapper.hpp:173
Definition CodePointSetBuilder.d.hpp:32
Definition DataError.d.hpp:37
Definition DataProvider.d.hpp:40
Definition Locale.d.hpp:33
Definition Bidi.d.hpp:14
Definition diplomat_runtime.hpp:125
Definition diplomat_runtime.hpp:111
Definition TitlecaseOptionsV1.d.hpp:39