| 1 |
#ifndef ICU4XCustomTimeZone_HPP |
| 2 |
#define ICU4XCustomTimeZone_HPP |
| 3 |
#include <stdint.h> |
| 4 |
#include <stddef.h> |
| 5 |
#include <stdbool.h> |
| 6 |
#include <algorithm> |
| 7 |
#include <memory> |
| 8 |
#include <variant> |
| 9 |
#include <optional> |
| 10 |
#include "diplomat_runtime.hpp" |
| 11 |
|
| 12 |
#include "ICU4XCustomTimeZone.h" |
| 13 |
|
| 14 |
class ICU4XCustomTimeZone; |
| 15 |
#include "ICU4XError.hpp" |
| 16 |
class ICU4XIanaToBcp47Mapper; |
| 17 |
class ICU4XTimeZoneIdMapper; |
| 18 |
class ICU4XMetazoneCalculator; |
| 19 |
class ICU4XIsoDateTime; |
| 20 |
|
| 21 |
/** |
| 22 |
* A destruction policy for using ICU4XCustomTimeZone with std::unique_ptr. |
| 23 |
*/ |
| 24 |
struct ICU4XCustomTimeZoneDeleter { |
| 25 |
void operator()(capi::ICU4XCustomTimeZone* l) const noexcept { |
| 26 |
capi::ICU4XCustomTimeZone_destroy(l); |
| 27 |
} |
| 28 |
}; |
| 29 |
|
| 30 |
/** |
| 31 |
* See the [Rust documentation for `CustomTimeZone`](https://docs.rs/icu/latest/icu/timezone/struct.CustomTimeZone.html) for more information. |
| 32 |
*/ |
| 33 |
class ICU4XCustomTimeZone { |
| 34 |
public: |
| 35 |
|
| 36 |
/** |
| 37 |
* Creates a time zone from an offset string. |
| 38 |
* |
| 39 |
* See the [Rust documentation for `from_str`](https://docs.rs/icu/latest/icu/timezone/struct.CustomTimeZone.html#method.from_str) for more information. |
| 40 |
*/ |
| 41 |
static diplomat::result<ICU4XCustomTimeZone, ICU4XError> create_from_string(const std::string_view s); |
| 42 |
|
| 43 |
/** |
| 44 |
* Creates a time zone with no information. |
| 45 |
* |
| 46 |
* See the [Rust documentation for `new_empty`](https://docs.rs/icu/latest/icu/timezone/struct.CustomTimeZone.html#method.new_empty) for more information. |
| 47 |
*/ |
| 48 |
static ICU4XCustomTimeZone create_empty(); |
| 49 |
|
| 50 |
/** |
| 51 |
* Creates a time zone for UTC. |
| 52 |
* |
| 53 |
* See the [Rust documentation for `utc`](https://docs.rs/icu/latest/icu/timezone/struct.CustomTimeZone.html#method.utc) for more information. |
| 54 |
*/ |
| 55 |
static ICU4XCustomTimeZone create_utc(); |
| 56 |
|
| 57 |
/** |
| 58 |
* Sets the `gmt_offset` field from offset seconds. |
| 59 |
* |
| 60 |
* Errors if the offset seconds are out of range. |
| 61 |
* |
| 62 |
* See the [Rust documentation for `try_from_offset_seconds`](https://docs.rs/icu/latest/icu/timezone/struct.GmtOffset.html#method.try_from_offset_seconds) for more information. |
| 63 |
* |
| 64 |
* Additional information: [1](https://docs.rs/icu/latest/icu/timezone/struct.GmtOffset.html) |
| 65 |
*/ |
| 66 |
diplomat::result<std::monostate, ICU4XError> try_set_gmt_offset_seconds(int32_t offset_seconds); |
| 67 |
|
| 68 |
/** |
| 69 |
* Clears the `gmt_offset` field. |
| 70 |
* |
| 71 |
* See the [Rust documentation for `offset_seconds`](https://docs.rs/icu/latest/icu/timezone/struct.GmtOffset.html#method.offset_seconds) for more information. |
| 72 |
* |
| 73 |
* Additional information: [1](https://docs.rs/icu/latest/icu/timezone/struct.GmtOffset.html) |
| 74 |
*/ |
| 75 |
void clear_gmt_offset(); |
| 76 |
|
| 77 |
/** |
| 78 |
* Returns the value of the `gmt_offset` field as offset seconds. |
| 79 |
* |
| 80 |
* Errors if the `gmt_offset` field is empty. |
| 81 |
* |
| 82 |
* See the [Rust documentation for `offset_seconds`](https://docs.rs/icu/latest/icu/timezone/struct.GmtOffset.html#method.offset_seconds) for more information. |
| 83 |
* |
| 84 |
* Additional information: [1](https://docs.rs/icu/latest/icu/timezone/struct.GmtOffset.html) |
| 85 |
*/ |
| 86 |
diplomat::result<int32_t, ICU4XError> gmt_offset_seconds() const; |
| 87 |
|
| 88 |
/** |
| 89 |
* Returns whether the `gmt_offset` field is positive. |
| 90 |
* |
| 91 |
* Errors if the `gmt_offset` field is empty. |
| 92 |
* |
| 93 |
* See the [Rust documentation for `is_positive`](https://docs.rs/icu/latest/icu/timezone/struct.GmtOffset.html#method.is_positive) for more information. |
| 94 |
*/ |
| 95 |
diplomat::result<bool, ICU4XError> is_gmt_offset_positive() const; |
| 96 |
|
| 97 |
/** |
| 98 |
* Returns whether the `gmt_offset` field is zero. |
| 99 |
* |
| 100 |
* Errors if the `gmt_offset` field is empty (which is not the same as zero). |
| 101 |
* |
| 102 |
* See the [Rust documentation for `is_zero`](https://docs.rs/icu/latest/icu/timezone/struct.GmtOffset.html#method.is_zero) for more information. |
| 103 |
*/ |
| 104 |
diplomat::result<bool, ICU4XError> is_gmt_offset_zero() const; |
| 105 |
|
| 106 |
/** |
| 107 |
* Returns whether the `gmt_offset` field has nonzero minutes. |
| 108 |
* |
| 109 |
* Errors if the `gmt_offset` field is empty. |
| 110 |
* |
| 111 |
* See the [Rust documentation for `has_minutes`](https://docs.rs/icu/latest/icu/timezone/struct.GmtOffset.html#method.has_minutes) for more information. |
| 112 |
*/ |
| 113 |
diplomat::result<bool, ICU4XError> gmt_offset_has_minutes() const; |
| 114 |
|
| 115 |
/** |
| 116 |
* Returns whether the `gmt_offset` field has nonzero seconds. |
| 117 |
* |
| 118 |
* Errors if the `gmt_offset` field is empty. |
| 119 |
* |
| 120 |
* See the [Rust documentation for `has_seconds`](https://docs.rs/icu/latest/icu/timezone/struct.GmtOffset.html#method.has_seconds) for more information. |
| 121 |
*/ |
| 122 |
diplomat::result<bool, ICU4XError> gmt_offset_has_seconds() const; |
| 123 |
|
| 124 |
/** |
| 125 |
* Sets the `time_zone_id` field from a BCP-47 string. |
| 126 |
* |
| 127 |
* Errors if the string is not a valid BCP-47 time zone ID. |
| 128 |
* |
| 129 |
* See the [Rust documentation for `time_zone_id`](https://docs.rs/icu/latest/icu/timezone/struct.CustomTimeZone.html#structfield.time_zone_id) for more information. |
| 130 |
* |
| 131 |
* Additional information: [1](https://docs.rs/icu/latest/icu/timezone/struct.TimeZoneBcp47Id.html) |
| 132 |
*/ |
| 133 |
diplomat::result<std::monostate, ICU4XError> try_set_time_zone_id(const std::string_view id); |
| 134 |
|
| 135 |
/** |
| 136 |
* Sets the `time_zone_id` field from an IANA string by looking up |
| 137 |
* the corresponding BCP-47 string. |
| 138 |
* |
| 139 |
* Errors if the string is not a valid BCP-47 time zone ID. |
| 140 |
* |
| 141 |
* See the [Rust documentation for `get`](https://docs.rs/icu/latest/icu/timezone/struct.IanaToBcp47MapperBorrowed.html#method.get) for more information. |
| 142 |
*/ |
| 143 |
diplomat::result<std::monostate, ICU4XError> try_set_iana_time_zone_id(const ICU4XIanaToBcp47Mapper& mapper, const std::string_view id); |
| 144 |
|
| 145 |
/** |
| 146 |
* Sets the `time_zone_id` field from an IANA string by looking up |
| 147 |
* the corresponding BCP-47 string. |
| 148 |
* |
| 149 |
* Errors if the string is not a valid BCP-47 time zone ID. |
| 150 |
*/ |
| 151 |
diplomat::result<std::monostate, ICU4XError> try_set_iana_time_zone_id_2(const ICU4XTimeZoneIdMapper& mapper, const std::string_view id); |
| 152 |
|
| 153 |
/** |
| 154 |
* Clears the `time_zone_id` field. |
| 155 |
* |
| 156 |
* See the [Rust documentation for `time_zone_id`](https://docs.rs/icu/latest/icu/timezone/struct.CustomTimeZone.html#structfield.time_zone_id) for more information. |
| 157 |
* |
| 158 |
* Additional information: [1](https://docs.rs/icu/latest/icu/timezone/struct.TimeZoneBcp47Id.html) |
| 159 |
*/ |
| 160 |
void clear_time_zone_id(); |
| 161 |
|
| 162 |
/** |
| 163 |
* Writes the value of the `time_zone_id` field as a string. |
| 164 |
* |
| 165 |
* Errors if the `time_zone_id` field is empty. |
| 166 |
* |
| 167 |
* See the [Rust documentation for `time_zone_id`](https://docs.rs/icu/latest/icu/timezone/struct.CustomTimeZone.html#structfield.time_zone_id) for more information. |
| 168 |
* |
| 169 |
* Additional information: [1](https://docs.rs/icu/latest/icu/timezone/struct.TimeZoneBcp47Id.html) |
| 170 |
*/ |
| 171 |
template<typename W> diplomat::result<std::monostate, ICU4XError> time_zone_id_to_writeable(W& write) const; |
| 172 |
|
| 173 |
/** |
| 174 |
* Writes the value of the `time_zone_id` field as a string. |
| 175 |
* |
| 176 |
* Errors if the `time_zone_id` field is empty. |
| 177 |
* |
| 178 |
* See the [Rust documentation for `time_zone_id`](https://docs.rs/icu/latest/icu/timezone/struct.CustomTimeZone.html#structfield.time_zone_id) for more information. |
| 179 |
* |
| 180 |
* Additional information: [1](https://docs.rs/icu/latest/icu/timezone/struct.TimeZoneBcp47Id.html) |
| 181 |
*/ |
| 182 |
diplomat::result<std::string, ICU4XError> time_zone_id() const; |
| 183 |
|
| 184 |
/** |
| 185 |
* Sets the `metazone_id` field from a string. |
| 186 |
* |
| 187 |
* Errors if the string is not a valid BCP-47 metazone ID. |
| 188 |
* |
| 189 |
* See the [Rust documentation for `metazone_id`](https://docs.rs/icu/latest/icu/timezone/struct.CustomTimeZone.html#structfield.metazone_id) for more information. |
| 190 |
* |
| 191 |
* Additional information: [1](https://docs.rs/icu/latest/icu/timezone/struct.MetazoneId.html) |
| 192 |
*/ |
| 193 |
diplomat::result<std::monostate, ICU4XError> try_set_metazone_id(const std::string_view id); |
| 194 |
|
| 195 |
/** |
| 196 |
* Clears the `metazone_id` field. |
| 197 |
* |
| 198 |
* See the [Rust documentation for `metazone_id`](https://docs.rs/icu/latest/icu/timezone/struct.CustomTimeZone.html#structfield.metazone_id) for more information. |
| 199 |
* |
| 200 |
* Additional information: [1](https://docs.rs/icu/latest/icu/timezone/struct.MetazoneId.html) |
| 201 |
*/ |
| 202 |
void clear_metazone_id(); |
| 203 |
|
| 204 |
/** |
| 205 |
* Writes the value of the `metazone_id` field as a string. |
| 206 |
* |
| 207 |
* Errors if the `metazone_id` field is empty. |
| 208 |
* |
| 209 |
* See the [Rust documentation for `metazone_id`](https://docs.rs/icu/latest/icu/timezone/struct.CustomTimeZone.html#structfield.metazone_id) for more information. |
| 210 |
* |
| 211 |
* Additional information: [1](https://docs.rs/icu/latest/icu/timezone/struct.MetazoneId.html) |
| 212 |
*/ |
| 213 |
template<typename W> diplomat::result<std::monostate, ICU4XError> metazone_id_to_writeable(W& write) const; |
| 214 |
|
| 215 |
/** |
| 216 |
* Writes the value of the `metazone_id` field as a string. |
| 217 |
* |
| 218 |
* Errors if the `metazone_id` field is empty. |
| 219 |
* |
| 220 |
* See the [Rust documentation for `metazone_id`](https://docs.rs/icu/latest/icu/timezone/struct.CustomTimeZone.html#structfield.metazone_id) for more information. |
| 221 |
* |
| 222 |
* Additional information: [1](https://docs.rs/icu/latest/icu/timezone/struct.MetazoneId.html) |
| 223 |
*/ |
| 224 |
diplomat::result<std::string, ICU4XError> metazone_id() const; |
| 225 |
|
| 226 |
/** |
| 227 |
* Sets the `zone_variant` field from a string. |
| 228 |
* |
| 229 |
* Errors if the string is not a valid zone variant. |
| 230 |
* |
| 231 |
* See the [Rust documentation for `zone_variant`](https://docs.rs/icu/latest/icu/timezone/struct.CustomTimeZone.html#structfield.zone_variant) for more information. |
| 232 |
* |
| 233 |
* Additional information: [1](https://docs.rs/icu/latest/icu/timezone/struct.ZoneVariant.html) |
| 234 |
*/ |
| 235 |
diplomat::result<std::monostate, ICU4XError> try_set_zone_variant(const std::string_view id); |
| 236 |
|
| 237 |
/** |
| 238 |
* Clears the `zone_variant` field. |
| 239 |
* |
| 240 |
* See the [Rust documentation for `zone_variant`](https://docs.rs/icu/latest/icu/timezone/struct.CustomTimeZone.html#structfield.zone_variant) for more information. |
| 241 |
* |
| 242 |
* Additional information: [1](https://docs.rs/icu/latest/icu/timezone/struct.ZoneVariant.html) |
| 243 |
*/ |
| 244 |
void clear_zone_variant(); |
| 245 |
|
| 246 |
/** |
| 247 |
* Writes the value of the `zone_variant` field as a string. |
| 248 |
* |
| 249 |
* Errors if the `zone_variant` field is empty. |
| 250 |
* |
| 251 |
* See the [Rust documentation for `zone_variant`](https://docs.rs/icu/latest/icu/timezone/struct.CustomTimeZone.html#structfield.zone_variant) for more information. |
| 252 |
* |
| 253 |
* Additional information: [1](https://docs.rs/icu/latest/icu/timezone/struct.ZoneVariant.html) |
| 254 |
*/ |
| 255 |
template<typename W> diplomat::result<std::monostate, ICU4XError> zone_variant_to_writeable(W& write) const; |
| 256 |
|
| 257 |
/** |
| 258 |
* Writes the value of the `zone_variant` field as a string. |
| 259 |
* |
| 260 |
* Errors if the `zone_variant` field is empty. |
| 261 |
* |
| 262 |
* See the [Rust documentation for `zone_variant`](https://docs.rs/icu/latest/icu/timezone/struct.CustomTimeZone.html#structfield.zone_variant) for more information. |
| 263 |
* |
| 264 |
* Additional information: [1](https://docs.rs/icu/latest/icu/timezone/struct.ZoneVariant.html) |
| 265 |
*/ |
| 266 |
diplomat::result<std::string, ICU4XError> zone_variant() const; |
| 267 |
|
| 268 |
/** |
| 269 |
* Sets the `zone_variant` field to "standard" time, which may or may |
| 270 |
* not correspond to a display name with "Standard" in its name. |
| 271 |
* |
| 272 |
* See the [Rust documentation for `standard`](https://docs.rs/icu/latest/icu/timezone/struct.ZoneVariant.html#method.standard) for more information. |
| 273 |
* |
| 274 |
* Additional information: [1](https://docs.rs/icu/latest/icu/timezone/struct.CustomTimeZone.html#structfield.zone_variant) |
| 275 |
*/ |
| 276 |
void set_standard_time(); |
| 277 |
|
| 278 |
/** |
| 279 |
* Sets the `zone_variant` field to "daylight" time, which may or may |
| 280 |
* not correspond to a display name with "Daylight" in its name. |
| 281 |
* |
| 282 |
* See the [Rust documentation for `daylight`](https://docs.rs/icu/latest/icu/timezone/struct.ZoneVariant.html#method.daylight) for more information. |
| 283 |
* |
| 284 |
* Additional information: [1](https://docs.rs/icu/latest/icu/timezone/struct.CustomTimeZone.html#structfield.zone_variant) |
| 285 |
*/ |
| 286 |
void set_daylight_time(); |
| 287 |
|
| 288 |
/** |
| 289 |
* Returns whether the `zone_variant` field is standard time. |
| 290 |
* |
| 291 |
* Errors if the `zone_variant` field is empty. |
| 292 |
* |
| 293 |
* See the [Rust documentation for `standard`](https://docs.rs/icu/latest/icu/timezone/struct.ZoneVariant.html#method.standard) for more information. |
| 294 |
* |
| 295 |
* Additional information: [1](https://docs.rs/icu/latest/icu/timezone/struct.CustomTimeZone.html#structfield.zone_variant) |
| 296 |
*/ |
| 297 |
diplomat::result<bool, ICU4XError> is_standard_time() const; |
| 298 |
|
| 299 |
/** |
| 300 |
* Returns whether the `zone_variant` field is daylight time. |
| 301 |
* |
| 302 |
* Errors if the `zone_variant` field is empty. |
| 303 |
* |
| 304 |
* See the [Rust documentation for `daylight`](https://docs.rs/icu/latest/icu/timezone/struct.ZoneVariant.html#method.daylight) for more information. |
| 305 |
* |
| 306 |
* Additional information: [1](https://docs.rs/icu/latest/icu/timezone/struct.CustomTimeZone.html#structfield.zone_variant) |
| 307 |
*/ |
| 308 |
diplomat::result<bool, ICU4XError> is_daylight_time() const; |
| 309 |
|
| 310 |
/** |
| 311 |
* Sets the metazone based on the time zone and the local timestamp. |
| 312 |
* |
| 313 |
* See the [Rust documentation for `maybe_calculate_metazone`](https://docs.rs/icu/latest/icu/timezone/struct.CustomTimeZone.html#method.maybe_calculate_metazone) for more information. |
| 314 |
* |
| 315 |
* Additional information: [1](https://docs.rs/icu/latest/icu/timezone/struct.MetazoneCalculator.html#method.compute_metazone_from_time_zone) |
| 316 |
*/ |
| 317 |
void maybe_calculate_metazone(const ICU4XMetazoneCalculator& metazone_calculator, const ICU4XIsoDateTime& local_datetime); |
| 318 |
inline const capi::ICU4XCustomTimeZone* AsFFI() const { return this->inner.get(); } |
| 319 |
inline capi::ICU4XCustomTimeZone* AsFFIMut() { return this->inner.get(); } |
| 320 |
inline explicit ICU4XCustomTimeZone(capi::ICU4XCustomTimeZone* i) : inner(i) {} |
| 321 |
ICU4XCustomTimeZone() = default; |
| 322 |
ICU4XCustomTimeZone(ICU4XCustomTimeZone&&) noexcept = default; |
| 323 |
ICU4XCustomTimeZone& operator=(ICU4XCustomTimeZone&& other) noexcept = default; |
| 324 |
private: |
| 325 |
std::unique_ptr<capi::ICU4XCustomTimeZone, ICU4XCustomTimeZoneDeleter> inner; |
| 326 |
}; |
| 327 |
|
| 328 |
#include "ICU4XIanaToBcp47Mapper.hpp" |
| 329 |
#include "ICU4XTimeZoneIdMapper.hpp" |
| 330 |
#include "ICU4XMetazoneCalculator.hpp" |
| 331 |
#include "ICU4XIsoDateTime.hpp" |
| 332 |
|
| 333 |
inline diplomat::result<ICU4XCustomTimeZone, ICU4XError> ICU4XCustomTimeZone::create_from_string(const std::string_view s) { |
| 334 |
auto diplomat_result_raw_out_value = capi::ICU4XCustomTimeZone_create_from_string(s.data(), s.size()); |
| 335 |
diplomat::result<ICU4XCustomTimeZone, ICU4XError> diplomat_result_out_value; |
| 336 |
if (diplomat_result_raw_out_value.is_ok) { |
| 337 |
diplomat_result_out_value = diplomat::Ok<ICU4XCustomTimeZone>(ICU4XCustomTimeZone(diplomat_result_raw_out_value.ok)); |
| 338 |
} else { |
| 339 |
diplomat_result_out_value = diplomat::Err<ICU4XError>(static_cast<ICU4XError>(diplomat_result_raw_out_value.err)); |
| 340 |
} |
| 341 |
return diplomat_result_out_value; |
| 342 |
} |
| 343 |
inline ICU4XCustomTimeZone ICU4XCustomTimeZone::create_empty() { |
| 344 |
return ICU4XCustomTimeZone(capi::ICU4XCustomTimeZone_create_empty()); |
| 345 |
} |
| 346 |
inline ICU4XCustomTimeZone ICU4XCustomTimeZone::create_utc() { |
| 347 |
return ICU4XCustomTimeZone(capi::ICU4XCustomTimeZone_create_utc()); |
| 348 |
} |
| 349 |
inline diplomat::result<std::monostate, ICU4XError> ICU4XCustomTimeZone::try_set_gmt_offset_seconds(int32_t offset_seconds) { |
| 350 |
auto diplomat_result_raw_out_value = capi::ICU4XCustomTimeZone_try_set_gmt_offset_seconds(this->inner.get(), offset_seconds); |
| 351 |
diplomat::result<std::monostate, ICU4XError> diplomat_result_out_value; |
| 352 |
if (diplomat_result_raw_out_value.is_ok) { |
| 353 |
diplomat_result_out_value = diplomat::Ok<std::monostate>(std::monostate()); |
| 354 |
} else { |
| 355 |
diplomat_result_out_value = diplomat::Err<ICU4XError>(static_cast<ICU4XError>(diplomat_result_raw_out_value.err)); |
| 356 |
} |
| 357 |
return diplomat_result_out_value; |
| 358 |
} |
| 359 |
inline void ICU4XCustomTimeZone::clear_gmt_offset() { |
| 360 |
capi::ICU4XCustomTimeZone_clear_gmt_offset(this->inner.get()); |
| 361 |
} |
| 362 |
inline diplomat::result<int32_t, ICU4XError> ICU4XCustomTimeZone::gmt_offset_seconds() const { |
| 363 |
auto diplomat_result_raw_out_value = capi::ICU4XCustomTimeZone_gmt_offset_seconds(this->inner.get()); |
| 364 |
diplomat::result<int32_t, ICU4XError> diplomat_result_out_value; |
| 365 |
if (diplomat_result_raw_out_value.is_ok) { |
| 366 |
diplomat_result_out_value = diplomat::Ok<int32_t>(diplomat_result_raw_out_value.ok); |
| 367 |
} else { |
| 368 |
diplomat_result_out_value = diplomat::Err<ICU4XError>(static_cast<ICU4XError>(diplomat_result_raw_out_value.err)); |
| 369 |
} |
| 370 |
return diplomat_result_out_value; |
| 371 |
} |
| 372 |
inline diplomat::result<bool, ICU4XError> ICU4XCustomTimeZone::is_gmt_offset_positive() const { |
| 373 |
auto diplomat_result_raw_out_value = capi::ICU4XCustomTimeZone_is_gmt_offset_positive(this->inner.get()); |
| 374 |
diplomat::result<bool, ICU4XError> diplomat_result_out_value; |
| 375 |
if (diplomat_result_raw_out_value.is_ok) { |
| 376 |
diplomat_result_out_value = diplomat::Ok<bool>(diplomat_result_raw_out_value.ok); |
| 377 |
} else { |
| 378 |
diplomat_result_out_value = diplomat::Err<ICU4XError>(static_cast<ICU4XError>(diplomat_result_raw_out_value.err)); |
| 379 |
} |
| 380 |
return diplomat_result_out_value; |
| 381 |
} |
| 382 |
inline diplomat::result<bool, ICU4XError> ICU4XCustomTimeZone::is_gmt_offset_zero() const { |
| 383 |
auto diplomat_result_raw_out_value = capi::ICU4XCustomTimeZone_is_gmt_offset_zero(this->inner.get()); |
| 384 |
diplomat::result<bool, ICU4XError> diplomat_result_out_value; |
| 385 |
if (diplomat_result_raw_out_value.is_ok) { |
| 386 |
diplomat_result_out_value = diplomat::Ok<bool>(diplomat_result_raw_out_value.ok); |
| 387 |
} else { |
| 388 |
diplomat_result_out_value = diplomat::Err<ICU4XError>(static_cast<ICU4XError>(diplomat_result_raw_out_value.err)); |
| 389 |
} |
| 390 |
return diplomat_result_out_value; |
| 391 |
} |
| 392 |
inline diplomat::result<bool, ICU4XError> ICU4XCustomTimeZone::gmt_offset_has_minutes() const { |
| 393 |
auto diplomat_result_raw_out_value = capi::ICU4XCustomTimeZone_gmt_offset_has_minutes(this->inner.get()); |
| 394 |
diplomat::result<bool, ICU4XError> diplomat_result_out_value; |
| 395 |
if (diplomat_result_raw_out_value.is_ok) { |
| 396 |
diplomat_result_out_value = diplomat::Ok<bool>(diplomat_result_raw_out_value.ok); |
| 397 |
} else { |
| 398 |
diplomat_result_out_value = diplomat::Err<ICU4XError>(static_cast<ICU4XError>(diplomat_result_raw_out_value.err)); |
| 399 |
} |
| 400 |
return diplomat_result_out_value; |
| 401 |
} |
| 402 |
inline diplomat::result<bool, ICU4XError> ICU4XCustomTimeZone::gmt_offset_has_seconds() const { |
| 403 |
auto diplomat_result_raw_out_value = capi::ICU4XCustomTimeZone_gmt_offset_has_seconds(this->inner.get()); |
| 404 |
diplomat::result<bool, ICU4XError> diplomat_result_out_value; |
| 405 |
if (diplomat_result_raw_out_value.is_ok) { |
| 406 |
diplomat_result_out_value = diplomat::Ok<bool>(diplomat_result_raw_out_value.ok); |
| 407 |
} else { |
| 408 |
diplomat_result_out_value = diplomat::Err<ICU4XError>(static_cast<ICU4XError>(diplomat_result_raw_out_value.err)); |
| 409 |
} |
| 410 |
return diplomat_result_out_value; |
| 411 |
} |
| 412 |
inline diplomat::result<std::monostate, ICU4XError> ICU4XCustomTimeZone::try_set_time_zone_id(const std::string_view id) { |
| 413 |
auto diplomat_result_raw_out_value = capi::ICU4XCustomTimeZone_try_set_time_zone_id(this->inner.get(), id.data(), id.size()); |
| 414 |
diplomat::result<std::monostate, ICU4XError> diplomat_result_out_value; |
| 415 |
if (diplomat_result_raw_out_value.is_ok) { |
| 416 |
diplomat_result_out_value = diplomat::Ok<std::monostate>(std::monostate()); |
| 417 |
} else { |
| 418 |
diplomat_result_out_value = diplomat::Err<ICU4XError>(static_cast<ICU4XError>(diplomat_result_raw_out_value.err)); |
| 419 |
} |
| 420 |
return diplomat_result_out_value; |
| 421 |
} |
| 422 |
inline diplomat::result<std::monostate, ICU4XError> ICU4XCustomTimeZone::try_set_iana_time_zone_id(const ICU4XIanaToBcp47Mapper& mapper, const std::string_view id) { |
| 423 |
auto diplomat_result_raw_out_value = capi::ICU4XCustomTimeZone_try_set_iana_time_zone_id(this->inner.get(), mapper.AsFFI(), id.data(), id.size()); |
| 424 |
diplomat::result<std::monostate, ICU4XError> diplomat_result_out_value; |
| 425 |
if (diplomat_result_raw_out_value.is_ok) { |
| 426 |
diplomat_result_out_value = diplomat::Ok<std::monostate>(std::monostate()); |
| 427 |
} else { |
| 428 |
diplomat_result_out_value = diplomat::Err<ICU4XError>(static_cast<ICU4XError>(diplomat_result_raw_out_value.err)); |
| 429 |
} |
| 430 |
return diplomat_result_out_value; |
| 431 |
} |
| 432 |
inline diplomat::result<std::monostate, ICU4XError> ICU4XCustomTimeZone::try_set_iana_time_zone_id_2(const ICU4XTimeZoneIdMapper& mapper, const std::string_view id) { |
| 433 |
auto diplomat_result_raw_out_value = capi::ICU4XCustomTimeZone_try_set_iana_time_zone_id_2(this->inner.get(), mapper.AsFFI(), id.data(), id.size()); |
| 434 |
diplomat::result<std::monostate, ICU4XError> diplomat_result_out_value; |
| 435 |
if (diplomat_result_raw_out_value.is_ok) { |
| 436 |
diplomat_result_out_value = diplomat::Ok<std::monostate>(std::monostate()); |
| 437 |
} else { |
| 438 |
diplomat_result_out_value = diplomat::Err<ICU4XError>(static_cast<ICU4XError>(diplomat_result_raw_out_value.err)); |
| 439 |
} |
| 440 |
return diplomat_result_out_value; |
| 441 |
} |
| 442 |
inline void ICU4XCustomTimeZone::clear_time_zone_id() { |
| 443 |
capi::ICU4XCustomTimeZone_clear_time_zone_id(this->inner.get()); |
| 444 |
} |
| 445 |
template<typename W> inline diplomat::result<std::monostate, ICU4XError> ICU4XCustomTimeZone::time_zone_id_to_writeable(W& write) const { |
| 446 |
capi::DiplomatWriteable write_writer = diplomat::WriteableTrait<W>::Construct(write); |
| 447 |
auto diplomat_result_raw_out_value = capi::ICU4XCustomTimeZone_time_zone_id(this->inner.get(), &write_writer); |
| 448 |
diplomat::result<std::monostate, ICU4XError> diplomat_result_out_value; |
| 449 |
if (diplomat_result_raw_out_value.is_ok) { |
| 450 |
diplomat_result_out_value = diplomat::Ok<std::monostate>(std::monostate()); |
| 451 |
} else { |
| 452 |
diplomat_result_out_value = diplomat::Err<ICU4XError>(static_cast<ICU4XError>(diplomat_result_raw_out_value.err)); |
| 453 |
} |
| 454 |
return diplomat_result_out_value; |
| 455 |
} |
| 456 |
inline diplomat::result<std::string, ICU4XError> ICU4XCustomTimeZone::time_zone_id() const { |
| 457 |
std::string diplomat_writeable_string; |
| 458 |
capi::DiplomatWriteable diplomat_writeable_out = diplomat::WriteableFromString(diplomat_writeable_string); |
| 459 |
auto diplomat_result_raw_out_value = capi::ICU4XCustomTimeZone_time_zone_id(this->inner.get(), &diplomat_writeable_out); |
| 460 |
diplomat::result<std::monostate, ICU4XError> diplomat_result_out_value; |
| 461 |
if (diplomat_result_raw_out_value.is_ok) { |
| 462 |
diplomat_result_out_value = diplomat::Ok<std::monostate>(std::monostate()); |
| 463 |
} else { |
| 464 |
diplomat_result_out_value = diplomat::Err<ICU4XError>(static_cast<ICU4XError>(diplomat_result_raw_out_value.err)); |
| 465 |
} |
| 466 |
return diplomat_result_out_value.replace_ok(std::move(diplomat_writeable_string)); |
| 467 |
} |
| 468 |
inline diplomat::result<std::monostate, ICU4XError> ICU4XCustomTimeZone::try_set_metazone_id(const std::string_view id) { |
| 469 |
auto diplomat_result_raw_out_value = capi::ICU4XCustomTimeZone_try_set_metazone_id(this->inner.get(), id.data(), id.size()); |
| 470 |
diplomat::result<std::monostate, ICU4XError> diplomat_result_out_value; |
| 471 |
if (diplomat_result_raw_out_value.is_ok) { |
| 472 |
diplomat_result_out_value = diplomat::Ok<std::monostate>(std::monostate()); |
| 473 |
} else { |
| 474 |
diplomat_result_out_value = diplomat::Err<ICU4XError>(static_cast<ICU4XError>(diplomat_result_raw_out_value.err)); |
| 475 |
} |
| 476 |
return diplomat_result_out_value; |
| 477 |
} |
| 478 |
inline void ICU4XCustomTimeZone::clear_metazone_id() { |
| 479 |
capi::ICU4XCustomTimeZone_clear_metazone_id(this->inner.get()); |
| 480 |
} |
| 481 |
template<typename W> inline diplomat::result<std::monostate, ICU4XError> ICU4XCustomTimeZone::metazone_id_to_writeable(W& write) const { |
| 482 |
capi::DiplomatWriteable write_writer = diplomat::WriteableTrait<W>::Construct(write); |
| 483 |
auto diplomat_result_raw_out_value = capi::ICU4XCustomTimeZone_metazone_id(this->inner.get(), &write_writer); |
| 484 |
diplomat::result<std::monostate, ICU4XError> diplomat_result_out_value; |
| 485 |
if (diplomat_result_raw_out_value.is_ok) { |
| 486 |
diplomat_result_out_value = diplomat::Ok<std::monostate>(std::monostate()); |
| 487 |
} else { |
| 488 |
diplomat_result_out_value = diplomat::Err<ICU4XError>(static_cast<ICU4XError>(diplomat_result_raw_out_value.err)); |
| 489 |
} |
| 490 |
return diplomat_result_out_value; |
| 491 |
} |
| 492 |
inline diplomat::result<std::string, ICU4XError> ICU4XCustomTimeZone::metazone_id() const { |
| 493 |
std::string diplomat_writeable_string; |
| 494 |
capi::DiplomatWriteable diplomat_writeable_out = diplomat::WriteableFromString(diplomat_writeable_string); |
| 495 |
auto diplomat_result_raw_out_value = capi::ICU4XCustomTimeZone_metazone_id(this->inner.get(), &diplomat_writeable_out); |
| 496 |
diplomat::result<std::monostate, ICU4XError> diplomat_result_out_value; |
| 497 |
if (diplomat_result_raw_out_value.is_ok) { |
| 498 |
diplomat_result_out_value = diplomat::Ok<std::monostate>(std::monostate()); |
| 499 |
} else { |
| 500 |
diplomat_result_out_value = diplomat::Err<ICU4XError>(static_cast<ICU4XError>(diplomat_result_raw_out_value.err)); |
| 501 |
} |
| 502 |
return diplomat_result_out_value.replace_ok(std::move(diplomat_writeable_string)); |
| 503 |
} |
| 504 |
inline diplomat::result<std::monostate, ICU4XError> ICU4XCustomTimeZone::try_set_zone_variant(const std::string_view id) { |
| 505 |
auto diplomat_result_raw_out_value = capi::ICU4XCustomTimeZone_try_set_zone_variant(this->inner.get(), id.data(), id.size()); |
| 506 |
diplomat::result<std::monostate, ICU4XError> diplomat_result_out_value; |
| 507 |
if (diplomat_result_raw_out_value.is_ok) { |
| 508 |
diplomat_result_out_value = diplomat::Ok<std::monostate>(std::monostate()); |
| 509 |
} else { |
| 510 |
diplomat_result_out_value = diplomat::Err<ICU4XError>(static_cast<ICU4XError>(diplomat_result_raw_out_value.err)); |
| 511 |
} |
| 512 |
return diplomat_result_out_value; |
| 513 |
} |
| 514 |
inline void ICU4XCustomTimeZone::clear_zone_variant() { |
| 515 |
capi::ICU4XCustomTimeZone_clear_zone_variant(this->inner.get()); |
| 516 |
} |
| 517 |
template<typename W> inline diplomat::result<std::monostate, ICU4XError> ICU4XCustomTimeZone::zone_variant_to_writeable(W& write) const { |
| 518 |
capi::DiplomatWriteable write_writer = diplomat::WriteableTrait<W>::Construct(write); |
| 519 |
auto diplomat_result_raw_out_value = capi::ICU4XCustomTimeZone_zone_variant(this->inner.get(), &write_writer); |
| 520 |
diplomat::result<std::monostate, ICU4XError> diplomat_result_out_value; |
| 521 |
if (diplomat_result_raw_out_value.is_ok) { |
| 522 |
diplomat_result_out_value = diplomat::Ok<std::monostate>(std::monostate()); |
| 523 |
} else { |
| 524 |
diplomat_result_out_value = diplomat::Err<ICU4XError>(static_cast<ICU4XError>(diplomat_result_raw_out_value.err)); |
| 525 |
} |
| 526 |
return diplomat_result_out_value; |
| 527 |
} |
| 528 |
inline diplomat::result<std::string, ICU4XError> ICU4XCustomTimeZone::zone_variant() const { |
| 529 |
std::string diplomat_writeable_string; |
| 530 |
capi::DiplomatWriteable diplomat_writeable_out = diplomat::WriteableFromString(diplomat_writeable_string); |
| 531 |
auto diplomat_result_raw_out_value = capi::ICU4XCustomTimeZone_zone_variant(this->inner.get(), &diplomat_writeable_out); |
| 532 |
diplomat::result<std::monostate, ICU4XError> diplomat_result_out_value; |
| 533 |
if (diplomat_result_raw_out_value.is_ok) { |
| 534 |
diplomat_result_out_value = diplomat::Ok<std::monostate>(std::monostate()); |
| 535 |
} else { |
| 536 |
diplomat_result_out_value = diplomat::Err<ICU4XError>(static_cast<ICU4XError>(diplomat_result_raw_out_value.err)); |
| 537 |
} |
| 538 |
return diplomat_result_out_value.replace_ok(std::move(diplomat_writeable_string)); |
| 539 |
} |
| 540 |
inline void ICU4XCustomTimeZone::set_standard_time() { |
| 541 |
capi::ICU4XCustomTimeZone_set_standard_time(this->inner.get()); |
| 542 |
} |
| 543 |
inline void ICU4XCustomTimeZone::set_daylight_time() { |
| 544 |
capi::ICU4XCustomTimeZone_set_daylight_time(this->inner.get()); |
| 545 |
} |
| 546 |
inline diplomat::result<bool, ICU4XError> ICU4XCustomTimeZone::is_standard_time() const { |
| 547 |
auto diplomat_result_raw_out_value = capi::ICU4XCustomTimeZone_is_standard_time(this->inner.get()); |
| 548 |
diplomat::result<bool, ICU4XError> diplomat_result_out_value; |
| 549 |
if (diplomat_result_raw_out_value.is_ok) { |
| 550 |
diplomat_result_out_value = diplomat::Ok<bool>(diplomat_result_raw_out_value.ok); |
| 551 |
} else { |
| 552 |
diplomat_result_out_value = diplomat::Err<ICU4XError>(static_cast<ICU4XError>(diplomat_result_raw_out_value.err)); |
| 553 |
} |
| 554 |
return diplomat_result_out_value; |
| 555 |
} |
| 556 |
inline diplomat::result<bool, ICU4XError> ICU4XCustomTimeZone::is_daylight_time() const { |
| 557 |
auto diplomat_result_raw_out_value = capi::ICU4XCustomTimeZone_is_daylight_time(this->inner.get()); |
| 558 |
diplomat::result<bool, ICU4XError> diplomat_result_out_value; |
| 559 |
if (diplomat_result_raw_out_value.is_ok) { |
| 560 |
diplomat_result_out_value = diplomat::Ok<bool>(diplomat_result_raw_out_value.ok); |
| 561 |
} else { |
| 562 |
diplomat_result_out_value = diplomat::Err<ICU4XError>(static_cast<ICU4XError>(diplomat_result_raw_out_value.err)); |
| 563 |
} |
| 564 |
return diplomat_result_out_value; |
| 565 |
} |
| 566 |
inline void ICU4XCustomTimeZone::maybe_calculate_metazone(const ICU4XMetazoneCalculator& metazone_calculator, const ICU4XIsoDateTime& local_datetime) { |
| 567 |
capi::ICU4XCustomTimeZone_maybe_calculate_metazone(this->inner.get(), metazone_calculator.AsFFI(), local_datetime.AsFFI()); |
| 568 |
} |
| 569 |
#endif |