#ifndef icu4x_RegionDisplayNames_HPP #define icu4x_RegionDisplayNames_HPP #include "RegionDisplayNames.d.hpp" #include #include #include #include #include #include #include "../diplomat_runtime.hpp" #include "DataError.hpp" #include "DataProvider.hpp" #include "Locale.hpp" #include "LocaleParseError.hpp" namespace icu4x { namespace capi { extern "C" { typedef struct icu4x_RegionDisplayNames_create_mv1_result {union {icu4x::capi::RegionDisplayNames* ok; icu4x::capi::DataError err;}; bool is_ok;} icu4x_RegionDisplayNames_create_mv1_result; icu4x_RegionDisplayNames_create_mv1_result icu4x_RegionDisplayNames_create_mv1(const icu4x::capi::DataProvider* provider, const icu4x::capi::Locale* locale); typedef struct icu4x_RegionDisplayNames_of_mv1_result {union { icu4x::capi::LocaleParseError err;}; bool is_ok;} icu4x_RegionDisplayNames_of_mv1_result; icu4x_RegionDisplayNames_of_mv1_result icu4x_RegionDisplayNames_of_mv1(const icu4x::capi::RegionDisplayNames* self, diplomat::capi::DiplomatStringView region, diplomat::capi::DiplomatWrite* write); void icu4x_RegionDisplayNames_destroy_mv1(RegionDisplayNames* self); } // extern "C" } // namespace capi } // namespace inline diplomat::result, icu4x::DataError> icu4x::RegionDisplayNames::create(const icu4x::DataProvider& provider, const icu4x::Locale& locale) { auto result = icu4x::capi::icu4x_RegionDisplayNames_create_mv1(provider.AsFFI(), locale.AsFFI()); return result.is_ok ? diplomat::result, icu4x::DataError>(diplomat::Ok>(std::unique_ptr(icu4x::RegionDisplayNames::FromFFI(result.ok)))) : diplomat::result, icu4x::DataError>(diplomat::Err(icu4x::DataError::FromFFI(result.err))); } inline diplomat::result icu4x::RegionDisplayNames::of(std::string_view region) const { std::string output; diplomat::capi::DiplomatWrite write = diplomat::WriteFromString(output); auto result = icu4x::capi::icu4x_RegionDisplayNames_of_mv1(this->AsFFI(), {region.data(), region.size()}, &write); return result.is_ok ? diplomat::result(diplomat::Ok(std::move(output))) : diplomat::result(diplomat::Err(icu4x::LocaleParseError::FromFFI(result.err))); } inline const icu4x::capi::RegionDisplayNames* icu4x::RegionDisplayNames::AsFFI() const { return reinterpret_cast(this); } inline icu4x::capi::RegionDisplayNames* icu4x::RegionDisplayNames::AsFFI() { return reinterpret_cast(this); } inline const icu4x::RegionDisplayNames* icu4x::RegionDisplayNames::FromFFI(const icu4x::capi::RegionDisplayNames* ptr) { return reinterpret_cast(ptr); } inline icu4x::RegionDisplayNames* icu4x::RegionDisplayNames::FromFFI(icu4x::capi::RegionDisplayNames* ptr) { return reinterpret_cast(ptr); } inline void icu4x::RegionDisplayNames::operator delete(void* ptr) { icu4x::capi::icu4x_RegionDisplayNames_destroy_mv1(reinterpret_cast(ptr)); } #endif // icu4x_RegionDisplayNames_HPP