1 #ifndef icu4x_PluralCategory_D_HPP 2 #define icu4x_PluralCategory_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 PluralCategory; 15 } 16 17 18 namespace icu4x { 19 namespace capi { 20 enum PluralCategory { 21 PluralCategory_Zero = 0, 22 PluralCategory_One = 1, 23 PluralCategory_Two = 2, 24 PluralCategory_Few = 3, 25 PluralCategory_Many = 4, 26 PluralCategory_Other = 5, 27 }; 28 29 typedef struct PluralCategory_option {union { PluralCategory ok; }; bool is_ok; } PluralCategory_option; 30 } // namespace capi 31 } // namespace 32 33 namespace icu4x { 34 class PluralCategory { 35 public: 36 enum Value { 37 Zero = 0, 38 One = 1, 39 Two = 2, 40 Few = 3, 41 Many = 4, 42 Other = 5, 43 }; 44 45 PluralCategory() = default; 46 // Implicit conversions between enum and ::Value PluralCategory(Value v)47 constexpr PluralCategory(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 std::optional<icu4x::PluralCategory> get_for_cldr_string(std::string_view s); 53 54 inline icu4x::capi::PluralCategory AsFFI() const; 55 inline static icu4x::PluralCategory FromFFI(icu4x::capi::PluralCategory c_enum); 56 private: 57 Value value; 58 }; 59 60 } // namespace 61 #endif // icu4x_PluralCategory_D_HPP 62