PluralCategory.d.hpp (2094B)
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 <cstdlib> 12 #include "../diplomat_runtime.hpp" 13 14 namespace icu4x { 15 class PluralCategory; 16 } 17 18 19 namespace icu4x { 20 namespace capi { 21 enum PluralCategory { 22 PluralCategory_Zero = 0, 23 PluralCategory_One = 1, 24 PluralCategory_Two = 2, 25 PluralCategory_Few = 3, 26 PluralCategory_Many = 4, 27 PluralCategory_Other = 5, 28 }; 29 30 typedef struct PluralCategory_option {union { PluralCategory ok; }; bool is_ok; } PluralCategory_option; 31 } // namespace capi 32 } // namespace 33 34 namespace icu4x { 35 /** 36 * See the [Rust documentation for `PluralCategory`](https://docs.rs/icu/latest/icu/plurals/enum.PluralCategory.html) for more information. 37 */ 38 class PluralCategory { 39 public: 40 enum Value { 41 Zero = 0, 42 One = 1, 43 Two = 2, 44 Few = 3, 45 Many = 4, 46 Other = 5, 47 }; 48 49 PluralCategory() = default; 50 // Implicit conversions between enum and ::Value 51 constexpr PluralCategory(Value v) : value(v) {} 52 constexpr operator Value() const { return value; } 53 // Prevent usage as boolean value 54 explicit operator bool() const = delete; 55 56 /** 57 * Construct from a string in the format 58 * [specified in TR35](https://unicode.org/reports/tr35/tr35-numbers.html#Language_Plural_Rules) 59 * 60 * See the [Rust documentation for `get_for_cldr_string`](https://docs.rs/icu/latest/icu/plurals/enum.PluralCategory.html#method.get_for_cldr_string) for more information. 61 * 62 * See the [Rust documentation for `get_for_cldr_bytes`](https://docs.rs/icu/latest/icu/plurals/enum.PluralCategory.html#method.get_for_cldr_bytes) for more information. 63 */ 64 inline static std::optional<icu4x::PluralCategory> get_for_cldr_string(std::string_view s); 65 66 inline icu4x::capi::PluralCategory AsFFI() const; 67 inline static icu4x::PluralCategory FromFFI(icu4x::capi::PluralCategory c_enum); 68 private: 69 Value value; 70 }; 71 72 } // namespace 73 #endif // icu4x_PluralCategory_D_HPP