ICU4X
International Components for Unicode
Loading...
Searching...
No Matches
ICU4XWeekCalculator.hpp
Go to the documentation of this file.
1#ifndef ICU4XWeekCalculator_HPP
2#define ICU4XWeekCalculator_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 "ICU4XWeekCalculator.h"
13
15class ICU4XLocale;
17#include "ICU4XError.hpp"
18#include "ICU4XIsoWeekday.hpp"
20
24struct ICU4XWeekCalculatorDeleter {
25 void operator()(capi::ICU4XWeekCalculator* l) const noexcept {
26 capi::ICU4XWeekCalculator_destroy(l);
27 }
28};
29
36 public:
37
44
49
56
63 uint8_t min_week_days() const;
64
69 inline const capi::ICU4XWeekCalculator* AsFFI() const { return this->inner.get(); }
70 inline capi::ICU4XWeekCalculator* AsFFIMut() { return this->inner.get(); }
71 inline explicit ICU4XWeekCalculator(capi::ICU4XWeekCalculator* i) : inner(i) {}
74 ICU4XWeekCalculator& operator=(ICU4XWeekCalculator&& other) noexcept = default;
75 private:
76 std::unique_ptr<capi::ICU4XWeekCalculator, ICU4XWeekCalculatorDeleter> inner;
77};
78
79#include "ICU4XDataProvider.hpp"
80#include "ICU4XLocale.hpp"
82
84 auto diplomat_result_raw_out_value = capi::ICU4XWeekCalculator_create(provider.AsFFI(), locale.AsFFI());
86 if (diplomat_result_raw_out_value.is_ok) {
87 diplomat_result_out_value = diplomat::Ok<ICU4XWeekCalculator>(ICU4XWeekCalculator(diplomat_result_raw_out_value.ok));
88 } else {
89 diplomat_result_out_value = diplomat::Err<ICU4XError>(static_cast<ICU4XError>(diplomat_result_raw_out_value.err));
90 }
91 return diplomat_result_out_value;
92}
94 return ICU4XWeekCalculator(capi::ICU4XWeekCalculator_create_from_first_day_of_week_and_min_week_days(static_cast<capi::ICU4XIsoWeekday>(first_weekday), min_week_days));
95}
97 return static_cast<ICU4XIsoWeekday>(capi::ICU4XWeekCalculator_first_weekday(this->inner.get()));
98}
99inline uint8_t ICU4XWeekCalculator::min_week_days() const {
100 return capi::ICU4XWeekCalculator_min_week_days(this->inner.get());
101}
103 capi::ICU4XWeekendContainsDay diplomat_raw_struct_out_value = capi::ICU4XWeekCalculator_weekend(this->inner.get());
104 return ICU4XWeekendContainsDay{ .monday = std::move(diplomat_raw_struct_out_value.monday), .tuesday = std::move(diplomat_raw_struct_out_value.tuesday), .wednesday = std::move(diplomat_raw_struct_out_value.wednesday), .thursday = std::move(diplomat_raw_struct_out_value.thursday), .friday = std::move(diplomat_raw_struct_out_value.friday), .saturday = std::move(diplomat_raw_struct_out_value.saturday), .sunday = std::move(diplomat_raw_struct_out_value.sunday) };
105}
106#endif
ICU4XError
Definition ICU4XError.hpp:23
ICU4XIsoWeekday
Definition ICU4XIsoWeekday.hpp:15
Definition ICU4XDataProvider.hpp:32
Definition ICU4XLocale.hpp:32
Definition ICU4XWeekCalculator.hpp:35
static diplomat::result< ICU4XWeekCalculator, ICU4XError > create(const ICU4XDataProvider &provider, const ICU4XLocale &locale)
Definition ICU4XWeekCalculator.hpp:83
ICU4XIsoWeekday first_weekday() const
Definition ICU4XWeekCalculator.hpp:96
ICU4XWeekCalculator(capi::ICU4XWeekCalculator *i)
Definition ICU4XWeekCalculator.hpp:71
ICU4XWeekCalculator()=default
uint8_t min_week_days() const
Definition ICU4XWeekCalculator.hpp:99
static ICU4XWeekCalculator create_from_first_day_of_week_and_min_week_days(ICU4XIsoWeekday first_weekday, uint8_t min_week_days)
Definition ICU4XWeekCalculator.hpp:93
ICU4XWeekCalculator(ICU4XWeekCalculator &&) noexcept=default
ICU4XWeekendContainsDay weekend() const
Definition ICU4XWeekCalculator.hpp:102
Definition diplomat_runtime.hpp:84
Definition ICU4XWeekendContainsDay.hpp:21
Definition diplomat_runtime.hpp:69
Definition diplomat_runtime.hpp:55