ICU4X
International Components for Unicode
Loading...
Searching...
No Matches
ICU4XBcp47ToIanaMapper.hpp
Go to the documentation of this file.
1#ifndef ICU4XBcp47ToIanaMapper_HPP
2#define ICU4XBcp47ToIanaMapper_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 "ICU4XBcp47ToIanaMapper.h"
13
16#include "ICU4XError.hpp"
17
21struct ICU4XBcp47ToIanaMapperDeleter {
22 void operator()(capi::ICU4XBcp47ToIanaMapper* l) const noexcept {
23 capi::ICU4XBcp47ToIanaMapper_destroy(l);
24 }
25};
26
33 public:
34
39
45 template<typename W> diplomat::result<std::monostate, ICU4XError> get_to_writeable(const std::string_view value, W& write) const;
46
52 diplomat::result<std::string, ICU4XError> get(const std::string_view value) const;
53 inline const capi::ICU4XBcp47ToIanaMapper* AsFFI() const { return this->inner.get(); }
54 inline capi::ICU4XBcp47ToIanaMapper* AsFFIMut() { return this->inner.get(); }
55 inline explicit ICU4XBcp47ToIanaMapper(capi::ICU4XBcp47ToIanaMapper* i) : inner(i) {}
58 ICU4XBcp47ToIanaMapper& operator=(ICU4XBcp47ToIanaMapper&& other) noexcept = default;
59 private:
60 std::unique_ptr<capi::ICU4XBcp47ToIanaMapper, ICU4XBcp47ToIanaMapperDeleter> inner;
61};
62
63#include "ICU4XDataProvider.hpp"
64
66 auto diplomat_result_raw_out_value = capi::ICU4XBcp47ToIanaMapper_create(provider.AsFFI());
68 if (diplomat_result_raw_out_value.is_ok) {
69 diplomat_result_out_value = diplomat::Ok<ICU4XBcp47ToIanaMapper>(ICU4XBcp47ToIanaMapper(diplomat_result_raw_out_value.ok));
70 } else {
71 diplomat_result_out_value = diplomat::Err<ICU4XError>(static_cast<ICU4XError>(diplomat_result_raw_out_value.err));
72 }
73 return diplomat_result_out_value;
74}
75template<typename W> inline diplomat::result<std::monostate, ICU4XError> ICU4XBcp47ToIanaMapper::get_to_writeable(const std::string_view value, W& write) const {
76 capi::DiplomatWriteable write_writer = diplomat::WriteableTrait<W>::Construct(write);
77 auto diplomat_result_raw_out_value = capi::ICU4XBcp47ToIanaMapper_get(this->inner.get(), value.data(), value.size(), &write_writer);
78 diplomat::result<std::monostate, ICU4XError> diplomat_result_out_value;
79 if (diplomat_result_raw_out_value.is_ok) {
80 diplomat_result_out_value = diplomat::Ok<std::monostate>(std::monostate());
81 } else {
82 diplomat_result_out_value = diplomat::Err<ICU4XError>(static_cast<ICU4XError>(diplomat_result_raw_out_value.err));
83 }
84 return diplomat_result_out_value;
85}
87 std::string diplomat_writeable_string;
88 capi::DiplomatWriteable diplomat_writeable_out = diplomat::WriteableFromString(diplomat_writeable_string);
89 auto diplomat_result_raw_out_value = capi::ICU4XBcp47ToIanaMapper_get(this->inner.get(), value.data(), value.size(), &diplomat_writeable_out);
90 diplomat::result<std::monostate, ICU4XError> diplomat_result_out_value;
91 if (diplomat_result_raw_out_value.is_ok) {
92 diplomat_result_out_value = diplomat::Ok<std::monostate>(std::monostate());
93 } else {
94 diplomat_result_out_value = diplomat::Err<ICU4XError>(static_cast<ICU4XError>(diplomat_result_raw_out_value.err));
95 }
96 return diplomat_result_out_value.replace_ok(std::move(diplomat_writeable_string));
97}
98#endif
ICU4XError
Definition ICU4XError.hpp:23
Definition ICU4XBcp47ToIanaMapper.hpp:32
diplomat::result< std::string, ICU4XError > get(const std::string_view value) const
Definition ICU4XBcp47ToIanaMapper.hpp:86
diplomat::result< std::monostate, ICU4XError > get_to_writeable(const std::string_view value, W &write) const
Definition ICU4XBcp47ToIanaMapper.hpp:75
ICU4XBcp47ToIanaMapper(ICU4XBcp47ToIanaMapper &&) noexcept=default
ICU4XBcp47ToIanaMapper(capi::ICU4XBcp47ToIanaMapper *i)
Definition ICU4XBcp47ToIanaMapper.hpp:55
static diplomat::result< ICU4XBcp47ToIanaMapper, ICU4XError > create(const ICU4XDataProvider &provider)
Definition ICU4XBcp47ToIanaMapper.hpp:65
ICU4XBcp47ToIanaMapper()=default
Definition ICU4XDataProvider.hpp:32
Definition diplomat_runtime.hpp:84
result< T2, E > replace_ok(T2 &&t)
Definition diplomat_runtime.hpp:125
capi::DiplomatWriteable WriteableFromString(std::string &string)
Definition diplomat_runtime.hpp:31
Definition diplomat_runtime.hpp:69
Definition diplomat_runtime.hpp:55