1 #ifndef icu4x_EastAsianWidth_D_HPP 2 #define icu4x_EastAsianWidth_D_HPP 3 4 #include <stdio.h> 5 #include <stdint.h> 6 #include <stddef.h> 7 #include <stdbool.h> 8 #include <memory> 9 #include <functional> 10 #include <optional> 11 #include "../diplomat_runtime.hpp" 12 13 namespace icu4x { 14 class EastAsianWidth; 15 } 16 17 18 namespace icu4x { 19 namespace capi { 20 enum EastAsianWidth { 21 EastAsianWidth_Neutral = 0, 22 EastAsianWidth_Ambiguous = 1, 23 EastAsianWidth_Halfwidth = 2, 24 EastAsianWidth_Fullwidth = 3, 25 EastAsianWidth_Narrow = 4, 26 EastAsianWidth_Wide = 5, 27 }; 28 29 typedef struct EastAsianWidth_option {union { EastAsianWidth ok; }; bool is_ok; } EastAsianWidth_option; 30 } // namespace capi 31 } // namespace 32 33 namespace icu4x { 34 class EastAsianWidth { 35 public: 36 enum Value { 37 Neutral = 0, 38 Ambiguous = 1, 39 Halfwidth = 2, 40 Fullwidth = 3, 41 Narrow = 4, 42 Wide = 5, 43 }; 44 45 EastAsianWidth() = default; 46 // Implicit conversions between enum and ::Value EastAsianWidth(Value v)47 constexpr EastAsianWidth(Value v) : value(v) {} operator Value() const48 constexpr operator Value() const { return value; } 49 // Prevent usage as boolean value 50 explicit operator bool() const = delete; 51 52 inline static icu4x::EastAsianWidth for_char(char32_t ch); 53 54 inline std::optional<std::string_view> long_name(); 55 56 inline std::optional<std::string_view> short_name(); 57 58 inline uint8_t to_integer_value(); 59 60 inline static std::optional<icu4x::EastAsianWidth> from_integer_value(uint8_t other); 61 62 inline icu4x::capi::EastAsianWidth AsFFI() const; 63 inline static icu4x::EastAsianWidth FromFFI(icu4x::capi::EastAsianWidth c_enum); 64 private: 65 Value value; 66 }; 67 68 } // namespace 69 #endif // icu4x_EastAsianWidth_D_HPP 70