1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
#ifndef icu4x_Locale_D_HPP
#define icu4x_Locale_D_HPP
#include <stdio.h>
#include <stdint.h>
#include <stddef.h>
#include <stdbool.h>
#include <memory>
#include <functional>
#include <optional>
#include <cstdlib>
#include "../diplomat_runtime.hpp"
namespace icu4x {
namespace capi { struct Locale; }
class Locale;
class LocaleParseError;
}
namespace icu4x {
namespace capi {
struct Locale;
} // namespace capi
} // namespace
namespace icu4x {
/**
* An ICU4X Locale, capable of representing strings like `"en-US"`.
*
* See the [Rust documentation for `Locale`](https://docs.rs/icu/2.0.0/icu/locale/struct.Locale.html) for more information.
*/
class Locale {
public:
/**
* Construct an {@link Locale} from an locale identifier.
*
* This will run the complete locale parsing algorithm. If code size and
* performance are critical and the locale is of a known shape (such as
* `aa-BB`) use `create_und`, `set_language`, `set_script`, and `set_region`.
*
* See the [Rust documentation for `try_from_str`](https://docs.rs/icu/2.0.0/icu/locale/struct.Locale.html#method.try_from_str) for more information.
*/
inline static diplomat::result<std::unique_ptr<icu4x::Locale>, icu4x::LocaleParseError> from_string(std::string_view name);
/**
* Construct a unknown {@link Locale} "und".
*
* See the [Rust documentation for `UNKNOWN`](https://docs.rs/icu/2.0.0/icu/locale/struct.Locale.html#associatedconstant.UNKNOWN) for more information.
*/
inline static std::unique_ptr<icu4x::Locale> unknown();
/**
* Clones the {@link Locale}.
*
* See the [Rust documentation for `Locale`](https://docs.rs/icu/2.0.0/icu/locale/struct.Locale.html) for more information.
*/
inline std::unique_ptr<icu4x::Locale> clone() const;
/**
* Returns a string representation of the `LanguageIdentifier` part of
* {@link Locale}.
*
* See the [Rust documentation for `id`](https://docs.rs/icu/2.0.0/icu/locale/struct.Locale.html#structfield.id) for more information.
*/
inline std::string basename() const;
/**
* Returns a string representation of the unicode extension.
*
* See the [Rust documentation for `extensions`](https://docs.rs/icu/2.0.0/icu/locale/struct.Locale.html#structfield.extensions) for more information.
*/
inline std::optional<std::string> get_unicode_extension(std::string_view s) const;
/**
* Set a Unicode extension.
*
* See the [Rust documentation for `extensions`](https://docs.rs/icu/2.0.0/icu/locale/struct.Locale.html#structfield.extensions) for more information.
*/
inline std::optional<std::monostate> set_unicode_extension(std::string_view k, std::string_view v);
/**
* Returns a string representation of {@link Locale} language.
*
* See the [Rust documentation for `id`](https://docs.rs/icu/2.0.0/icu/locale/struct.Locale.html#structfield.id) for more information.
*/
inline std::string language() const;
/**
* Set the language part of the {@link Locale}.
*
* See the [Rust documentation for `try_from_str`](https://docs.rs/icu/2.0.0/icu/locale/struct.Locale.html#method.try_from_str) for more information.
*/
inline diplomat::result<std::monostate, icu4x::LocaleParseError> set_language(std::string_view s);
/**
* Returns a string representation of {@link Locale} region.
*
* See the [Rust documentation for `id`](https://docs.rs/icu/2.0.0/icu/locale/struct.Locale.html#structfield.id) for more information.
*/
inline std::optional<std::string> region() const;
/**
* Set the region part of the {@link Locale}.
*
* See the [Rust documentation for `try_from_str`](https://docs.rs/icu/2.0.0/icu/locale/struct.Locale.html#method.try_from_str) for more information.
*/
inline diplomat::result<std::monostate, icu4x::LocaleParseError> set_region(std::string_view s);
/**
* Returns a string representation of {@link Locale} script.
*
* See the [Rust documentation for `id`](https://docs.rs/icu/2.0.0/icu/locale/struct.Locale.html#structfield.id) for more information.
*/
inline std::optional<std::string> script() const;
/**
* Set the script part of the {@link Locale}. Pass an empty string to remove the script.
*
* See the [Rust documentation for `try_from_str`](https://docs.rs/icu/2.0.0/icu/locale/struct.Locale.html#method.try_from_str) for more information.
*/
inline diplomat::result<std::monostate, icu4x::LocaleParseError> set_script(std::string_view s);
/**
* Normalizes a locale string.
*
* See the [Rust documentation for `normalize`](https://docs.rs/icu/2.0.0/icu/locale/struct.Locale.html#method.normalize) for more information.
*/
inline static diplomat::result<std::string, icu4x::LocaleParseError> normalize(std::string_view s);
/**
* Returns a string representation of {@link Locale}.
*
* See the [Rust documentation for `write_to`](https://docs.rs/icu/2.0.0/icu/locale/struct.Locale.html#method.write_to) for more information.
*/
inline std::string to_string() const;
/**
* See the [Rust documentation for `normalizing_eq`](https://docs.rs/icu/2.0.0/icu/locale/struct.Locale.html#method.normalizing_eq) for more information.
*/
inline bool normalizing_eq(std::string_view other) const;
/**
* See the [Rust documentation for `strict_cmp`](https://docs.rs/icu/2.0.0/icu/locale/struct.Locale.html#method.strict_cmp) for more information.
*/
inline int8_t compare_to_string(std::string_view other) const;
/**
* See the [Rust documentation for `total_cmp`](https://docs.rs/icu/2.0.0/icu/locale/struct.Locale.html#method.total_cmp) for more information.
*/
inline int8_t compare_to(const icu4x::Locale& other) const;
inline bool operator==(const icu4x::Locale& other) const;
inline bool operator!=(const icu4x::Locale& other) const;
inline bool operator<=(const icu4x::Locale& other) const;
inline bool operator>=(const icu4x::Locale& other) const;
inline bool operator<(const icu4x::Locale& other) const;
inline bool operator>(const icu4x::Locale& other) const;
inline const icu4x::capi::Locale* AsFFI() const;
inline icu4x::capi::Locale* AsFFI();
inline static const icu4x::Locale* FromFFI(const icu4x::capi::Locale* ptr);
inline static icu4x::Locale* FromFFI(icu4x::capi::Locale* ptr);
inline static void operator delete(void* ptr);
private:
Locale() = delete;
Locale(const icu4x::Locale&) = delete;
Locale(icu4x::Locale&&) noexcept = delete;
Locale operator=(const icu4x::Locale&) = delete;
Locale operator=(icu4x::Locale&&) noexcept = delete;
static void operator delete[](void*, size_t) = delete;
};
} // namespace
#endif // icu4x_Locale_D_HPP