1#ifndef icu4x_Locale_HPP
2#define icu4x_Locale_HPP
22 typedef struct icu4x_Locale_from_string_mv1_result {
union {icu4x::capi::Locale* ok; icu4x::capi::LocaleParseError err;};
bool is_ok;} icu4x_Locale_from_string_mv1_result;
23 icu4x_Locale_from_string_mv1_result icu4x_Locale_from_string_mv1(diplomat::capi::DiplomatStringView name);
25 icu4x::capi::Locale* icu4x_Locale_unknown_mv1(
void);
27 icu4x::capi::Locale* icu4x_Locale_clone_mv1(
const icu4x::capi::Locale* self);
29 void icu4x_Locale_basename_mv1(
const icu4x::capi::Locale* self, diplomat::capi::DiplomatWrite* write);
31 typedef struct icu4x_Locale_get_unicode_extension_mv1_result {
bool is_ok;} icu4x_Locale_get_unicode_extension_mv1_result;
32 icu4x_Locale_get_unicode_extension_mv1_result icu4x_Locale_get_unicode_extension_mv1(
const icu4x::capi::Locale* self, diplomat::capi::DiplomatStringView s, diplomat::capi::DiplomatWrite* write);
34 typedef struct icu4x_Locale_set_unicode_extension_mv1_result {
bool is_ok;} icu4x_Locale_set_unicode_extension_mv1_result;
35 icu4x_Locale_set_unicode_extension_mv1_result icu4x_Locale_set_unicode_extension_mv1(icu4x::capi::Locale* self, diplomat::capi::DiplomatStringView k, diplomat::capi::DiplomatStringView v);
37 void icu4x_Locale_language_mv1(
const icu4x::capi::Locale* self, diplomat::capi::DiplomatWrite* write);
39 typedef struct icu4x_Locale_set_language_mv1_result {
union { icu4x::capi::LocaleParseError err;};
bool is_ok;} icu4x_Locale_set_language_mv1_result;
40 icu4x_Locale_set_language_mv1_result icu4x_Locale_set_language_mv1(icu4x::capi::Locale* self, diplomat::capi::DiplomatStringView s);
42 typedef struct icu4x_Locale_region_mv1_result {
bool is_ok;} icu4x_Locale_region_mv1_result;
43 icu4x_Locale_region_mv1_result icu4x_Locale_region_mv1(
const icu4x::capi::Locale* self, diplomat::capi::DiplomatWrite* write);
45 typedef struct icu4x_Locale_set_region_mv1_result {
union { icu4x::capi::LocaleParseError err;};
bool is_ok;} icu4x_Locale_set_region_mv1_result;
46 icu4x_Locale_set_region_mv1_result icu4x_Locale_set_region_mv1(icu4x::capi::Locale* self, diplomat::capi::DiplomatStringView s);
48 typedef struct icu4x_Locale_script_mv1_result {
bool is_ok;} icu4x_Locale_script_mv1_result;
49 icu4x_Locale_script_mv1_result icu4x_Locale_script_mv1(
const icu4x::capi::Locale* self, diplomat::capi::DiplomatWrite* write);
51 typedef struct icu4x_Locale_set_script_mv1_result {
union { icu4x::capi::LocaleParseError err;};
bool is_ok;} icu4x_Locale_set_script_mv1_result;
52 icu4x_Locale_set_script_mv1_result icu4x_Locale_set_script_mv1(icu4x::capi::Locale* self, diplomat::capi::DiplomatStringView s);
54 typedef struct icu4x_Locale_normalize_mv1_result {
union { icu4x::capi::LocaleParseError err;};
bool is_ok;} icu4x_Locale_normalize_mv1_result;
55 icu4x_Locale_normalize_mv1_result icu4x_Locale_normalize_mv1(diplomat::capi::DiplomatStringView s, diplomat::capi::DiplomatWrite* write);
57 void icu4x_Locale_to_string_mv1(
const icu4x::capi::Locale* self, diplomat::capi::DiplomatWrite* write);
59 bool icu4x_Locale_normalizing_eq_mv1(
const icu4x::capi::Locale* self, diplomat::capi::DiplomatStringView other);
61 int8_t icu4x_Locale_compare_to_string_mv1(
const icu4x::capi::Locale* self, diplomat::capi::DiplomatStringView other);
63 int8_t icu4x_Locale_compare_to_mv1(
const icu4x::capi::Locale* self,
const icu4x::capi::Locale* other);
65 void icu4x_Locale_destroy_mv1(Locale* self);
72 auto result = icu4x::capi::icu4x_Locale_from_string_mv1({name.data(), name.size()});
77 auto result = icu4x::capi::icu4x_Locale_unknown_mv1();
78 return std::unique_ptr<icu4x::Locale>(icu4x::Locale::FromFFI(result));
82 auto result = icu4x::capi::icu4x_Locale_clone_mv1(this->AsFFI());
83 return std::unique_ptr<icu4x::Locale>(icu4x::Locale::FromFFI(result));
88 diplomat::capi::DiplomatWrite write = diplomat::WriteFromString(output);
89 icu4x::capi::icu4x_Locale_basename_mv1(this->AsFFI(),
96 diplomat::capi::DiplomatWrite write = diplomat::WriteFromString(output);
97 auto result = icu4x::capi::icu4x_Locale_get_unicode_extension_mv1(this->AsFFI(),
100 return result.is_ok ? std::optional<std::string>(std::move(output)) : std::nullopt;
104 auto result = icu4x::capi::icu4x_Locale_set_unicode_extension_mv1(this->AsFFI(),
105 {k.data(), k.size()},
106 {v.data(), v.size()});
107 return result.is_ok ? std::optional<std::monostate>() : std::nullopt;
112 diplomat::capi::DiplomatWrite write = diplomat::WriteFromString(output);
113 icu4x::capi::icu4x_Locale_language_mv1(this->AsFFI(),
119 auto result = icu4x::capi::icu4x_Locale_set_language_mv1(this->AsFFI(),
120 {s.data(), s.size()});
126 diplomat::capi::DiplomatWrite write = diplomat::WriteFromString(output);
127 auto result = icu4x::capi::icu4x_Locale_region_mv1(this->AsFFI(),
129 return result.is_ok ? std::optional<std::string>(std::move(output)) : std::nullopt;
133 auto result = icu4x::capi::icu4x_Locale_set_region_mv1(this->AsFFI(),
134 {s.data(), s.size()});
140 diplomat::capi::DiplomatWrite write = diplomat::WriteFromString(output);
141 auto result = icu4x::capi::icu4x_Locale_script_mv1(this->AsFFI(),
143 return result.is_ok ? std::optional<std::string>(std::move(output)) : std::nullopt;
147 auto result = icu4x::capi::icu4x_Locale_set_script_mv1(this->AsFFI(),
148 {s.data(), s.size()});
154 diplomat::capi::DiplomatWrite write = diplomat::WriteFromString(output);
155 auto result = icu4x::capi::icu4x_Locale_normalize_mv1({s.data(), s.size()},
162 diplomat::capi::DiplomatWrite write = diplomat::WriteFromString(output);
163 icu4x::capi::icu4x_Locale_to_string_mv1(this->AsFFI(),
169 auto result = icu4x::capi::icu4x_Locale_normalizing_eq_mv1(this->AsFFI(),
170 {other.data(), other.size()});
175 auto result = icu4x::capi::icu4x_Locale_compare_to_string_mv1(this->AsFFI(),
176 {other.data(), other.size()});
181 auto result = icu4x::capi::icu4x_Locale_compare_to_mv1(this->AsFFI(),
209inline const icu4x::capi::Locale* icu4x::Locale::AsFFI()
const {
210 return reinterpret_cast<const icu4x::capi::Locale*
>(
this);
213inline icu4x::capi::Locale* icu4x::Locale::AsFFI() {
214 return reinterpret_cast<icu4x::capi::Locale*
>(
this);
217inline const icu4x::Locale* icu4x::Locale::FromFFI(
const icu4x::capi::Locale* ptr) {
218 return reinterpret_cast<const icu4x::Locale*
>(ptr);
221inline icu4x::Locale* icu4x::Locale::FromFFI(icu4x::capi::Locale* ptr) {
222 return reinterpret_cast<icu4x::Locale*
>(ptr);
225inline void icu4x::Locale::operator
delete(
void* ptr) {
226 icu4x::capi::icu4x_Locale_destroy_mv1(
reinterpret_cast<icu4x::capi::Locale*
>(ptr));
Definition diplomat_runtime.hpp:140
bool is_ok() const
Definition diplomat_runtime.hpp:152
Definition LocaleParseError.d.hpp:32
Definition Locale.d.hpp:33
std::optional< std::string > script() const
Definition Locale.hpp:138
int8_t compare_to(const icu4x::Locale &other) const
Definition Locale.hpp:180
diplomat::result< std::monostate, icu4x::LocaleParseError > set_script(std::string_view s)
Definition Locale.hpp:146
std::unique_ptr< icu4x::Locale > clone() const
Definition Locale.hpp:81
diplomat::result< std::monostate, icu4x::LocaleParseError > set_language(std::string_view s)
Definition Locale.hpp:118
diplomat::result< std::monostate, icu4x::LocaleParseError > set_region(std::string_view s)
Definition Locale.hpp:132
std::string basename() const
Definition Locale.hpp:86
bool operator>=(const icu4x::Locale &other) const
Definition Locale.hpp:197
static std::unique_ptr< icu4x::Locale > unknown()
Definition Locale.hpp:76
static diplomat::result< std::unique_ptr< icu4x::Locale >, icu4x::LocaleParseError > from_string(std::string_view name)
Definition Locale.hpp:71
bool operator>(const icu4x::Locale &other) const
Definition Locale.hpp:205
std::string to_string() const
Definition Locale.hpp:160
bool normalizing_eq(std::string_view other) const
Definition Locale.hpp:168
std::optional< std::string > get_unicode_extension(std::string_view s) const
Definition Locale.hpp:94
bool operator<=(const icu4x::Locale &other) const
Definition Locale.hpp:193
bool operator<(const icu4x::Locale &other) const
Definition Locale.hpp:201
std::optional< std::monostate > set_unicode_extension(std::string_view k, std::string_view v)
Definition Locale.hpp:103
bool operator!=(const icu4x::Locale &other) const
Definition Locale.hpp:189
std::optional< std::string > region() const
Definition Locale.hpp:124
bool operator==(const icu4x::Locale &other) const
Definition Locale.hpp:185
std::string language() const
Definition Locale.hpp:110
int8_t compare_to_string(std::string_view other) const
Definition Locale.hpp:174
static diplomat::result< std::string, icu4x::LocaleParseError > normalize(std::string_view s)
Definition Locale.hpp:152
Definition diplomat_runtime.hpp:125
Definition diplomat_runtime.hpp:111