ICU4X
International Components for Unicode
Loading...
Searching...
No Matches
GraphemeClusterSegmenter.hpp
Go to the documentation of this file.
1#ifndef icu4x_GraphemeClusterSegmenter_HPP
2#define icu4x_GraphemeClusterSegmenter_HPP
3
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>
15#include "DataError.hpp"
16#include "DataProvider.hpp"
20
21
22namespace icu4x {
23namespace capi {
24 extern "C" {
25
26 icu4x::capi::GraphemeClusterSegmenter* icu4x_GraphemeClusterSegmenter_create_mv1(void);
27
28 typedef struct icu4x_GraphemeClusterSegmenter_create_with_provider_mv1_result {union {icu4x::capi::GraphemeClusterSegmenter* ok; icu4x::capi::DataError err;}; bool is_ok;} icu4x_GraphemeClusterSegmenter_create_with_provider_mv1_result;
29 icu4x_GraphemeClusterSegmenter_create_with_provider_mv1_result icu4x_GraphemeClusterSegmenter_create_with_provider_mv1(const icu4x::capi::DataProvider* provider);
30
31 icu4x::capi::GraphemeClusterBreakIteratorUtf8* icu4x_GraphemeClusterSegmenter_segment_utf8_mv1(const icu4x::capi::GraphemeClusterSegmenter* self, diplomat::capi::DiplomatStringView input);
32
33 icu4x::capi::GraphemeClusterBreakIteratorUtf16* icu4x_GraphemeClusterSegmenter_segment_utf16_mv1(const icu4x::capi::GraphemeClusterSegmenter* self, diplomat::capi::DiplomatString16View input);
34
35 icu4x::capi::GraphemeClusterBreakIteratorLatin1* icu4x_GraphemeClusterSegmenter_segment_latin1_mv1(const icu4x::capi::GraphemeClusterSegmenter* self, diplomat::capi::DiplomatU8View input);
36
37 void icu4x_GraphemeClusterSegmenter_destroy_mv1(GraphemeClusterSegmenter* self);
38
39 } // extern "C"
40} // namespace capi
41} // namespace
42
43inline std::unique_ptr<icu4x::GraphemeClusterSegmenter> icu4x::GraphemeClusterSegmenter::create() {
44 auto result = icu4x::capi::icu4x_GraphemeClusterSegmenter_create_mv1();
45 return std::unique_ptr<icu4x::GraphemeClusterSegmenter>(icu4x::GraphemeClusterSegmenter::FromFFI(result));
46}
47
49 auto result = icu4x::capi::icu4x_GraphemeClusterSegmenter_create_with_provider_mv1(provider.AsFFI());
50 return result.is_ok ? diplomat::result<std::unique_ptr<icu4x::GraphemeClusterSegmenter>, icu4x::DataError>(diplomat::Ok<std::unique_ptr<icu4x::GraphemeClusterSegmenter>>(std::unique_ptr<icu4x::GraphemeClusterSegmenter>(icu4x::GraphemeClusterSegmenter::FromFFI(result.ok)))) : diplomat::result<std::unique_ptr<icu4x::GraphemeClusterSegmenter>, icu4x::DataError>(diplomat::Err<icu4x::DataError>(icu4x::DataError::FromFFI(result.err)));
51}
52
53inline std::unique_ptr<icu4x::GraphemeClusterBreakIteratorUtf8> icu4x::GraphemeClusterSegmenter::segment(std::string_view input) const {
54 auto result = icu4x::capi::icu4x_GraphemeClusterSegmenter_segment_utf8_mv1(this->AsFFI(),
55 {input.data(), input.size()});
56 return std::unique_ptr<icu4x::GraphemeClusterBreakIteratorUtf8>(icu4x::GraphemeClusterBreakIteratorUtf8::FromFFI(result));
57}
58
59inline std::unique_ptr<icu4x::GraphemeClusterBreakIteratorUtf16> icu4x::GraphemeClusterSegmenter::segment16(std::u16string_view input) const {
60 auto result = icu4x::capi::icu4x_GraphemeClusterSegmenter_segment_utf16_mv1(this->AsFFI(),
61 {input.data(), input.size()});
62 return std::unique_ptr<icu4x::GraphemeClusterBreakIteratorUtf16>(icu4x::GraphemeClusterBreakIteratorUtf16::FromFFI(result));
63}
64
65inline std::unique_ptr<icu4x::GraphemeClusterBreakIteratorLatin1> icu4x::GraphemeClusterSegmenter::segment_latin1(diplomat::span<const uint8_t> input) const {
66 auto result = icu4x::capi::icu4x_GraphemeClusterSegmenter_segment_latin1_mv1(this->AsFFI(),
67 {input.data(), input.size()});
68 return std::unique_ptr<icu4x::GraphemeClusterBreakIteratorLatin1>(icu4x::GraphemeClusterBreakIteratorLatin1::FromFFI(result));
69}
70
71inline const icu4x::capi::GraphemeClusterSegmenter* icu4x::GraphemeClusterSegmenter::AsFFI() const {
72 return reinterpret_cast<const icu4x::capi::GraphemeClusterSegmenter*>(this);
73}
74
75inline icu4x::capi::GraphemeClusterSegmenter* icu4x::GraphemeClusterSegmenter::AsFFI() {
76 return reinterpret_cast<icu4x::capi::GraphemeClusterSegmenter*>(this);
77}
78
79inline const icu4x::GraphemeClusterSegmenter* icu4x::GraphemeClusterSegmenter::FromFFI(const icu4x::capi::GraphemeClusterSegmenter* ptr) {
80 return reinterpret_cast<const icu4x::GraphemeClusterSegmenter*>(ptr);
81}
82
83inline icu4x::GraphemeClusterSegmenter* icu4x::GraphemeClusterSegmenter::FromFFI(icu4x::capi::GraphemeClusterSegmenter* ptr) {
84 return reinterpret_cast<icu4x::GraphemeClusterSegmenter*>(ptr);
85}
86
87inline void icu4x::GraphemeClusterSegmenter::operator delete(void* ptr) {
88 icu4x::capi::icu4x_GraphemeClusterSegmenter_destroy_mv1(reinterpret_cast<icu4x::capi::GraphemeClusterSegmenter*>(ptr));
89}
90
91
92#endif // icu4x_GraphemeClusterSegmenter_HPP
Definition diplomat_runtime.hpp:140
Definition diplomat_runtime.hpp:223
constexpr T * data() const noexcept
Definition diplomat_runtime.hpp:234
constexpr size_t size() const noexcept
Definition diplomat_runtime.hpp:237
Definition DataError.d.hpp:37
Definition DataProvider.d.hpp:40
std::unique_ptr< icu4x::GraphemeClusterBreakIteratorLatin1 > segment_latin1(diplomat::span< const uint8_t > input) const
Definition GraphemeClusterSegmenter.hpp:65
static diplomat::result< std::unique_ptr< icu4x::GraphemeClusterSegmenter >, icu4x::DataError > create_with_provider(const icu4x::DataProvider &provider)
Definition GraphemeClusterSegmenter.hpp:48
std::unique_ptr< icu4x::GraphemeClusterBreakIteratorUtf16 > segment16(std::u16string_view input) const
Definition GraphemeClusterSegmenter.hpp:59
std::unique_ptr< icu4x::GraphemeClusterBreakIteratorUtf8 > segment(std::string_view input) const
Definition GraphemeClusterSegmenter.hpp:53
static std::unique_ptr< icu4x::GraphemeClusterSegmenter > create()
Definition GraphemeClusterSegmenter.hpp:43
Definition Bidi.d.hpp:14
Definition diplomat_runtime.hpp:125
Definition diplomat_runtime.hpp:111